one to many relationship in database - design concept

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

    A one-to-many relationship should be implemented with 2 tables.

    But the relationship you propose in your example (between Authors and Books) is not one-to-many, is many-to-many.

    "An Author can write many Books, and a Book can be written by one or more Authors."

    And a many-to-many relationship should be implemented with 3 tables.

    Have a good day.

提交回复
热议问题