Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Eloquent 可以有效地管理与 Eloquent 模型的所有关系。那么,我真的需要在数据库中维护外键关系吗?在数据库级别维护关系是否会对应用程序的性能产生任何额外的影响,因为数据完整性已经由 ORM 层管理?
我个人不喜欢在使用 Eloquent 时在数据库中保留外键关系,因为我想在一个地方(应用层)处理所有依赖逻辑。
在性能方面确实没有理由拥有外键,这纯粹是一个架构/设计决定。