| Lesson 14 | Entity-Relationship Modeling: Review and Next Steps |
| Objective | Synthesize relationship types, participation and relational implementation; validate a model before drawing the next module's ER diagrams. |
An entity-relationship model turns business requirements into explicit statements about identity, associations and permitted data. This module developed three relationship types, one-to-one, one-to-many and many-to-many, alongside a separate question: must an instance participate, or may it exist without a related instance?
The central skill is reading a relationship in both directions. “Customers place orders” names an association but leaves important rules unanswered. “Every order belongs to exactly one customer; a customer may place zero or many orders” supplies both maximum cardinalities and both minimums. Those statements guide the diagram, foreign keys and application behavior.
This conclusion brings together the Person–Passport, Customer–Order, Department–Employee, Student–Class and Employee–Project examples. Use it as a review and as a practical sequence for checking a new design. The next module develops diagram conventions; the rules established here determine what those symbols should communicate.
An entity type describes a kind of thing recorded by the system, such as Student or Project. An instance is a particular student or project. Attributes describe those instances, while a relationship associates them. In a typical relational implementation, entity types become tables, instances become rows and attributes become columns, although logical design may restructure an initial conceptual model.
Start by defining what one instance represents. Does Class identify a subject in a catalog, a scheduled offering in a particular term, or a section of that offering? Does Passport represent a current record or every passport issued over a lifetime? Without those boundaries, a diagram can appear plausible while its key rejects legitimate data or permits duplicates.
Choose identifiers deliberately. A name is not automatically unique, and a generated identifier does not replace a business uniqueness rule. Define which facts depend on each identifier. Student names depend on StudentID; class details depend on ClassID; an enrollment grade describes a specific enrollment or attempt.
In Lesson 2's Employee–Project example, the assignment is represented by EmployeeProject. EmpID and ProjID identify its members, while AssignedDate and HoursWorked describe the assignment. If repeated assignment periods must be recorded, their identity must be added to the model rather than silently treating several events as the same pair.
The notation 1:1, 1:N or M:N summarizes the maximum number of related instances. It does not decide whether the minimum is zero or one. Lesson 3 compares the patterns; the following table connects each to its usual relational representation.
| Type | Maximum rule in both directions | Example | Typical table design |
|---|---|---|---|
| 1:1 | At most one related instance in either direction | Person and current Passport in the example system | Unique foreign key or shared primary key |
| 1:N | Several children per parent; at most one parent per child | Customer and SalesOrder | Foreign key on the many side |
| M:N | Several related instances permitted in both directions | Student and Class | Associative table with references to both parents |
Many-to-one is a one-to-many relationship read from the opposite end. Reversing the viewpoint does not move the foreign key or produce a fourth fundamental relationship type. Likewise, observing only one child per parent in today's data does not prove that the business permits only one.
In the scoped Person–Passport example, a person may have zero or one current passport, and every recorded passport belongs to exactly one person. That maximum must hold in both directions. It is a rule of this system, not a claim that people can never hold multiple passports in the real world.
Lesson 4 presents two implementations. A shared-key design makes Passport.PersonID both its primary key and a foreign key to Person. An independent-key design gives Passport its own PassportID and makes PersonID a required, unique foreign key. Both prevent two Passport rows from referencing the same Person under the stated rule.
The constraints perform distinct jobs. NOT NULL requires a reference; the foreign key validates its target; UNIQUE limits reuse of that target in Passport. They do not require every Person to have a Passport. Ben's Person row can therefore remain without a matching passport row.
Lesson 5 asks whether a separate table is justified by security, sparse details or lifecycle requirements. Splitting a table does not automatically improve performance, and a unique foreign key does not by itself establish mandatory participation for both parents. Review the purpose, access patterns and minimums before choosing the design.
For Customer and SalesOrder, one customer may have several orders, while each order references exactly one customer. SalesOrder.CustomerID is therefore a required foreign key. It remains non-unique so Ava can be referenced by orders 5001, 5002 and 5003. Adding UNIQUE would accidentally limit her to one order.
Lesson 6 illustrates the same rows from both viewpoints. Read from the customer, the relationship is one-to-many; read from an order, it is many-to-one. Ben can have no orders because the customer-side minimum is zero. The required CustomerID in each existing order does not change that minimum.
Lesson 7 applies the reasoning to departments, project managers and vendors. A finite maximum can still be greater than one. The example manager may have at most three active projects, so the relationship remains one-to-many rather than one-to-one.
The lesson's slot design combines a required slot numbered 1 through 3 with uniqueness on (ManagerID, ManagerSlot). It prevents more than three occupied slots per manager under that schema. That is a specific constraint strategy for the stated active-project rule; it should not be assumed to handle assignment history, transitions or every capacity requirement without further design.
A many-to-many relationship is valid conceptually. A normalized relational representation normally introduces an associative table whose rows record the actual links. Lesson 8 uses SalesOrder, Product and OrderItem: an order includes several products, and a product can appear on several orders.
OrderItem holds both references and Quantity. In the simplified design, (OrderID, ProductID) is the composite primary key, allowing a product once per order. If an order may contain repeated product lines with different configurations or delivery dates, an appropriate line identity is needed. The correct key follows the meaning of a row.
Lesson 9 develops Student, Class and Enrollment. Cindy takes Finance, Statistics and Spanish II; Finance has Cindy and Leo. A single ClassID in Student cannot store Cindy's several enrollments within that row. ClassID1, ClassID2 and ClassID3 impose an artificial maximum and complicate validation.
Enrollment instead records one pairing per row. Repeating StudentID or ClassID across different pairs is expected. A composite pair key rejects only a repeated combination. A surrogate EnrollmentID can make references from other tables convenient, but the same pair rule still needs a separate UNIQUE constraint when duplicate pairs are forbidden.
Lesson 11 implements the pattern with SQL. Each enrollment belongs to exactly one student and exactly one class; each parent can have zero or many enrollment rows. EnrolledOn and Grade belong to that association. Separate catalog courses, scheduled offerings and repeated attempts when the requirements distinguish them.
Lesson 10 examines a flattened table that stores enrollment pairs alongside copied student and class names. Cindy's name occurs three times; Finance occurs twice. If those rows are the authoritative storage of parent facts, renaming Finance requires changing every copy, and partial updates can leave contradictory values.
The same design cannot naturally store a class with no students when every row must be a complete enrollment. Removing the last enrollment for a class can also remove its only stored details. These insertion and deletion consequences depend on the stated single-table design; they do not follow merely from an M:N business relationship.
Separate Student facts, Class facts and Enrollment facts, then join them for reports. A joined report may legitimately display Cindy's name several times while the authoritative Student row stores it once. Repeated scalar values alone do not establish a first-normal-form violation. Identify the row's key and the dependencies responsible for copied facts.
Normalization supports this separation, but an ERD is not a complete proof that every table satisfies a particular normal form. Examine additional dependencies within the resulting tables. Also distinguish an accidental stale copy from an intentional historical fact, such as the price agreed on an order rather than a product's current list price.
Lesson 12 distinguishes “every order has a customer” from “every customer has an order.” The first is enforced in Orders with a required reference to Customers. The second would be an additional minimum-child rule, which that foreign key does not enforce.
A required parent reference needs both NOT NULL and a foreign key to a unique parent key. NOT NULL alone accepts an identifier that has no matching parent. A nullable foreign key permits an absent reference while checking supplied values. Constraint enforcement must actually be enabled for the implementation to preserve those rules.
Lesson 13 shows two optional patterns. Ben's Employee row can have NULL DepartmentID when assignment is optional. Support can have no Employee rows independently of that choice. In Student–Course, Leo's lack of enrollment is represented by no Enrollment rows; an existing enrollment still requires both parent keys.
A foreign key therefore cannot guarantee that every active student is enrolled or that every submitted order has a line. Define when such minimums must hold, including draft and active states. Enforce the relevant transitions and subsequent edits transactionally, accounting for concurrent changes. Periodic checks can detect violations but do not prevent them.
Mandatory participation does not automatically make an entity weak. In classical ER modeling, a weak entity depends on its owner's key for identification. OrderLine identified by (OrderID, LineNo) is an example: LineNo distinguishes lines within an order. An Order with an independent OrderID can require a customer without using the customer's key as part of its identity.
Deletion policy is another separate decision. A restrictive foreign key protects references by rejecting deletion of a parent whose children remain. Cascading deletion removes dependent rows when the parent is deleted. SET NULL clears an optional reference where supported and allowed. It conflicts with a required NOT NULL reference.
Choose policies according to retention and lifecycle requirements. Deleting an enrollment normally should not delete its Student or Class parents. Keeping order history may require deactivating a customer or preserving an appropriate record. The presence of a cascade is not the definition of a weak entity or a prerequisite for preventing orphans.
The module's updated diagrams use numeric multiplicities to make rules explicit. A label near an entity describes how many instances of that entity can relate to one instance at the opposite end. In Customer–Order, 1 near Customer means one customer per order; 0..many near Order means zero or many orders per customer.
Chen, Crow's Foot and IDEF1X have different conventions. Read each diagram's legend and both endpoint symbols. Crow's Foot uses symbols for minimum and maximum participation; a bar or circle considered alone does not supply the whole rule. IDEF1X should not be treated as another name for Crow's Foot.
Relationship degree is also distinct from cardinality. A ternary relationship involves three entity roles. It cannot always be replaced by independent binary associations without changing which combinations are permitted. Understand the business meaning of the complete association before simplifying its diagram.
Use a short sequence that connects requirements, diagram and implementation:
For Person–Passport, try a second passport for the same person. For Customer–Order, accept a second order but reject a missing customer. For Enrollment, accept the same student with another class and reject the same pair twice. For optional Department–Employee, accept an unassigned employee while rejecting a supplied nonexistent department.
Finally, inspect representative queries. LEFT JOIN can include an unassigned employee or empty department; an INNER JOIN omits unmatched instances. Count a non-null child key to obtain zero for an empty parent. Review indexes and query plans for the actual engine rather than assuming every foreign key creates a child index automatically.
You should now be able to explain a relationship's meaning, distinguish its maximum cardinalities from its minimum participation, choose a suitable association key, and identify the constraints needed to preserve its rules. You should also recognize when history, capacities or mandatory parent participation require additional design.
Return to the module introduction for the vocabulary or revisit the linked lessons for diagrams and executable examples. When presenting a model to a colleague, read its relationship sentences aloud and demonstrate one permitted and one rejected boundary case. That makes the design easier to review than symbols alone.
Before moving to the next module, complete the Entity Relationships quiz. Explain the rule behind each answer, especially which viewpoint determines optionality.
Continue to Module 7: Entity Diagram Conventions to express these rules consistently in readable diagrams.