What are the differences between Unique Key, Primary Key and Foreign Key with respect to concept of SQL
?
How they are different from each other?
What are the differences between Unique Key, Primary Key and Foreign Key with respect to concept of SQL
?
How they are different from each other?
A PRIMARY Key and UNIQUE Key constraints both are similar and it provide unique enforce uniqueness of the column on which they are defined.
Note: we use constraint for enforce data integrity
Primary Key
1)can't insert null value
2) one table have one primary key
Unique key 1) insert null value one at time 2)one table have multiple unique key 3) you can refereed as candidate key also
foreign key 1) maintain the relationship between two table and also multiple Note: without any constraint you get data in multiple table but you can not get data peoperly
A note about Unique key
The parent table in a Primary Key-Foreign Key relation is normally called as Primary Key table but PK is not mandatory in a parent table. A unique key/constraint in parent table is sufficient. As PK is always unique, it is often used as foreign key in another table. see this SO post
© 2022 - 2024 — McMap. All rights reserved.