Primary Key:-
- The primary key is uniquely identifier in the table
- The primary key is not more than once in the table.
- The primary key needs a UNIQUE value and is not null.
Foreign key:-
- The foreign key is used to make link b/w more than one table.
- The foreign key is field/collection of fields which are primary key in another table fields.
Unique Key:-
- The Unique key is same like primary key provide feature of uniqness .
- All Value are different and unique in unique key fields.
So my question is that----
- there are any simple definition to define primary, foreign, and unique key in one paragraph????
- What is different b/w Primary and foreign key????
- What is different b/w Primary and Unique key????
- What is different b/w Foreign and Unique Key????

Sachin SinghPosted Jun 24, 2021, 12:11 PM
first, they all are constraints and the sole purpose of all of them is to maintain database integrity.
1. Primary key:- By default clustered unique index means there can be only one PK, also this is the only reason you can not create another clustered index until you delete the primary key.
2. Foreign key:- to enforce referential integrity, so that if there is no department with ID=4 then you will not be allowed to enter DepId=4 in another table like an employee table. So it forces that the data must be present in the primary key table, here the primary key table is the department that acts as a foreign key for other tables like the employee table.
3. Unique key:- so that no duplicate entry will be allowed, but one null entry is possible, not more than one null entry.
If you follow the constraints then your database will always be in a consistent state.
Rajanikant HawaldarPosted Jun 24, 2021, 11:59 AM
https://www.c-sharpcorner.com/article/difference-between-primary-key-and-foreign-key-in-sql-server/
https://www.c-sharpcorner.com/article/understanding-concept-of-foreign-key-through-gui-in-sql-server/
https://www.c-sharpcorner.com/blogs/primary-key-and-foreign-key
https://www.c-sharpcorner.com/blogs/difference-between-primary-key-unique-key-and-foreign-key1
Rahul ChauhanPosted Jun 24, 2021, 11:12 AM
Really its useful salman
Salman BegPosted Jun 24, 2021, 11:04 AM