Defining Primary Keys in MySQL
A primary key is a column (or a group of columns) that uniquely identifies each row in a table. It ensures no two rows have the same primary key value and that the column(s) cannot contain NULL.
Ensure each row is uniquely identifiable.
Improve query performance using indexes created automatically.
Prevent duplicate or NULL values in the key column.
Enable relationships with foreign keys in other tables.
Define it inline with the column.
Define it separately at the table level.
Use composite (multi-column) primary keys.
Composite primary keys enforce uniqueness across a combination of columns instead of a single column.