1Applying ER Modeling to a Problem Domain
▶
Entity-Relationship (ER) modeling is the bridge between a real-world problem domain and a structured database design. When given a business scenario — a description of a company's operations, a university's registration system, a hospital's patient records, or any other domain — a database designer must systematically analyze that description, extract the relevant data elements, and translate them into a formal ER diagram. This process is not mechanical; it demands careful reading, critical judgment, and iterative refinement. The sections below walk through each stage of this process in depth, from reading requirements to drawing and validating the finished diagram.
Analyzing Business Requirements
Every ER model begins with a written or spoken description of what the business needs to track. Before touching a drawing tool or writing a single entity name, the designer must deeply understand this narrative. The goal of requirements analysis is to extract every meaningful data element and every business rule embedded in the description.
A practical first technique is to underline or highlight every noun in the requirement text. Nouns and noun phrases name things — people, places, objects, events, and concepts — and they are the raw material from which entities and attributes emerge. Consider a simple business description:
"A university tracks its students, who enroll in courses offered by departments. Each course has a course number, a title, and a credit value. Instructors, who belong to departments, teach courses. A student receives a grade for each course they complete."
Underlining the nouns yields: university, students, courses, departments, course number, title, credit value, instructors, grade. This list is not yet a finished set of entities and attributes — it is a starting inventory for analysis.
Equally important is to examine the verbs and action phrases. Verbs describe what entities do to or with each other, and they reveal relationships. In the example above: enroll in, offered by, belong to, teach, receives. Each verb is a candidate relationship name. "Students enroll in courses" suggests an ENROLLMENT relationship between STUDENT and COURSE. "Instructors teach courses" suggests a TEACHES relationship between INSTRUCTOR and COURSE.
As you gather nouns and verbs, you must distinguish between objects themselves and data that merely describes those objects. An entity is a thing that warrants its own table and can have multiple instances; an attribute is a property or characteristic of an entity. "Course number" and "title" describe a course — they are attributes. "Course" is the object being described — it is an entity. Getting this distinction right early prevents structural mistakes later.
Finally, re-read the requirements multiple times. The first reading gives a general picture; subsequent readings reveal constraints, edge cases, and implied rules that are easy to miss. A phrase like "each instructor belongs to exactly one department" encodes a cardinality rule. A phrase like "a student may have no advisor" encodes a participation constraint. These details are as important as the main entities themselves and must be captured before modeling begins.
Identifying Entities from a Problem Domain
Once the nouns list is assembled, the next task is to promote the right nouns to full entity status. An entity represents a category or class of things — not a single specific instance. "Student" is an entity; "John Smith" is a particular student, an instance of that entity. This distinction keeps the model general and reusable.
For something to qualify as an entity, it should:
- Represent multiple instances of the same kind of object (e.g., many students, many courses).
- Have several meaningful attributes that describe it (a student has a student ID, name, date of birth, major, etc.).
- Have at least one attribute (or combination of attributes) that can serve as a primary key — a unique identifier for every instance.
A critical category to recognize early is the weak entity. A weak entity cannot be uniquely identified by its own attributes alone; it depends on a related owner or parent entity for identification. For example, in a company database, a DEPENDENT (family member of an employee) typically has a name and relationship type, but the name "Alice" might belong to multiple employees' dependents. Alice's identity only makes sense relative to a specific EMPLOYEE. DEPENDENT is therefore a weak entity; EMPLOYEE is its identifying (strong) entity. The relationship between them is an identifying relationship, usually shown with a double diamond in Chen notation. Weak entities are represented with a double rectangle.
Knowing when not to create an entity is equally important. If a noun from the requirements has only one or two properties and always belongs to exactly one other object, it is usually better modeled as an attribute. "Phone number" for a person is typically an attribute (or, if a person can have multiple numbers, a multi-valued attribute), not a separate entity — unless you need to track the type, provider, or history of each phone number, in which case promotion to an entity becomes justified.
Determining Attributes for Each Entity
After identifying the entities, every entity must be equipped with the right set of attributes. This step requires both completeness (capturing everything the business needs) and discipline (avoiding redundancy and misplacement).
The first task within this step is selecting the primary key. A good primary key is:
- Unique — no two instances share the same key value.
- Stable — its value rarely or never changes (avoid using a person's name or email, which can change).
- Minimal — it uses as few attributes as necessary. A single-attribute key (StudentID, OrderNumber) is preferred over a composite key when feasible.
- Non-null — every instance must have a key value; nulls are forbidden in primary keys.
Natural keys (meaningful identifiers already present in the domain, like a government-issued ID number) are preferable when they meet all four criteria. Surrogate keys (system-generated numbers like auto-increment integers) are used when no reliable natural key exists.
Attributes come in several varieties that the ER model distinguishes explicitly:
- Simple (atomic) attributes cannot be divided further. StudentID, CreditHours, and GradePointAverage are examples.
- Composite attributes can be broken into sub-parts. FullName might be decomposed into FirstName, MiddleName, and LastName. If the application ever needs to search or sort by last name alone, storing the composite decomposition is the right choice. If the name is always used as a unit, storing it as a simple attribute may suffice.
- Multi-valued attributes hold more than one value per entity instance. A STUDENT might have multiple PhoneNumbers or multiple Hobbies. In Chen notation, multi-valued attributes are shown with a double oval. In relational implementation, they require a separate table.
- Derived attributes can be computed from other stored attributes. Age can be derived from DateOfBirth and the current date; TotalOrderCost can be derived by summing line items. In Chen notation, derived attributes are shown with a dashed oval. The general rule is not to store derived values unless recalculating them is too expensive at query time.
Careful placement of attributes prevents data duplication. An attribute belongs to the entity it directly describes. If you find yourself copying the same attribute to multiple entities (e.g., putting DepartmentName on both the INSTRUCTOR and COURSE entities), that is a sign the attribute should live on a DEPARTMENT entity and be accessed through relationships. Redundant storage of the same fact in multiple places leads to update anomalies — the classic problem that normalization later addresses.
Identifying and Defining Relationships
Relationships capture the associations among entities. Every relationship in an ER diagram should be grounded in a concrete business rule from the requirements.
Each relationship should be given a meaningful name — typically a verb or verb phrase written on or beside the relationship line or diamond. Good names make diagrams self-documenting. "STUDENT enrolls in COURSE" is immediately understandable; a relationship labeled only "R1" forces the reader to consult external documentation. The name should ideally read sensibly in both directions: "A student enrolls in a course" and "A course is enrolled in by students."
Relationships are classified by degree — the number of entities they connect:
- Unary (recursive) relationships connect an entity to itself. An EMPLOYEE entity might have a manages relationship where some employees manage other employees.
- Binary relationships connect exactly two entities and are by far the most common type. Most relationships in typical business systems are binary.
- Ternary relationships connect three entities simultaneously. A classic example: a SUPPLIER supplies a PART to a PROJECT. A ternary relationship is used when the association among all three cannot be decomposed into binary relationships without losing information — for example, when the combination of supplier, part, and project together determines the quantity supplied, and that quantity cannot be attributed to any pair alone.
Sometimes a relationship itself carries data. A relationship attribute is an attribute that belongs to the relationship, not to either participating entity. In the ENROLLMENT relationship between STUDENT and COURSE, the Grade a student earns makes sense only in the context of a specific student in a specific course — it is not an attribute of the student alone, nor of the course alone. It is a relationship attribute of ENROLLMENT. In Chen notation it appears as an oval connected to the relationship diamond.
When a relationship accumulates several attributes, or when it participates in other relationships, it should be promoted to an associative entity (also called a composite or bridge entity). ENROLLMENT with attributes Grade, EnrollmentDate, and SectionNumber is better modeled as an ENROLLMENT entity than as a relationship with many attributes hanging off it. Promotion to an entity allows the associative entity to have its own primary key and to participate in further relationships — for example, ENROLLMENT might relate to TEXTBOOK to record which books a student needs for that enrolled section.
Establishing Cardinality and Participation Constraints
Constraints are what give an ER diagram its precision. Without them, a diagram merely names entities and relationships; constraints encode the actual business rules that govern how data can exist.
Cardinality ratios describe how many instances of one entity can relate to how many instances of another:
| Cardinality Type | Notation | Meaning | Example |
|---|---|---|---|
| One-to-One (1:1) | 1 — 1 | Each instance of A relates to at most one instance of B, and vice versa. | An EMPLOYEE manages at most one DEPARTMENT; a DEPARTMENT is managed by at most one EMPLOYEE. |
| One-to-Many (1:N) | 1 — N | Each instance of A relates to many instances of B; each instance of B relates to at most one A. | A DEPARTMENT employs many EMPLOYEEs; each EMPLOYEE belongs to one DEPARTMENT. |
| Many-to-Many (M:N) | M — N | Each instance of A relates to many instances of B, and each B relates to many As. | A STUDENT enrolls in many COURSEs; a COURSE is enrolled in by many STUDENTs. |
Cardinality ratios must be derived from business rules, not assumed. Ask: "Can a department have only one employee?" If the answer is no, the relationship is 1:N or M:N, not 1:1. The requirements text or a subject-matter expert must confirm every ratio.
Participation constraints specify whether every instance of an entity must participate in a relationship:
- Total (mandatory) participation: Every instance of the entity must be associated with at least one instance of the related entity. Represented in Chen notation by a double line. Example: "Every employee must belong to a department" — EMPLOYEE has total participation in the BELONGS_TO relationship.
- Partial (optional) participation: Some instances may not participate. Represented by a single line. Example: "Not every employee manages a department" — EMPLOYEE has partial participation in the MANAGES relationship.
Tracking the source business rule beside each constraint decision is professional practice and supports traceability. When a stakeholder later asks why COURSE has total participation in the OFFERED_BY relationship with DEPARTMENT, you can point directly to the requirement that stated "every course must belong to a department."
Many-to-many relationships deserve a special flag during ER modeling because they cannot be directly implemented in a relational database. They require a bridge (junction) table during physical design. Identifying them early gives the team time to think about what attributes the bridge table will carry and whether it warrants promotion to an associative entity in the ER diagram itself.
Drawing the Complete ER Diagram
With entities, attributes, relationships, and constraints defined, the designer assembles the complete ER diagram. The two most common notations are Chen notation (rectangles for entities, diamonds for relationships, ovals for attributes) and Crow's Foot notation (rectangles for entities, lines with crow's foot symbols for cardinality). Most academic courses use Chen notation; many industry tools default to Crow's Foot or UML-style diagrams. The principles are the same regardless of notation.
Layout guidelines for a clear, readable diagram:
- Place entities as the primary nodes. Arrange them so that the most frequently connected entities are near the center, with peripheral entities around the edges. Avoid crossing relationship lines where possible.
- Attach all attributes to their respective entities or relationships. In Chen notation, draw ovals from the entity rectangle with short lines. Underline the primary key attribute(s) to make them immediately visible. Use a double oval for multi-valued attributes and a dashed oval for derived attributes.
- For weak entities, draw a double rectangle and connect them to their identifying entity with a double diamond (Chen) or an appropriate dependency marker (Crow's Foot).
- Place cardinality and participation symbols on both ends of every relationship line. In Chen notation, write the ratio values (1, N, M) beside the lines and use double or single lines for total/partial participation. In Crow's Foot notation, the crow's foot (many) and single bar (one) at each end encode both cardinality and minimum participation.
- Verify completeness: every entity from the requirements has a corresponding rectangle; every relationship has a name and correct cardinality; every attribute is attached and every primary key is underlined.
Consider the following partial structural summary for the university example used throughout this discussion:
| Entity | Primary Key | Notable Attributes | Relationships |
|---|---|---|---|
| STUDENT | StudentID | FirstName, LastName, DateOfBirth, Major | ENROLLS_IN (COURSE), ADVISED_BY (INSTRUCTOR) |
| COURSE | CourseNumber | Title, CreditHours | ENROLLS_IN (STUDENT), OFFERED_BY (DEPARTMENT), TAUGHT_BY (INSTRUCTOR) |
| INSTRUCTOR | InstructorID | FirstName, LastName, HireDate, Rank | BELONGS_TO (DEPARTMENT), TAUGHT_BY (COURSE), ADVISED_BY (STUDENT) |
| DEPARTMENT | DeptCode | DeptName, Location, Phone | OFFERED_BY (COURSE), BELONGS_TO (INSTRUCTOR) |
| ENROLLMENT (associative) | StudentID + CourseNumber (composite) | Grade, EnrollmentDate, Semester | Promotes the M:N ENROLLS_IN relationship |
Validating and Refining the ER Model
A first-draft ER diagram is rarely correct or complete. Validation is the process of stress-testing the model against real scenarios and the original requirements before committing to physical implementation.
The most effective validation technique is to walk through sample data scenarios. Imagine actual data rows and ask: "Can the model store this?" For example:
- Can I record that student #10045 (Maria Gonzalez) enrolled in CS301 in Fall 2024 and received a grade of B+? — Yes: the ENROLLMENT associative entity accommodates this with StudentID, CourseNumber, Semester, and Grade attributes.
- Can I record a student who has not yet enrolled in any course? — Only if STUDENT has partial participation in ENROLLMENT. If the requirement says every student must be enrolled, total participation applies.
- Can I record a course that no one has enrolled in yet (a newly created course)? — Check the participation constraint on COURSE in the ENROLLMENT relationship.
Check the diagram for redundant relationships. If STUDENT is connected to DEPARTMENT both through COURSE (via ENROLLMENT and OFFERED_BY) and through a direct STUDIES_IN relationship, ask whether that direct relationship adds any information not already inferable from the chain. If not, it is redundant and should be removed to keep the model clean.
Confirm that every business rule stated in the requirements is enforced by something visible in the diagram. Rules often fall into one of two categories:
- Structural rules expressed through cardinality and participation (e.g., "an instructor must belong to exactly one department" → total participation, 1:N).
- Domain rules that may need to be enforced at the application or database constraint level rather than through the ER diagram itself (e.g., "a student's GPA cannot exceed 4.0"). Note these rules even if they cannot be fully diagrammed — they will become CHECK constraints or trigger logic during physical implementation.
Finally, solicit feedback from stakeholders. Bring the ER diagram to the business analysts, department managers, or subject-matter experts who provided the original requirements. Walk through the diagram with them and ask whether every entity, relationship, and constraint reflects how their business actually works. Misinterpretations caught at the ER stage are cheap to fix — a renamed entity or adjusted cardinality takes minutes. The same misinterpretation caught after the database is built, populated, and integrated with applications is extremely costly. This review loop is not a sign of weakness; it is a sign of professional rigor.
The entire ER modeling process — from reading requirements to validating the finished diagram — is inherently iterative. Requirements change, stakeholders clarify ambiguous statements, and new business rules surface during review. A well-practiced designer embraces this iteration and builds a model that faithfully represents the problem domain, is internally consistent, and is ready to be translated into a relational schema.