English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

In SQL, I have created two tables Employee and Personal. Can i keep Employeenumber as "primary key" for both the tables or Personal table should contain some other primary key?

2007-08-12 11:18:39 · 4 answers · asked by Anonymous in Computers & Internet Programming & Design

4 answers

Firstly, I believe the other table should be named "Personnel", not "Personal".

Technically, you can have employee_number as the Primary key in both tables. I believe you know that Primary key value cannot be NULL. So all personnel should have an employee_number if you are making it a primary key.

But doing this will not make sense because :
1. If all personnel have an employee_number, there is no need to maintain two different tables. You can just have the Employee table.
2. If the purpose of two tables is to maintain master - detail relationship, then you should have a Primary key - Foreign key relation. Employee_number should be Primary key in one table ( Employee) and Foreign key in the other table (Personnel) or vice versa.

2007-08-12 11:41:46 · answer #1 · answered by Anonymous · 1 1

yes yu can have same field names in two tables.

2007-08-12 18:28:20 · answer #2 · answered by swapna491 2 · 0 1

They can be and are often the same name.

2007-08-12 18:26:13 · answer #3 · answered by mdigitale 7 · 0 1

yes, you could name both id if you wanted

2007-08-12 18:24:42 · answer #4 · answered by Big D 4 · 0 1

fedest.com, questions and answers