Is it bad to store information such as: name, phone number, address etc. in one table? That would result in the Employee and Customer Table having a foreign key referencing to the "People" Table.
If we don't store such information in one table, we would have the Employee and Customer Table have a lot of similar type of information.
What would be the best design?
The customer table contains a list of all customers. The customer table is referred to in the payment and rental tables and refers to the address and store tables using foreign keys.
Every business key table has the same structure: three metadata columns and a natural key value, which might be a single column or a concatenation of two or more.
The staff table refers to the store and address tables using foreign keys, and is referred to by the rental , payment , and store tables.
My personal preference: separate out customer and employee database. While some of the data may be same between customer and employee, it won't be long before data requirements and rules start differing. For example, for employees you may want to store birth dates but you may not need that for customer.
Keeping the table also prevents error in select
s. If customers and employees were reference in people and a newcomer doesn't know what to join and when to use the where
clause to separate customers and employees, the result may be unexpected and may go undetected. Having customer and employee separate avoids such issues.
Having them separate is also helpful in adding customer table to schema associated with customers/orders etc., and employee tables can go to hr related schema. Different levels of protection can be applied to them.
People table's maintenance may affect customer and employee tables. For example, if you had to add a column in a large people table, some RDBMS may lock the table too long. If tables were separate, you would be able to prepare only the relevant group.
Overall, I see little benefit in creating people table with FK related to customer and employees. Perhaps others on SO may raise benefits of people table.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With