| Lesson 1 | Introduction to Entity-Relationship Diagrams |
| Objective | Explain how entity-relationship diagrams describe entities, relationships, cardinality and participation, and guide the design of relational tables. |
An entity-relationship diagram (ERD) describes the things a system records and the associations between them. It helps you turn business statements such as “customers place orders” into a model with explicit identifiers and relationship rules.
An ERD is useful before writing SQL because it exposes decisions that table names alone cannot answer. Can a customer exist without an order? Can a student enroll in several classes? What identifies an enrollment? This module develops those questions through worked examples and then shows how to implement the answers with keys and constraints.
The diagram is a model of agreed requirements. Its accuracy depends on the rules you establish with the people who use the system.
| Concept | Meaning | Example |
|---|---|---|
| Entity type | A kind of thing about which the system records facts | Customer or Order |
| Entity instance | One particular occurrence of that type | Customer 101, Ava |
| Attribute | A fact describing an entity or association | CustomerName, OrderDate or an enrollment's Grade |
| Identifier | An attribute or combination that distinguishes instances | CustomerID |
| Relationship | A meaningful association between instances | A customer places an order |
| Cardinality and participation | The permitted maximum and minimum of related instances | Zero or many orders per customer |
In a typical relational implementation, an entity type maps to a table, an instance to a row, and an attribute to a column. The logical design may introduce additional tables or restructure the initial conceptual model. A relationship can also have its own attributes: a grade describes a particular student's enrollment, rather than the student or class alone.
The labels 1:1, 1:N and M:N summarize maximum cardinalities. They do not establish whether participation is optional. Read each relationship from both ends.
| Type | Business rule | Typical implementation |
|---|---|---|
| One-to-one (1:1) | In this system, a person has at most one current passport; each passport belongs to one person. | A foreign key with a uniqueness constraint, or a shared primary key |
| One-to-many (1:N) | A customer may place many orders; every order belongs to exactly one customer. | A required foreign key in Order referencing Customer |
| Many-to-many (M:N) | A student may take many classes; a class may have many students. | An Enrollment table with references to both parents |
The passport example is a deliberately limited rule about one current passport in the modeled system. Recording multiple passports or passport history would require a different model. State such boundaries rather than presenting a simplified example as a universal real-world rule.
A one-to-one relationship can support separate security, lifecycle or optional-detail requirements. It should have a reason beyond splitting columns arbitrarily. A one-to-many relationship read in reverse is many-to-one; the foreign key still belongs on the many side.
A many-to-many association is valid in a conceptual ERD. Its relational implementation normally introduces an associative table, also called a junction or linking table. Enrollment turns the table representation into Student → Enrollment and Class → Enrollment, two 1:N relationships, while preserving the original business association.
Optional participation permits zero related instances. Mandatory participation requires at least one. Determine this separately for each direction.
A customer can therefore participate optionally in the customer/order relationship even though every order has a required customer reference. Do not describe the entire relationship as mandatory or optional without identifying the viewpoint.
ER modeling uses several notations. Chen commonly shows entities as rectangles, attributes as ovals and relationships as diamonds. Crow's Foot uses endpoint symbols for one, many and optionality. IDEF1X is a distinct notation with its own conventions; it should not be treated as another name for Crow's Foot.
The updated examples in this module also use numeric labels such as 1, 0..1 and 0..many. A label near an entity tells you how many instances of that entity can relate to one instance at the opposite end. Thus a 1 near Customer means one customer per order; 0..many near Order means zero or many orders per customer.
Read an unfamiliar diagram's legend before interpreting its symbols. Continue with the notation comparison and Crow's Foot guide when you need the notation details.
For example, ClassID should identify the relevant scheduled offering if students can take the same subject in different terms. If repeated attempts are recorded, the enrollment key must distinguish them. Diagram and key choices depend on what one stored instance actually means.
Write “each order belongs to exactly one customer; each customer may have zero or many orders.” This gives you entities, a relationship, both maxima and both minima. Repeat that process for each association before choosing keys or drawing symbols.
Up next: Lesson 2 introduces the entity-relationship concept through the Employee–Project example. Later lessons develop the three relationship types, associative tables, and mandatory and optional participation.