PRIMARY KEY (Composite)
PRIMARY KEY (Composite) is a SQL statement in the Constraints category. A composite primary key uses two or more columns to uniquely identify a row. The syntax is CREATE TABLE table (col1 type, col2 type, PRIMARY KEY (col1, col2));. It returns composite PK constraint. A typical example: CREATE TABLE order_items ( order_id INT, product_id INT, quantity INT, PRIMARY KEY (order_id, product_id) ); -- Each product can appear once per order -- But same product can appear in different orders A close relative is PRIMARY KEY, which a column or set of columns that uniquely identifies each row. Only one PK per table. Automatically creates a unique index. A close relative is FOREIGN KEY, which ensures referential integrity: values in this column must exist in the referenced parent table. A close relative is UNIQUE, which ensures all values in a column (or combination) are unique across the table. Allows NULLs (multiple NULLs allowed).