sql - table design issue for normalizing multiple catogories sharing similar data -


I'm a little confused in a table design

Method 1) I have a phonecard table with the first method I can select all the phone numbers and filter the employee phone number by specifying the type. Method 2) In the second method, I can select all from joining two tables and get employee phone number.

I have the same problem with addresses. I have employees, customers, employees and other people know that I have googled and still can not choose which is the right way which is the right way and why others And no other better design for this?

Method 1

  Employee ID. Name 1 e customer ID. Name 1c phone_book type | Fk_id | Phone E1 123123123 C1451323123   

Method 2

  employee ID | Name 1 e customer ID. Name 1c staff_phone_book emp_id | Phone 1 1231233434 2 6273343423 customer_phone_book cus_id | Phone 1 5231233434 2 1251233434   

Edit: Employees and customers can have multiple phone numbers. And with address details.

  employee ID | Name | Phone_id 1 E1 Customer ID | Name | Phone_ id 1c2 phone_book phone_id | Phone 1 123123123 2 451323123   

The phone should be referenced to me employee and customer tables (from FK to phone_book table)

Update: If the customer / employee can have multiple phones then it will be better to define multiple-to-many relationships like additional table

  customer_phone phone_id | customer_id (reference to customer table) 1 1 2 1    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -