Difference between one-to-one and one-to-many relationship in database

后端 未结 8 1453
执念已碎
执念已碎 2021-02-01 06:13

This is probably a basic(dumb) question but when having a one-to-one relationship in a database the other table has a foreign key ID(in this example). And in a one-to-many relat

8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-01 07:07

    In a sense, all the relationships we talk about are not known to the database, they are constructs we have invented to better understand how to design the tables.

    The big difference in terms of table structure between one-to-one and one-to-many is that in one-to-one it is possible (but not necessary) to have a bidirectional relationship, meaning table A can have a foreign key into table B, and table B can have a foreign key into the associated record in table A. This is not possible with a one-to-many relationship.

    One-to-one relationships associate one record in one table with a single record in the other table. One-to-many relationships associate one record in one table with many records in the other table.

提交回复
热议问题