How to model multiple types of contacts?

by lessless   Last Updated October 19, 2019 23:06 PM

I'm not sure if this can be called a polymorphic association - what is needed is to for each Message to have a Sender Contact and a Recipient Contact. Both Sender Contact and Recipient Contact could be one of 2+ types. Currently SMS and Email are supported but more may come.

I have this urge to eliminate a possible duplication that would appear in case of having two different tables - sender_contacts and recipient_contacts. Also type column is a kinda of a DB-modeling smell. But I'm not a DB modelling expert and rather looking for an advise from an experts how to properly model those relationships.

Any input is appreciated.

Thanks.



Related Questions


Updated May 19, 2016 07:46 AM

Updated December 09, 2016 08:02 AM

Updated February 16, 2018 17:06 PM

Updated February 17, 2017 21:06 PM