views:

152

answers:

6

Can we apply two primary keys in a table in anyway?

+2  A: 

Suppose you have an Employee. This employee has an EmployeeType of some sort (one foreign key). And this Employee has an EmployeeDepartment connection (another foreign key).

If I understand your question correctly, of course.

Denis Valeev
A: 

Yes , You can....

Assume Emp table with this structure ,

Emp#  DeptId   BusinessUnit

Deptid references from Department table ,

BusinessUnit references from BusinessUnit table.

The above structure i showed is an example,a table can contain any number of foreign keys.

srinivas reddy thatiparthy
A: 

Yes, you can have as many foreign keys as you like. Just add them.

When I want to create a constraint to enforce the foreign key, I create a diagram with the tables, and drag a connection from the primary key to the foreign key.

Depending on how you use the keys in queries, you might want to create an index for it also.

Guffa
A: 

there should be one primary key but there can be more than 1 foreign key if the table has references to other tables

PaulStack
+1  A: 

Yes you can. Although I can't be sure this is the correct answer for you as your question is so vague.

Foreign Key information

Barry