Composite Keys in SQL — a practical guide to SQL composite key with clear examples you can reuse in real projects.
SQL Tutorial Series (10/100). Prefer one article? Read the complete SQL tutorial.
Short description
Common in junction tables for many-to-many relationships.
Composite PK
CREATE TABLE course_user (
course_id INT UNSIGNED NOT NULL,
user_id INT UNSIGNED NOT NULL,
PRIMARY KEY (course_id, user_id)
);