one to many relationship in database - design concept

前端 未结 5 1204
日久生厌
日久生厌 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:35

    If the relationship is actually one to many, there is no need for a linking table (authorConnectsBooks in your example). In your example, however, you don't have a one-to-many relationship since one author can write many books and one book can be written by many authors. In your example, you actually have a many-to-many relationship. If you actually have a many-to-many relationship, then you do need a linking table (authorConnectsBooks in your example).

提交回复
热议问题