one to many relationship in database - design concept

前端 未结 5 1220
日久生厌
日久生厌 2020-12-30 11:46

A one to many relationship between two tables should be implemented with two or three tables? For example should we have:

author(id,otherAttributtes)
books(i         


        
5条回答
  •  梦谈多话
    2020-12-30 12:44

    As everyone stated out, the first one is a one to many relationship in which you dont need the extra table. Just two tables should work. But in the second case, since its a many to many realtionship, you'll need to add an extra table known as the Junction or the cross-reference table because most database management systems only support one-to-many relationships, it is necessary to implement such relationships manually via a third junction table. The junction table's primary key is normally formed using the primary keys of the tables it connects. Here is a wiki page that explains the exact same example that you asked:

    LINK

提交回复
热议问题