ER diagram
ER-диаграмма
An entity–relationship diagram shows what kinds of things a system stores data about, what details it records, and how those things relate to one another.
Also known as: модель данных
What an ER diagram shows
An ER diagram gives a team a shared picture of its data. In a course platform, Student and Course are entities: kinds of things the system needs to track. A particular student is an instance of Student, and the student's email address is an attribute. “A student enrolls in a course” describes a relationship.
The diagram is a view of the data model, not the model itself. An early sketch might focus on business concepts without showing any tables. A diagram of a relational schema can go further and show columns, data types, primary keys, and foreign keys.
Read each relationship both ways
Ask how many instances at one end can be linked to a single instance at the other end. The maximum tells you whether the relationship is one-to-one, one-to-many, or many-to-many. The minimum tells you whether participation is optional. “A student can take many courses” leaves a question unanswered: can a student exist in the system before enrolling in any course?
In Crow’s Foot notation, a circle means zero, a bar means one, and the fork means many. You may also see ranges such as 0..* (zero or more) and 1..* (one or more).
Example: course enrollment
A student can enroll in several courses, and each course can have several students. In a relational database, represent this many-to-many relationship with an Enrollment table:
Student 1 ───── 0..* Enrollment
Course 1 ───── 0..* Enrollment
Each enrollment points to exactly one student and one course; either a student or a course can exist without any enrollments. The enrollment date belongs on Enrollment because it describes when this student joined this course. In SQL, two NOT NULL foreign keys can enforce the required references. If a student may enroll in a course only once, a unique constraint on (student_id, course_id) enforces that rule. The foreign keys alone do not prevent duplicate enrollments.
Where it helps and what interviewers look for
Teams draw ER diagrams before writing SQL to settle questions about the business rules. They also use diagrams of existing schemas to understand how tables join or to plan a migration. A line on a diagram does not prove that the database enforces the rule it represents: a foreign key from Enrollment to Course, for example, cannot guarantee that every course has at least one student.
In an interview, start by stating assumptions and test them with concrete cases. Can a student retake a course? If enrollments are tied to scheduled offerings, you might introduce CourseOffering and allow one enrollment per student per offering instead of per course. Explaining why the requirement changes the model matters more than drawing the notation perfectly.