Primary Key vs Foreign Key
PRIMARY KEY is this table’s identity (students.roll). FOREIGN KEY is a pointer in another table (marks.roll) that must match a parent PK/UNIQUE. Parent first, then child.
You can query without declaring an FK, but then the database will not stop orphans. Declare the FK.
Trap — putting the FK on the parent instead of the child.
On the example next to this theory: Primary Key vs Foreign Key — keys and constraints protect data integrity; indexes speed lookups.
students.id ← PK (unique)
▲
│ FK
marks.student_idExam tip
students.roll PK. marks.roll FK → students.roll.