+ 1
What is the difference between primary and foreign key?
I still find it confusing and I need more questions to further explicate its difference
6 Antworten
+ 14
Primary key is unique identifier in a table while foreign key is a field in one table which is primary key in other table.
Primary key can't accept null values while foreign key can accept multiple null values.
Only one primary key is possible for a table but multiple foreign keys are possible which link multiple tables to parent table
Edit: This might help
https://www.essentialsql.com/what-is-the-difference-between-a-primary-key-and-a-foreign-key/
+ 12
I guess for each table.. there can be one primary key
+ 2
only one primary in one database or only one primary in each table? :D
+ 2
Thank you it somewhat enlightens me! @frost
+ 1
for each table there is only one primary key and it cannot be null.
0
Primary key is unique and not null but foreign key is may or may not be unique and nulls accepted and also duplicate rows allowed