Database design models real-world data into tables, columns, relationships, and constraints.

Start with Entities

Examples:

Each entity often becomes a table.

Relationships

One-to-One

One user has one profile.

One-to-Many

One user has many orders.

users.id -> orders.user_id

Many-to-Many

Students enroll in many courses; courses have many students.

Use a junction table:

CREATE TABLE enrollments (
  student_id INT REFERENCES students(id),
  course_id INT REFERENCES courses(id),
  PRIMARY KEY (student_id, course_id)
);

Cardinality

Cardinality describes how many rows can participate in a relationship.

Examples:

Schema Design Tips

Interview Notes