how to save marital relationship in a database

后端 未结 6 1571
说谎
说谎 2021-01-18 11:28

I have to save this information in a database

Person -> is married to -> Person

Where should I save that information? What is the proper design pattern shoul

6条回答
  •  一整个雨季
    2021-01-18 12:16

    This is a great question for teaching schema design. What seems like a simple problem can easily become quite complicated:

    E.g., how to handle:
    - mariages of more than two people
    - different types of marriage (legal, religious, other)
    - concurrent marriages
    - repeat marriages
    - divorce
    - self-marriage (hey, it happend on Glee!)

    The trick, if there is one, is to carefully think out all the permutations of what you are trying to model. Only then do you actually go ahead and model it.

提交回复
热议问题