Database design - Similar Contact Information for multiple entities

戏子无情 提交于 2019-12-04 14:39:33

You are correct when you say "it depends". It depends on what your data will be used for OLTP you would look at a normalized design, and a reporting system you would want the data de-normalized with the contact information inline with the other data components.

In the normalized database, the level of normalization can also be debated. Some will say to have contact information granular like you have in your first scenario. I like to go "middle of the road" I would have all contact information in one table, which included address, telephone and email.

Contact
ID, Address, Address2, City, State, Zip, Phone, Email

Then create a relationship with a separate table

CompanyContact
ID, CompanyID, ContactID

This too could be integrated into the company table, by just adding a ContactID to the Company table and avoid the separate relationship and join.

You could also implement a table with ContactTypes.

ContactType 
ID, ContactType
1, Company
2, Charity
3, Auditor
....

Then you could specify that in the CompanyContact table and remove the need for a relationship. Although it fits your scenario of 1 contact per type it does not leave room for growth.

I like your method 2 better, but it still seems too much work. Why not just have a PhoneNumber, Address, etc... tables that store ALL addresses, phone numbers, whatevers, then reference that from the Company, Auditor, etc...? It's probably how I would have done it.

You could use a single table for all and use data types like below.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!