且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用一对一表关系有什么优点? (MySQL)

更新时间:2022-12-26 20:54:58

我使用了一对一的关系用于扩展现有应用程序中的某些功能,而不会影响应用程序数据库结构。

I've used one to one relationship for extending some features in existing applications, without affecting the application db structure. This is an unobtrusive way to extending existing db tables.

使用一对一关系的另一个原因是为了实现 Class表继承,其中层次结构中的每个类都有一个表,一个对象在其表类,其父类表,其祖父类表等中具有相应的行。

Another reason to use one-to-one relationship is for implementing Class Table Inheritance, in which each class in the hierarchy has a table, and an object has a corresponding row in his table class, in his parent class table, in his grandparent class table and so on.

例如,请参阅Doctrine 2 类表继承页面

See, for example, Doctrine 2 Class Table Inheritance Page