I would like to know if there's a better way to design this kind of relationships within Postgre:
Basically, I've got some entities that are either an EntityA
, an EntityB
or an EntityC
. I will have plenty of other relationships between entities and other stuff (like Comment
in this case) so I've got this generic Entity
that defines which type of Entity
it's linked to.
As an example, if we have an EntityA linked to a comment, the Entity entry will look like:
type: EntityA
entity_a_id: x
entity_b_id: null
entity_c_id: null
Is there a better way to design this?