-3

Given the two models company and person I'm noticing duplicate fields i.e. zipcode, emailaddress for each.

Yet, a short research reveals a reasonable popularity for separating those two entities into two tables (in terms of customer relation management databases [crm]).

Would one contact table with appropriate fields or foreign tables to distinct not suffice for both?

4
  • The answer is as always: depends on your use case. Commented Mar 20 at 8:59
  • Are both used identically? If you are just sending out news letters it might not matter. But for a full blown CRM you probably want to handle companies differently from people. You might also want "site" or "office", since that is often useful to know.
    – JonasH
    Commented Mar 20 at 9:04
  • @PhilipKendall In what use case is a person or a company not a contact?
    – jjk
    Commented Mar 20 at 9:14
  • This seems like a CRM-specific question; the term 'contact' seems to be commonly used in CRMs, but different CRMs may define the term differently: What is a contact in CRM? Commented Mar 20 at 13:13

2 Answers 2

2

The question is tagged with database and domain-driven-design and the answer is different for these.

From a DDD perspective, it is a bad idea to combine separate concepts into a single concept just because they share some or even all properties. In the domain, what matters is the behavior that the concepts have. If multiple concepts share the exact same behavior, you can consider to merge them into a single concept, as long as the business agrees that it makes sense and you can find a good enough term for it in the ubiquitous language.

In the database, if storing data for separate entities in a single table helps performance, reduce costs, or whatever other reason you may have, then you could consider it. As long as you can map the data back to the domain entities you should be fine. Should you actually do this? Probably not. In practice such optimizations are rarely worth it.

1

Each company can have more than one contact. It is also possible for a person to be a contact for more than one company.

If a company has many locations each contact can have a different mailing address.

You will have to determine what information has to be in the company table but not in the contact table.

Not the answer you're looking for? Browse other questions tagged or ask your own question.