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

前端 未结 10 1094
醉梦人生
醉梦人生 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:26

    It really looks like you are wanting to create a series of custom join tables, that are used to associate items from one entity to another.

    I would start at the most granular level, person and say that ANY author must be a person. I would simplify that process.

    Create a person table with person information and a PersonId, put the information in there.

    THen create a BookAuthors table, with 3 columns BookId, PersonId, TitledName. THis way you can use a different name if needed, if not, you can use COALESE or something similar to get the default name if TitledName is null.

    Just an idea..

提交回复
热议问题