Click here to Skip to main content
15,610,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a column that contains primary key.
i use the same column in another table by using join query? after using the same column in another table is it possible to insert duplicate values?
thanks in advance
Member 10434230 6-Jan-14 4:06am    
so you wanna say that you have 2 tables, in 1 table there is a PK column and the other one is having no PK, right?

What you are talking about in your question is called FOREIGN KEY[^]

You cannot insert duplicate values in a primary key column. Primary key columns are unique.

Lets see how foreign key works. You usually create foreign key column in a table when the tables have 1-m relationship. Consider Employee-Department scenario. 1 department can have many employees. So you create foreign key DepartmentId (primary key from Department table) in employees table.
Now to answer your question, yes this column may have duplicate/repeated values because the there could be more than 1 employee in a department.

I hope that clears your doubt.
Share this answer

Primary key has its own defination in its name , means that it can not allow duplicate values even null value.
And you are talking about FOREIGN key. it is the column of other table .
So depend your requirement it will be 1-1,1-Many, Many-1, Many-Many relationships.
So yes it will allowing you to enter duplicate value in reference key columns.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900