Explain the difference between primary keys and foreign keys?



Explain the difference between primary keys and foreign keys?..

Answer / Sonam Sidhu

Primary Key is a unique column or set of columns in a table that is used to identify each row uniquely. It cannot contain NULL values. A Primary Key ensures data integrity and enforces uniqueness of rows within a table. Foreign Key, on the other hand, is a column (or set of columns) in one table that refers to the primary key in another table. It is used to establish a relationship between two or more tables in a database.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL Server Interview Questions

How to update a field in SQL after ALTERING a row?

1 Answers   Amdocs,


What is Dedicated Administrator Connection in sql server 2005?

2 Answers  


what is the maximum size of a row in sql server 2000 and 2005

2 Answers  


what is denormalization and when would you go for it? : Sql server database administration

1 Answers  


how to delete duplicate rows from table in sql server

12 Answers   HCL, UHG,


Is it possible to have more then one foreign key in a single table? if possible, is this the good way to design the table?

2 Answers  


What is difference between index and primary key?

1 Answers  


How to execute a stored procedure in ms sql server?

1 Answers  


Write a SQL query to delete a table?

1 Answers   Amdocs,


What is ACID Property of Transaction?

10 Answers  


Explain basic SQL queries with SELECT from where Order By, Group By-Having?

3 Answers   TetraSoft, Wipro,


What is compression - row-level and page-level compression?

1 Answers  


Categories