Understanding Primary and Foreign Keys
Published October 08, 2026
By Sai Sree Ram Gundepudi
Primary Key
CREATE TABLE users (
id INT PRIMARY KEY,
name VARCHAR(100)
);Foreign Key
CREATE TABLE orders (
id INT,
user_id INT,
FOREIGN KEY (user_id) REFERENCES users(id)
);