Understanding Primary Keys in MySQL
A primary key is a column or a combination of columns that uniquely identifies each row in a table. It ensures that no two rows have the same value in the primary key column(s) and that the value is never NULL.
Uniquely identifies each row in the table.
Cannot contain NULL values.
Automatically creates a unique index.
Ensures entity integrity in relational databases.
A table can only have one primary key constraint.
However, that primary key can consist of multiple columns — this is called a composite primary key.
You cannot define two separate primary keys in one table.
In this example, neither student_id nor course_id alone uniquely identifies a row, but the combination does — forming a composite primary key.