Keys and Relationships
Use primary and foreign keys to connect related tables.
Keys and Relationships
A primary key identifies a row in one table. A foreign key points to a primary key in another table.
sql
CREATE TABLE orders (
id INT PRIMARY KEY,
customer_id INT,
FOREIGN KEY (customer_id) REFERENCES customers(id)
);