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 smartest way to achieve that?
I have thought about a table link "actor" like this (drawn with the excellent yUML.me BTW) :
In the actor
table, according to actor_type
, person_id
or company_id
is a foreign key on its corresponding table or is NULL
. This way, when one_table
wants to retrieve details about the actor
, I start by checking the actor_type
field and retrieve either person_id
or company_id
.
It is working, but I am looking for a better design. Here is the link for editing the diagram