Database : what design to point on two possibilities?

后端 未结 3 544
执念已碎
执念已碎 2021-01-24 09:25

I am designing a datamodel for a new project.

One of the requirements specifies that some objects can point either a person or a company.

What is the sma

3条回答
  •  后悔当初
    2021-01-24 09:57

    This is a classic case of classes/subclasses (or, if you prefer types/subtypes). I suggest you visit the following three tags and look over both the tagged questions and also the tag wiki you can see under "learn more".

    single-table-inheritance class-table-inheritance shared-primary-key

    This may give you all the answers you need. Or you may prefer to add one or more of these tags to your question, so as to attract more answers.

    Note: the reason the word "inheritance" is used in the tags is that these techniques allow you to gain some of the benefits that are built into object environments that implement inheritance.

提交回复
热议问题