Sketch a domain as entities, attributes, and relationships — then mechanically turn the diagram into relational tables.
The entity-relationship (ER) model is a picture of your data *before any tables exist*. You draw the real-world things you care about — entities — as rectangles, the facts about them — attributes — as ovals, and the meaningful links between them — relationships — as diamonds. It is a design-time sketch. A mechanical recipe then turns that diagram into actual tables, which is why join tables appear seemingly from nowhere.
Students).name, age). The key attribute — the one that tells each entity apart — is underlined (a student_id).Student *enrolls in* Course). It can carry its own attributes that belong to the pairing, like the grade.Two entities: Student (key student_id, plus name) and Course (key course_code, plus title). One relationship: Enrolls, which is M:N (a student takes many courses, a course has many students) and carries its own attribute grade. Here is the mechanical mapping to tables.
-- Each entity becomes its own table; the key attribute becomes the primary key
CREATE TABLE Student (
student_id INT PRIMARY KEY,
name VARCHAR(60)
);
CREATE TABLE Course (
course_code VARCHAR(8) PRIMARY KEY,
title VARCHAR(80)
);
-- An M:N relationship becomes its OWN table of foreign keys,
-- plus any attributes that belonged to the relationship itself
CREATE TABLE Enrolls (
student_id INT REFERENCES Student(student_id),
course_code VARCHAR(8) REFERENCES Course(course_code),
grade CHAR(1),
PRIMARY KEY (student_id, course_code)
);