How do you deal with m..n relationships in a relational database?

前端 未结 10 1106
醉梦人生
醉梦人生 2020-12-14 18:48

Let\'s look at an example - books. A book can have 1..n authors. An author can have 1..m books. What is a good way to represent all of the authors of a book?

I came

10条回答
  •  忘掉有多难
    2020-12-14 19:20

    The first thing that comes to mind is to have a link table, perhaps called AuthorOf to link books with their authors.

    The columns would be AuthorID, BookID and perhaps CreditAs, so you can differentiate between Dr. Bob and Bob, PhD. (As well as pen names like Stephen King and Richard Bachman).

    And you can still uniquely identify the author.

提交回复
热议问题