- Learn
- Computer Science & IT
- Programming
- Database Design and Advanced SQL
- Entity-Relationship Modeling
Entity-Relationship Modeling
IntermediateLesson 3 of 8 in Database Design and Advanced SQL Course
What you will learn
- Turn a written description of an organization's data into entity types with well-chosen attributes and keys, as the first step of conceptual database design.
- Find the entities in a set of requirementsPlace ER modeling in the database design process, tell entity types from their instances, and pick out the things a database must keep data about.
- Describe entities with attributes and keysChoose the right kind of attribute for each fact, allow for missing values, and give every strong entity type a key that identifies its instances.
- Find the entities in a set of requirements
- Connect entity types with relationships, state how many instances can take part on each side, and choose between the different ways to model the same facts.
- Describe relationships, their degree and rolesName relationships between entity types, recognize binary, ternary and recursive relationships, and decide which facts belong to a relationship rather than to an entity.
- State cardinality and participationTurn business rules into cardinality ratios and participation constraints, and express both together as minimum and maximum counts for each side of a relationship.
- Choose between modeling alternativesDecide whether a fact is best modeled as an attribute, an entity or a relationship, place relationship attributes correctly, and turn a relationship into an entity when the requirements call for it.
- Describe relationships, their degree and roles
- Draw a model in Chen notation and in crow's foot notation, read the cardinality and participation in each, and convert a diagram from one notation to the other.
- Draw and read Chen notationUse rectangles, diamonds and ovals to show entity types, relationships and attributes, and read the cardinality and participation marks on the lines.
- Draw and read crow's foot diagramsRead and draw entity boxes and relationship lines with crow's foot end marks, resolve many-to-many and ternary relationships with associative entities, and convert a Chen diagram into crow's foot form.
- Draw and read Chen notation
- Model entities that are identified through an owner, and organize entity types into superclasses and subclasses with the right constraints.
- Model weak entity typesRecognize entity types that cannot be identified on their own, link them to their owner through an identifying relationship, and choose their partial key.
- Build specialization and generalization hierarchiesSplit an entity type into subclasses or combine similar entity types under a superclass, decide what each level inherits, and recognize when a subclass is worth adding.
- Apply constraints on specializationState whether subclasses may overlap and whether every superclass instance must belong to one, and check sample instances against these constraints.
- Model weak entity types
- Translate entity types, relationships, weak entity types and hierarchies into tables with primary keys, foreign keys and constraints that keep the model's rules.
- Map entity types and their attributesTurn each strong entity type into a table, and map composite, multivalued and derived attributes into columns, extra tables or queries.
- Map one-to-many and one-to-one relationshipsPlace foreign keys on the correct side, turn participation into NULL and NOT NULL rules, and choose among the options for one-to-one and recursive relationships.
- Map many-to-many relationships and weak entity typesBuild tables whose primary keys combine foreign keys: junction tables for many-to-many and higher-degree relationships, and tables for weak entity types.
- Map specialization and generalizationCompare the four standard ways to store a superclass and its subclasses in tables, and choose one that fits the hierarchy's constraints and use.
- Map entity types and their attributes
- Carry a realistic case from written requirements to a diagram and a set of tables, and review the result for missing facts, traps and rules that need extra constraints.
- Go from requirements to a schemaApply every step to one case: find the entity types and keys, add the relationships with their constraints, recognize the weak entity type, and map the model to tables.
- Review a model for traps and qualityCheck a model against its requirements with a checklist and sample data, find fan traps and chasm traps, and record the rules the diagram cannot show.
- Go from requirements to a schema
Entity-Relationship Modeling study guide
1Entities, attributes, and keys
A database design starts with the things an organization needs to remember. Before choosing columns or writing SQL, you need clear names for those things, the facts that describe them, and rules that distinguish one instance from another. A training center provides a small example: courses, trainers, and participants each need an identity, while a score describes a particular enrollment. These choices give the rest of the model a dependable base.
1.1 Finding the things to model
A useful entity-relationship model starts with requirements: what must the organization remember, and what questions must the data answer? Read for meaning before drawing boxes. A noun is a clue, not a decision.
Where the ER model fits
Design usually moves through requirements, conceptual design, logical design, and physical design. Requirements describe the needed facts and rules. Conceptual design organizes those facts as entities, attributes, and relationships. Logical design turns that model into tables and constraints. Physical design chooses storage details such as indexes.
At the conceptual stage, you can discuss a student's identity without choosing an integer column, or a course's participants without deciding how to join tables. This keeps the conversation focused on the domain while its meaning is still being settled.
Types and instances
An entity is something distinguishable about which data is kept. It might be a person, an object, an event, or a concept. An entity type is the category, such as Student. An instance is one particular student, such as Amira Haddad, student number 20417. Some books use “entity set” for the category.
Use singular names: Student, Course, and Department. Mathematics Department and History Department are instances of Department, not separate types. Keep a name's meaning consistent; if Customer can mean either a person or an organization, settle how those cases are represented.
Work through the requirements
Consider: “A training center runs courses. Each course has a code, a title, and credits. Trainers teach courses. Participants enroll and receive a score.”
- Mark the nouns and noun phrases: training center, course, code, title, credits, trainer, participant, and score.
- Merge any synonyms. “Learner” and “participant” might describe the same type.
- Separate things from their properties. Course is a type; code, title, and credits describe it. Trainer and Participant also have identities and facts of their own.
- Locate facts about links. A score describes a participant's enrollment in one course.
The training center itself needs a type if its address, branches, or relationships must be recorded. A type can have just one instance. The question is whether the database needs facts about it, not whether many examples already exist.
Let the required facts guide the choice
A department name can be an Employee attribute when the name is all that matters. If each department also has a budget and a manager, give Department its own type. The department now has facts and relationships that should be recorded once and linked to employees.
A screen or report usually presents stored facts. A monthly sales report produced from Sale and Product data does not need a separate entity type merely because a user opens it. If the business stores individual issued reports as records with their own identifiers and dates, those are a different requirement.
Finally, turn gaps into concrete questions. “Trainers teach courses” leaves open whether a course can have several trainers. Ask whether two trainers may share one course and whether an unassigned course may exist. Those answers determine the relationships later.
Key Takeaways
- An entity type names a category; an instance is one member of it.
- Conceptual design describes data and links before logical design chooses tables.
- Choose entity types from the facts and relationships the organization needs to keep.
- Use singular, consistent names and resolve unclear requirements with domain experts.
1.2 Attributes and reliable identifiers
Once the entity types are clear, decide which facts describe each one. An attribute takes values from a domain: dates for date of birth, whole numbers from 1 to 30 for credits, or text up to 100 characters for a course title. The domain describes valid values, not just the values currently in the database.
Choose the attribute's form
A simple attribute is treated as one value. A composite attribute has useful parts. Address can contain street, postal code, and city; separate the parts when users need them separately, such as finding members in one city.
A single-valued attribute has one value per instance. A multivalued attribute allows several, such as a member's mobile and work phone numbers. Fixed fields named phone1, phone2, and phone3 impose an arbitrary limit and leave empty slots. Model the set of phone numbers directly; its table mapping will allow one row per value.
Stored facts are entered directly. Derived attributes are calculated from other facts. Date of birth is stored; age depends on it and today's date. A person born on 2000-03-15 is 26 on 2026-10-29. Counting enrollments gives a course's participant count. Storing a current age without updating it would make it stale.
A missing or inapplicable value becomes NULL in the table design. A member might have no middle name, or a return date might be unknown because a loan is still open. When an entire group needs different attributes, such as hourly staff needing an hourly rate, consider a subclass.
Identify each instance
A key is an attribute or group of attributes that uniquely identifies an instance. A candidate key is minimal: removing any part loses uniqueness. If student number alone is unique, the pair of student number and last name is unique too, but it is not minimal. Choose one candidate as the primary key; preserve the others as alternate candidate keys.
A composite key needs several attributes together. A scheduled flight can use flight number and date: AB 123 runs on many dates, and many flights run on 2026-11-02, but the pair identifies the scheduled flight in this model.
| Key choice | Meaning | Design concern |
|---|---|---|
| Natural key | Comes from the domain, such as an ISBN | Check uniqueness, presence, and stability |
| Surrogate key | Generated solely for identification, such as member_id | Keep any domain uniqueness rules separately |
An email address is a candidate key only when every instance must have one and no two may share it. Household members may share an address, and addresses can change. A person's name is also a poor identifier because different people can have the same name.
Test the rule, not just the sample
Suppose ten members currently have different names. That sample fits a unique-name constraint, but a later member could have an existing name. A candidate key must distinguish every allowed instance, including future ones. Establish uniqueness from the business rules, then test whether the proposed key has any unnecessary parts. Favor a primary key that stays stable when descriptive facts change.
Key Takeaways
- An attribute domain states which values are valid.
- Composite attributes have useful parts; multivalued attributes have several values per instance.
- Derive current values such as age from stored facts when they are needed.
- A candidate key is unique and minimal; one candidate becomes the primary key.
- A surrogate identifier does not replace a separate business uniqueness rule.
- Choose keys from the domain rules, not from a small sample.
2Relationships and business rules
Knowing the entity types is only the beginning: a design must also say which instances are connected. A relationship can carry its own facts, limit how many partners each instance has, and require or allow participation. Work from sentences about the domain, including whether the database keeps history. Then choose a representation that can preserve each required link, especially when an event repeats or a fact needs three participants together.
2.1 Links, roles, and relationship facts
A relationship type describes an association, such as “Participant enrolls in Course.” A relationship instance links particular entities: Amira and Databases. Use a verb phrase for the name so that the connection reads as a meaningful sentence.
How many participants does the fact need?
The degree describes the relationship's structure. A binary relationship links two entity types, such as Trainer and Course. A ternary relationship links three. A recursive relationship links an entity type to itself.
In “Employee supervises Employee,” the two occurrences have different roles: supervisor and supervisee. A role tells you which job an instance plays in that relationship. Draw both connections to the same Employee type and label the roles. Do not create separate Supervisor and Supervisee types merely to show the two positions.
The same entity types can have several relationships. Employee “works in” Department and Employee “manages” Department record different facts. Knowing where an employee works does not identify the department they manage unless a separate rule connects those facts.
Put facts on the right link
A relationship can have attributes. Amira scores 85 in Databases and 70 in Statistics. The score is not a fact about Amira alone because it changes with the course. It is not a fact about Databases alone because different participants receive different scores. It belongs to the enrollment link.
A useful test is to hold one participant fixed and change the other. If the fact can change, the first entity alone does not determine it. Repeat the test in the opposite direction. In a many-to-many enrollment relationship, the participant–course pair identifies the score.
Keep three-way facts together
Consider “Supplier supplies Part to Project.” The instance linking Northline, M8 bolt, and Bridge Renewal carries quantity 400. All three are needed to identify what the quantity describes.
Replacing this with three pairwise relationships loses the complete fact. The pairwise data might say:
- Northline supplies M8 bolts to some project.
- Northline supplies some part to Bridge Renewal.
- Bridge Renewal uses M8 bolts.
Those statements leave open whether Northline supplied the bolts used in Bridge Renewal. A different supplier could have supplied them, while Northline supplied another part to that project. A ternary Supply relationship preserves the actual triple.
Use binary relationships when the pairs are independent facts. Use a ternary relationship when the requirement needs one joint fact about all three. Counting nouns in a sentence cannot decide this: the meaning of the stored association does.
Separate stored links from activities
“The manager prints the attendance report” describes a workflow. It requires a relationship only if the database must remember which manager printed which report. A relationship line commits the model to storing an association, so add it for a required data fact, not every action mentioned during an interview.
Key Takeaways
- Relationship names describe stored associations with verb phrases.
- Role names distinguish the participants in a recursive relationship.
- A relationship attribute describes the link, such as a score for one enrollment.
- A ternary fact can lose information when replaced by independent pairs.
2.2 Minimum and maximum participation
For each relationship, ask two questions in both directions: how many partners can one instance have at most, and how many must it have at least? Keeping the questions separate prevents “one” from silently becoming “exactly one.”
Find the maximum in both directions
For one Department, how many Employees are allowed? Many. For one Employee, how many Departments are allowed? One. The maximum ratio is 1:N from Department to Employee.
If both answers are one, the ratio is 1:1. If both are many, it is M:N. Participant–Course enrollment is M:N when a participant can enroll in several courses and each course can have several participants. An Employee–Department management link is 1:1 when each department has one manager and each employee manages at most one department.
These are rules about allowed database states. A department with one employee today can still belong to a 1:N relationship. Empty departments and departments with many employees must also be considered if the rules permit them.
Add the minimum
Total participation means every instance must take part at least once. Partial participation means an instance may have no link. If every employee must belong to a department, Employee participates totally. If a department can be created before employees are assigned, Department participates partially.
Combine the two questions in a (minimum, maximum) pair:
| Starting instance | Number of partners | Pair for that instance |
|---|---|---|
| One Employee | Exactly one Department | (1, 1) |
| One Department | Zero or many Employees | (0, N) |
Here each pair describes the participation of the named starting instance. A minimum can exceed one: “Every project needs at least two members” has minimum 2. Basic notation marks for zero and one need a written rule for that larger minimum.
Work through loans
A library keeps loan history. Each Loan belongs to exactly one Member and concerns exactly one Copy. A Member can have zero or many Loans over time; a Copy can also have zero or many Loans over time. Thus the two relationships are Member 1:N Loan and Copy 1:N Loan, with total participation for Loan in each.
The copy may be on at most one open loan now while having many past loans. These statements concern different time scopes. A current-state model and a history model can need different relationships and identifiers.
Check rules with evidence
Sample data can expose a violation: an employee recorded in two departments contradicts a maximum of one. A sample in which everyone has one department leaves open whether the business would permit two. Confirm the allowed maximum with someone who knows the domain.
The maximum later helps choose the table structure: a foreign key can record one partner, while many-to-many links need a junction table. The minimum helps choose whether a foreign key can be NULL. A rule requiring every parent to have a child needs a further check; filling each child's foreign key does not create a child for every parent.
Key Takeaways
- Ask minimum and maximum questions in both directions.
- Cardinality ratios describe allowed maxima, not current row counts.
- Total participation requires a link; partial participation permits none.
- A pair beside a starting entity can state its own minimum and maximum participation.
- Choose the time scope before deciding how many partners are possible.
2.3 Choosing a representation that keeps the facts
An attribute, a relationship, and an entity type can sometimes represent similar information. Choose by asking what must have its own identity, details, or connections. The best choice lets every required fact be recorded without duplicating its meaning.
When a property needs its own entity
A member's phone numbers can be a multivalued attribute. If each number also needs a type, such as mobile or work, and permission to receive text messages, a Phone entity makes those details easier to attach. A simple department name can stay an attribute until the database needs Department's own budget, manager, or independent list of departments.
The number of words in the name does not decide the choice. The data the organization needs about the concept does. Give it an entity type when it has facts or relationships of its own.
When a link becomes an entity
A basic “Employee works in Department” relationship identifies which instances are linked. An associative entity gives a link its own box and attributes. Enrollment can connect Participant to Course and hold score. It replaces one M:N connection with two 1:N connections: each enrollment belongs to one participant and one course.
An event also needs its own identity when the same participants can be linked repeatedly. A member can borrow the same copy, return it, and borrow it again. A simple Member–Copy pair records only one link for that pair. Give each Loan a loan_id, or choose an event identifier that includes an appropriate date or occurrence value. The dates then describe one specific loan.
Put an attribute where its value is determined
For a current 1:N “works in” relationship, each Employee has at most one Department. The start date of that assignment can sit with Employee because each employee has only one current link. If the model starts keeping assignment history, several start dates may be needed; the event records then need separate identities.
An enrollment score cannot move into Participant, because one participant has a different score in each course. It also cannot move into Course, because each course has many participants with their own scores. Keep it on Enrollment or on the M:N relationship.
Avoid recording the same connection twice
In a conceptual model, the “works in” relationship already records Employee's Department. Adding department_id as an ordinary Employee attribute repeats that association. The attribute and the line could disagree. During logical mapping, the relationship becomes the foreign key; that is the point at which department_id belongs in the table.
Relationships can also duplicate each other. If every Course belongs to one Department and every Department belongs to one Faculty, the course's faculty follows from that chain. A direct Course–Faculty link adds nothing unless the business allows a course's faculty to differ. When two routes appear to answer the same question, check whether they really describe the same fact before keeping both.
Key Takeaways
- Promote a property to an entity when it needs its own details or relationships.
- An associative entity gives a relationship a place for its attributes and further links.
- Repeated events need an identifier that distinguishes occurrences.
- A conceptual relationship becomes a foreign key during logical mapping; avoid drawing the same link twice.
3Reading and drawing ER diagrams
A diagram carries business rules through its shapes and marks. Chen notation makes entities, relationships, and attributes visually distinct; crow’s foot notation puts attributes inside boxes and combines minimum and maximum marks at line ends. You will read the same rules in both styles and convert between them. Pay special attention to where a mark belongs: a mark beside one box can describe the partners reached from the other box.
3.1 Chen shapes and constraint marks
Chen notation, introduced by Peter Chen in 1976, gives each kind of concept a distinct shape. Entity types are rectangles, relationships are diamonds, and attributes are ovals. Lines connect attributes to their entity or relationship and connect each relationship diamond to its participating types.
Read the attributes
An underlined attribute name marks a key. A composite attribute has ovals for its parts attached to its oval. A double oval marks a multivalued attribute; a dashed oval marks a derived attribute. An attribute belonging to a relationship attaches to the diamond.
For example, put trainer_id, name, and email in ovals attached to TRAINER, with trainer_id underlined. COURSE has code, title, and credits, with code underlined. PARTICIPANT and COURSE connect to ENROLLS; score hangs from that diamond because it describes an enrollment.
Ratio labels are read across the relationship
The schematic below names the shapes: uppercase names in square boxes represent rectangles, and the diamond marks the relationship.
[DEPARTMENT] --1-- <EMPLOYS> --N-- [EMPLOYEE]
The N beside EMPLOYEE means that one department can employ many employees. The 1 beside DEPARTMENT means that one employee works in at most one department. These labels describe maximum cardinality; they leave the minima to participation marks.
A double line between EMPLOYEE and EMPLOYS means total participation: every employee must have a department. A single line between DEPARTMENT and EMPLOYS allows a department with no employees. Double lines concern the entity at that end, so read participation separately from the ratio labels.
Minimum–maximum pairs use another direction
A different Chen style replaces ratio labels and participation lines with pairs:
[EMPLOYEE] --(1, 1)-- <EMPLOYS> --(0, N)-- [DEPARTMENT]
Here the pair beside EMPLOYEE states how many EMPLOYS instances each employee participates in: exactly one. The pair beside DEPARTMENT states how many each department participates in: zero or many. Some diagrams write 1..1 and 0..*.
The many-valued ratio label sits beside EMPLOYEE, but the many-valued participation pair sits beside DEPARTMENT. That reversal is a frequent reading error. Establish the diagram's convention before interpreting any marks; do not combine the two styles as if their labels had the same direction.
Arrows and recursive links
Some textbooks show maximum one with an arrowhead pointing toward an entity type. An arrow from EMPLOYS to DEPARTMENT means each employee has at most one department. A plain line allows many. The arrow alone does not require participation.
A recursive relationship has two lines from one diamond to the same rectangle. Label them with roles such as supervisor and supervisee so that “Employee supervises Employee” has a clear direction.
To build the training example, connect TRAINER to COURSE through TEACHES with 1 beside TRAINER and N beside COURSE. Draw COURSE's participation line double when every course needs a trainer. Then add the M:N ENROLLS relationship and its score oval. Each symbol now represents a separate fact about the model.
Key Takeaways
- Chen uses rectangles for entity types, diamonds for relationships, and ovals for attributes.
- A key is underlined; multivalued and derived attributes use double and dashed ovals.
- Ratio labels are read across the relationship; a participation pair describes the adjacent entity’s own links.
- A double participation line requires every instance at that end to take part.
- An arrow toward an entity type means at most one partner of that type.
- Label the roles on recursive relationship lines.
3.2 Crow’s foot end marks and conversion
Crow's foot notation, also called Information Engineering notation, draws each entity type as a box with its attributes inside. A labeled line represents a relationship. Logical diagrams commonly mark primary keys with PK and foreign keys with FK.
Read the far end
Each line end has two marks. The mark closest to the box gives the maximum: a bar means one and a three-pronged crow's foot means many. The farther mark gives the minimum: a circle means zero and a bar means one.
| End marks | Number of partners |
|---|---|
| Circle and bar | Zero or one |
| Two bars | Exactly one |
| Circle and crow's foot | Zero or many |
| Bar and crow's foot | One or many |
Start at one box and read the marks at the other box. On a Department–Employee line, two bars beside Department mean that each employee has exactly one department. A circle and crow's foot beside Employee mean that each department has zero or many employees.
The marks beside Employee therefore describe how many employees a department can reach. Reading them as Employee's own participation reverses the rule. Say both complete sentences aloud while checking a diagram.
Turn a relationship into a box when needed
A conceptual M:N relationship can have crow's feet at both ends. A logical model resolves it into an associative entity. Enrollment holds the score and links to Participant and Course. Each Enrollment reaches exactly one Participant and exactly one Course; either participant type may reach many Enrollment instances.
A ternary Supply fact becomes a Supply box linked to Supplier, Part, and Project. Its quantity belongs inside Supply. Each Supply instance points to one instance of each participant. With optional participation for the participant types, the Supply ends of all three lines show zero or many.
Crow's foot has no universal symbols for all Chen attribute kinds. List a composite address as street, postal code, and city. Give a multivalued phone attribute a separate Member Phone box. Record the derivation of a calculated value in the diagram's notes or legend if the tool has no symbol for it.
Convert one relationship step by step
Start with Chen's DEPARTMENT–EMPLOYS–EMPLOYEE, ratio 1:N, with a double line at EMPLOYEE and a single line at DEPARTMENT.
- Replace the entity rectangles with boxes and move the attribute ovals inside.
- Replace EMPLOYS with a line labeled “employs.”
- Put exactly-one marks beside Department: every employee must have one department.
- Put zero-or-many marks beside Employee: a department may have no employees.
In common ASCII form this is:
DEPARTMENT ||--o{ EMPLOYEE : employs
The two bars are beside DEPARTMENT, and the circle plus opening crow's foot is beside EMPLOYEE. In many tools, solid lines mean identifying relationships and dashed lines mean non-identifying ones. Read the legend because tools vary. Conversion must preserve the business sentences even when the shapes and positions change.
Key Takeaways
- Read crow’s foot marks at the opposite end from the starting instance.
- The nearest mark gives the maximum and the farther mark gives the minimum.
- An associative entity holds relationship attributes and resolves logical M:N or ternary links.
- Convert the business rules, then place the marks; copying their positions can reverse the meaning.
- Use the diagram legend for identifying lines and unsupported attribute symbols.
4Weak entities and type hierarchies
Some instances borrow part of their identity from an owner; others are specialized forms of the same underlying instance. These are different modeling needs. Room numbers illustrate identification within an owner, while Person, Student, and Employee illustrate inherited identity and facts. You will distinguish those structures, show them in a diagram, and state independently whether subclass membership can overlap and whether every superclass instance must belong to a subclass.
4.1 Identity within an owner
A weak entity type cannot identify its instances with its own attributes alone. Its full identity combines an owner's key with a partial key that distinguishes instances belonging to that owner. A strong entity type already has a key of its own.
Build the identifier
Room numbers repeat across campus buildings. Room 101 in building A and room 101 in building B are different rooms. Building has key building_code; Room has partial key room_number. The room identifiers are the pairs (A, 101) and (B, 101).
The owner–weak link is an identifying relationship. It is usually 1:N from owner to weak entity, and the weak entity participates totally: a room in this model cannot exist without its building. An owner can still have no weak instances when the requirements allow it.
Order lines work the same way. Order 5001 has lines 1, 2, and 3; order 5002 has lines 1 and 2. The value 1 identifies a line only after an order has been chosen. Deleting order 5001 removes the meaning of its three lines, so the design deletes those lines with the order.
Draw identification explicitly
In Chen notation, draw Room as a double rectangle, the identifying relationship as a double diamond, and the partial key with a dashed underline. Use a double participation line from Room to the identifying relationship.
A solid underline would incorrectly claim that room number alone is globally unique. A single participation line would allow an ownerless room. In many crow's foot tools, a solid identifying line and an owner key included in the child's PK express the same identity; the legend establishes the line convention.
Dependency is different from weak identity
An Order may require a Customer and still be strong. If order_id is unique across the whole database, it identifies the order without the customer's identifier. The required customer link gives total participation, while weakness concerns how identity is formed.
You can give Room a surrogate room_id and make it strong. Keep the original rule with UNIQUE (building_code, room_number), and require both columns. Otherwise two room records could claim the same number in the same building despite having different generated IDs.
Follow nested ownership
A weak type can own another weak type. In a cinema chain, Hall is identified by Venue plus hall_number. Seat is identified by Hall plus seat_label. Expand the full identifier one level at a time:
- Venue:
venue_id. - Hall:
(venue_id, hall_number). - Seat:
(venue_id, hall_number, seat_label).
Seat A7 in hall 2 of venue 9 differs from seat A7 in hall 2 of venue 10. Dropping any owner component would merge distinct locations. When mapping or referencing a weak entity, carry every component of this complete key.
Key Takeaways
- A weak entity’s identity combines its owner’s key and its partial key.
- The identifying relationship has total participation on the weak side.
- A required owner link alone does not make an entity weak.
- Adding a surrogate key still leaves the owner-relative uniqueness rule to enforce.
- Nested weak identifiers include the full chain of owner keys.
4.2 Shared identity and inherited facts
A subclass is a specialized group within a superclass. Every Student is a Person. The Student and Person descriptions concern the same underlying instance, so the IS-A connection carries identity as well as membership.
Inherit the shared facts
Person has person_id, name, and date of birth. Student adds enrollment year and an enrollment relationship. Employee adds salary and a “works in” relationship. A student has all Person attributes plus the Student attributes, and inherits Person's relationships too.
Place each shared fact at the superclass level. Repeating name as an independently stored subclass attribute would allow two names for the same person. Attributes specific to a subclass stay with that subclass, where they apply to every member of that group.
An ordinary 1:1 relationship has a different meaning. A person can have one passport, but Person and Passport are distinct things. Student IS-A Person means the student is that person. Drawing it as a plain one-to-one link loses the shared-identity rule.
Work down or work up
Specialization starts with a broad type and splits out groups with their own facts or relationships. From Employee, identify Instructor with academic rank and Administrator with an office.
Generalization starts with similar types and finds their common base. Car and Truck may share registration number, make, and model year. Move those shared facts into Vehicle and keep the differences in Car and Truck. The result is the same kind of hierarchy, reached from the other direction.
A group name alone rarely needs a subclass. If the only difference is a label and all facts and links are identical, a type attribute can be enough. A pattern of inapplicable attributes can reveal a useful subclass: hourly rate belongs naturally to hourly staff when other employees do not have one. This is a design clue to check against the actual requirements.
More than one level or parent
Hierarchies can have several levels. A further subclass inherits through its ancestors. A lattice allows a subclass to have more than one superclass: Teaching Assistant can be both Student and Employee and inherit from both.
The shared subclass must keep the same underlying Person identity along both paths. It does not represent one unrelated student joined to one unrelated employee. The purpose is to describe one instance that has both roles.
Show the structure clearly
An extended Chen style links the superclass to a small circle and the circle to subclass rectangles. Subclass-specific attributes attach to those rectangles. Other styles use hollow arrowheads pointing from subclasses to the superclass.
Crow's foot tools vary: some nest subtype boxes, while others use a subtype connector. Write the hierarchy's constraints beside it when needed. First make the IS-A meaning clear; then state whether members may occupy more than one subclass and whether the subclasses cover the entire superclass.
Key Takeaways
- An IS-A link means the subclass instance is the same instance as its superclass.
- Subclasses inherit superclass attributes and relationships.
- Specialization works downward; generalization finds a shared superclass from below.
- A lattice lets a shared subclass inherit from more than one superclass.
4.3 Overlap and completeness
A hierarchy needs two independent membership rules. Disjointness asks whether one instance can belong to several subclasses. Completeness asks whether every superclass instance must belong to at least one. Neither rule answers the other question.
Make the two decisions
Disjoint subclasses allow at most one membership. Overlapping subclasses allow several. Total specialization requires at least one membership; partial specialization allows none.
| Combination | Allowed membership |
|---|---|
| Disjoint and total | Exactly one subclass |
| Disjoint and partial | One subclass or none |
| Overlapping and total | One or several subclasses |
| Overlapping and partial | None, one, or several subclasses |
For accounts limited to Savings and Checking, disjoint and total means every account is exactly one of those two types. A Person hierarchy with Student and Employee can be overlapping and partial: a person may study, work, do both, or do neither.
Check concrete instances
Consider four people: Amira is a student, Bruno is an employee, Mei is both, and Lena is neither. Mei needs overlapping membership; Lena needs partial completeness. Under a disjoint-and-total rule, Mei violates disjointness and Lena violates completeness.
Testing the two cases separately helps diagnose a bad rule. If the database must accept Mei but reject Lena, choose overlapping and total. If it must reject Mei but accept Lena, choose disjoint and partial. Seeing only students and employees in a small current list does not establish that future “neither” cases are forbidden; the business rule must settle that.
Put constraints on the diagram
In extended Chen notation, the circle contains d for disjoint or o for overlapping. A double line from the superclass to the circle means total specialization; a single line means partial. A diagram with o and a single superclass line expresses the four-person example.
Other tools write the words directly. Keep both words visible because a single “optional” note can otherwise be mistaken for a statement about overlapping membership.
Decide how membership is assigned
An attribute-defined specialization uses a superclass attribute to determine membership. For example, account_type = 'SAVINGS' puts an account in Savings. One single-valued type code fits a disjoint classification because the row holds one value. A user-defined specialization records membership through user decisions instead of one defining attribute.
The rules also govern changes. Under total specialization, a new superclass instance must acquire a subclass membership. Removing its only membership without replacing it would break completeness. Removing the superclass instance removes it from every subclass because those memberships refer to the same instance. In an attribute-defined hierarchy, changing the defining value changes the membership. When translating the hierarchy to tables, preserve these rules explicitly; merely creating subclass tables does not enforce all of them.
Key Takeaways
- Disjointness controls whether memberships may overlap.
- Completeness controls whether zero memberships are allowed.
- Total and overlapping are compatible: every instance belongs to at least one subclass and may belong to several.
- An attribute-defined specialization derives membership from a defining value.
- Changes must preserve both constraints, including when the last membership is removed.
5Turning the model into tables
Logical mapping makes the model enforceable in a relational database. Entity identities become primary keys, links become foreign keys or junction tables, and attribute kinds determine whether a fact needs one column or several rows. You will map each relationship shape, carry complete weak keys into references, and compare four ways to store subclasses. At each step, check which business rules the chosen SQL constraints actually enforce.
5.1 Tables and attribute storage
Logical design translates a conceptual model into a relational schema. A strong entity type becomes a table, and each simple attribute becomes a column. The entity's chosen identifier becomes the table's primary key.
Preserve all candidate keys
Schema notation makes the design compact: course(code PK, title, credits) marks code as the primary key. FK → member marks a foreign key to Member. SQL then gives these labels enforceable meaning through PRIMARY KEY and REFERENCES.
An alternate candidate key must be both unique and present. If every trainer has a distinct work email, declare email NOT NULL UNIQUE. A uniqueness constraint alone is insufficient to require an address. In the library model, members may share an email, so email is an ordinary attribute with no uniqueness constraint.
A composite address contributes its simple parts, such as street, postal_code, and city. The containing attribute name disappears from the table. This allows a city search without parsing a complete address string.
Give each repeated value a row
A multivalued phone attribute becomes member_phone(member_id PK FK → member, phone PK). The pair identifies each value belonging to one owner. Two phone numbers give two rows; no phone numbers give no rows.
CREATE TABLE member (
member_id INTEGER PRIMARY KEY,
first_name VARCHAR(50) NOT NULL,
last_name VARCHAR(50) NOT NULL,
email VARCHAR(254),
street VARCHAR(100),
postal_code VARCHAR(10),
city VARCHAR(60),
date_of_birth DATE
);
CREATE TABLE member_phone (
member_id INTEGER REFERENCES member (member_id),
phone VARCHAR(20),
PRIMARY KEY (member_id, phone)
);
The composite primary key makes both phone-table columns non-null and prevents a member–phone pair from being repeated. It still permits the same phone number to appear for different members because phone alone is not unique. A comma-separated list in one column would not give each value its own constraint or reference.
Decide whether to store a derived value
Age has no column here: compute it from date of birth and the current date. Likewise, count enrollments when a course's participant count is needed. A view or query can present the result alongside stored facts.
A historical snapshot has a different purpose. An order's charged price preserves the value agreed at that time, even if the current product price changes. A stored current count, kept because computing it repeatedly is too slow, must change whenever its inputs change. Do not update a historical snapshot as though it were a current cached value.
Map in a practical order
Start with strong types, then weak types, binary relationships, higher-degree relationships, multivalued attributes, and hierarchies. Add foreign keys after their referenced tables exist. When references form a cycle, create the tables and add constraints in stages as needed. The final schema should show each stored fact's columns, every candidate key, and each link's full referenced key.
Key Takeaways
- Strong entity types become tables and simple attributes become columns.
- Alternate candidate keys need NOT NULL as well as uniqueness.
- Composite attributes contribute their simple parts; multivalued attributes get separate rows.
- Compute derived current values unless a deliberate storage choice requires them.
- Historical snapshots stay fixed; stored current results must track their inputs.
5.2 Foreign keys for one-to-many and one-to-one links
A foreign key stores a reference to one related row. Its position and constraints must match both the relationship's maximum and its minimum. A reference that finds a real parent still needs separate rules about whether it can be missing or repeated.
Put a 1:N reference on the many side
For Department 1:N Employee, put department_id in Employee. Many employee rows can repeat the same department identifier. Putting one employee_id in Department would provide space for only one employee.
If every employee needs a department, make the foreign key NOT NULL. If unassigned employees are allowed, permit NULL. A start date belonging to the current assignment goes beside the foreign key on Employee.
CREATE TABLE employee (
employee_id INTEGER PRIMARY KEY,
name VARCHAR(100) NOT NULL,
department_id INTEGER NOT NULL
REFERENCES department (department_id),
start_date DATE,
supervisor_id INTEGER REFERENCES employee (employee_id)
);
The supervisor reference maps a recursive 1:N relationship. Its role name distinguishes it from the employee's own key. It allows NULL so that a top manager can have no supervisor.
With employees 1–3 assigned to department 10 and employees 4–7 assigned to department 20, department 30 can still have no employees. A non-null department reference in every employee enforces Employee's total participation. It does not enforce total participation for Department. Requiring every department to have an employee needs another mechanism that checks child existence.
Limit a 1:1 reference with uniqueness
Suppose every department has exactly one manager and an employee manages at most one department. Use department(department_id PK, name, manager_id FK → employee NOT NULL UNIQUE, manager_since).
REFERENCES checks that the manager exists. NOT NULL requires every department to name one. UNIQUE prevents the same employee from managing two departments. Without uniqueness, several departments could name the same manager, making the relationship 1:N.
Two other designs are useful:
- Merge the types when both participate totally and are created together, such as an account and its settings.
- Use a cross-reference table when both sides are optional and few are linked. Make each participant key individually unique in that table.
A combined primary key on the cross-reference pair only stops duplicate pairs; it does not stop either participant appearing in several different pairs.
Handle required circular references
If Department requires manager_id and Employee requires department_id, the first department and first employee cannot each be inserted alone with immediate checks. A supported deferrable foreign key can be checked after both rows exist at transaction end. Another design permits a temporary null reference and fills it in later, but then the final business rule needs its own enforcement. Making a column nullable changes what the schema permits; it is not itself a complete implementation of mandatory participation.
Key Takeaways
- For 1:N, put the foreign key and link attributes on the many side.
- Use NOT NULL for mandatory participation of the referencing row.
- A foreign key does not require every referenced row to have a child.
- A 1:1 foreign key also needs UNIQUE.
- A recursive 1:N link is a role-named reference to the same table.
- Plan how required circular references are created and checked.
5.3 Junction tables and complete weak keys
Many-to-many relationships need a row for each link. Weak entity types need a row whose identity contains its owner's key. Both often use composite primary keys, but the keys express different facts: one identifies an association and the other identifies an owned instance.
Map each enrollment link
Create enrollment(participant_id PK FK → participant, course_code PK FK → course, score). Amira takes Databases and Statistics; Bruno takes Databases; Mei takes Databases, Statistics, and Art. The two Amira links, one Bruno link, and three Mei links give six rows. Databases appears in three rows, one for each participant.
The primary key prevents the same participant–course pair from appearing twice. If results from repeated terms must be kept, extend the identifier to (participant_id, course_code, term). A surrogate enrollment_id is also possible, but keep a unique constraint on that business combination. Generated row IDs alone would allow duplicate enrollment facts with conflicting scores.
A recursive M:N relationship uses two role-named foreign keys to the same table: course_prerequisite(course_code PK FK → course, prerequisite_code PK FK → course). Reversing the columns changes which course requires which.
Keep a higher-degree fact in one row
Supply has foreign keys to Supplier, Part, and Project, with quantity as a link attribute. Usually the three participant keys form the primary key. If each project gets each part from exactly one supplier, (part_id, project_id) alone identifies the relationship row. Supplier stays a required foreign key but is omitted from the primary key.
Making all three columns the only uniqueness rule would then allow two suppliers for the same part–project pair. Choose the smallest key justified by the relationship's actual constraints.
Map weak identity
Room becomes room(building_code PK FK → building, room_number PK, capacity). The identifying relationship needs no separate table: the owner reference already represents it.
For an order line, combine the owner's key and the line number. The owner reference can use ON DELETE CASCADE when deleting an order must remove its lines:
CREATE TABLE order_line (
order_id INTEGER REFERENCES customer_order (order_id)
ON DELETE CASCADE,
line_number INTEGER,
product_id INTEGER NOT NULL REFERENCES product (product_id),
quantity INTEGER NOT NULL CHECK (quantity > 0),
PRIMARY KEY (order_id, line_number)
);
The table is named customer_order because ORDER is reserved in SQL. The primary key makes both identifying columns non-null. Without a delete action, the default NO ACTION prevents a referenced order from being deleted while its lines still reference it, subject to when the constraint is checked.
Reference the whole identifier
If another table refers to Room, its foreign key must combine building_code and room_number and reference that pair together. A room number alone can match several buildings. Separate checks on the two values would not establish that the particular combination exists. The same rule applies to every composite key, including nested weak identifiers.
Key Takeaways
- An M:N link becomes a junction table containing participant foreign keys and link attributes.
- A surrogate key still needs a uniqueness rule for the actual association.
- Repeated occurrences need an additional identifying value.
- A higher-degree relationship’s constraints determine which participant keys are needed in its primary key.
- A weak table’s primary key combines the owner’s key and the partial key.
- Reference composite identifiers with one foreign key over the complete combination.
5.4 Four ways to store subclasses
Consider Person with key person_id, name, and date of birth. Student adds enrollment year; Employee adds salary. The table mapping must preserve shared identity, allowed memberships, and any subclass-specific relationships.
Compare the four options
| Option | Tables | Best fit or limitation |
|---|---|---|
| A: Superclass plus subclasses | Person, Student, Employee | Supports every constraint combination; full subclass records need joins |
| B: Subclasses only | Student and Employee, each with inherited columns | Needs total coverage; overlap duplicates shared facts |
| C: One table with one type | Person with a type column and subclass columns | Fits disjoint membership |
| D: One table with flags | Person with one Boolean flag per subclass | Fits overlapping membership |
The table layouts below use PK for primary key and FK for foreign key.
A:
person(person_id PK, name, date_of_birth)
student(person_id PK FK → person, enrollment_year)
employee(person_id PK FK → person, salary)
B:
student(person_id PK, name, date_of_birth, enrollment_year)
employee(person_id PK, name, date_of_birth, salary)
C:
person(person_id PK, name, date_of_birth, person_type,
enrollment_year, salary)
D:
person(person_id PK, name, date_of_birth, is_student,
is_employee, enrollment_year, salary)
With A, each subclass uses person_id as both primary key and foreign key to Person. Person holds the shared facts once. Foreign keys ensure that subclass rows have superclass rows; total coverage and disjointness still need additional enforcement when required.
With B, each subclass row repeats name and date of birth. A person in neither subclass has nowhere to go, so the specialization must be total. Overlapping membership stores the same person in two tables, where shared values can disagree. Another table cannot refer to all people through one ordinary foreign key because the possible targets are split. An inherited outgoing reference, such as a department reference from each person, can still be repeated in each subclass table.
With C, one person_type value selects a subclass. Inapplicable subclass columns are NULL, and checks tie their use to the type. For example, salary must be null unless the type is Employee. A single type value cannot represent someone who belongs to both Student and Employee. A partial disjoint hierarchy also needs a representation for “neither.”
With D, is_student and is_employee can both be true. Require non-null flags and checks that keep subclass-only values consistent with membership. If the hierarchy is total, also require at least one flag to be true. Two false flags represent “neither” when the hierarchy is partial.
Follow the four-person example
Amira is a student, Bruno an employee, Mei both, and Lena neither. Option A gives four Person rows, two Student rows, and two Employee rows. Option B cannot store Lena and duplicates Mei's shared facts. Option C cannot express Mei's two memberships with one type. Option D gives four rows, with both flags true for Mei and both false for Lena.
Use the relationships to choose
With many subclass-specific attributes or links, A keeps each table focused. Employee's department foreign key goes in Employee, preventing a non-employee from acquiring that link; Mei can have one because she is an employee too.
With few subclass fields and frequent whole-population reads, C or D avoids joins but needs checks around nullable fields. B suits a disjoint, total hierarchy when work usually concerns one subclass at a time. In a one-table mapping, a department foreign key needs a membership check so that people outside Employee cannot use it.
Key Takeaways
- Option A shares the superclass key with each subclass and supports all membership combinations.
- Option B needs total coverage and duplicates inherited facts when memberships overlap.
- Option C’s one type column fits disjoint membership; Option D’s flags allow overlap.
- The table layout must be paired with constraints that enforce the hierarchy’s rules.
- Keep subclass-specific relationships available only to members of that subclass.
6Building and checking a complete design
A complete model has to work as a whole: its identifiers, relationship rules, and tables must support the questions people ask. The library case brings together multivalued attributes, a weak copy identifier, authorship links, and repeatable loan events. Then sample data and targeted review questions expose missing links and unenforced rules. A diagram can look tidy while still losing a fact, so the final test is whether the required data can be stored and retrieved correctly.
6.1 From library requirements to a schema
The library needs branches with names and addresses; books cataloged by ISBN, title, year, and authors; numbered copies kept at branches; and members with names, emails, and phone numbers. It keeps each loan's dates, including repeat loans of the same copy to the same member.
Choose identities and attributes
Use Branch, Member, Book, Author, Copy, and Loan. Give Branch, Member, Author, and Loan generated identifiers. Book uses ISBN. A copy number is unique only within a book, so Copy is weak with partial key copy_number and owner Book.
Split Branch's address into street, postal code, and city. Member's phone numbers are multivalued. Email is not a candidate key: the requirements do not guarantee distinct addresses for different members. Loan keeps loan date, due date, and return date; a still-open loan has a null return date.
A Loan needs an identity beyond the Member–Copy pair. Otherwise the same member's second borrowing would collide with the first and its dates could not be kept separately.
State every relationship in both directions
Each Book has one or more Authors, and each Author in this catalog has one or more Books: M:N. A Book has zero or many Copies; each Copy belongs to exactly one Book. A Branch holds zero or many Copies; each Copy is held by exactly one Branch. A Member has zero or many Loans and a Copy has zero or many Loans over time; each Loan has exactly one Member and one Copy.
One crow's foot rendering of the logical relationships is:
BOOK ||--o{ COPY : identifies
BRANCH ||--o{ COPY : holds
MEMBER ||--o{ LOAN : borrows
COPY ||--o{ LOAN : concerns
BOOK ||--|{ BOOK_AUTHOR : has
AUTHOR ||--|{ BOOK_AUTHOR : writes
MEMBER ||--o{ MEMBER_PHONE : registers
Each end describes the partners reached from the opposite box. Book Author is the authorship link; Member Phone stores each registered phone value.
Produce the eight tables
branch(branch_id PK, name, street, postal_code, city)member(member_id PK, name, email)member_phone(member_id PK FK → member, phone PK)book(isbn PK, title, publication_year)author(author_id PK, name)book_author(isbn PK FK → book, author_id PK FK → author)copy(isbn PK FK → book, copy_number PK, branch_id FK → branch NOT NULL)loan(loan_id PK, member_id FK → member NOT NULL, isbn NOT NULL, copy_number NOT NULL, loan_date, due_date, return_date)
Loan additionally needs one composite constraint: FOREIGN KEY (isbn, copy_number) REFERENCES copy (isbn, copy_number). It checks the particular copy, including its book, as a single reference.
Check the design with instances
“The Quiet River” has copies 1 and 2 at Central and copy 3 at Harbor. Member 12 borrowed copy 1 on 2026-10-01, due 2026-10-22, and returned it on 2026-10-20. Copy 2 was borrowed on 2026-10-20, is due on 2026-11-10, and has no return date. On 2026-10-29, copy 1 is available at Central; copy 2 still has an open loan.
Requiring every book to have an author needs a child-existence check beyond the foreign keys. Date ordering fits CHECK (return_date >= loan_date); it permits a null return date for an open loan. Requiring loan date to be present needs NOT NULL as well.
Key Takeaways
- Book and Copy are different types; Copy’s identity includes Book’s ISBN.
- A Loan identifier keeps repeat borrowings separate.
- The library mapping has eight tables, including phone and authorship tables.
- Loan references Copy with one composite foreign key.
- Sample rows check whether the design can answer availability questions.
- Author minimums and date rules need explicit enforcement beyond the relationship lines.
6.2 Finding missing links and unenforced rules
A review asks whether the model can keep every required fact and answer every required question. Check the requirements against the diagram, then check the diagram against the table constraints. A correct-looking line can still encode the wrong minimum, maximum, or time scope.
Read and test the model
For each strong type, find its key. For each weak type, find its owner and partial key. Check multivalued and derived attributes, consistent names, and relationships drawn twice as both attributes and lines.
Read every relationship aloud with both bounds: “Each copy is held by exactly one branch” and “Each branch holds zero or many copies.” Have someone who knows the domain confirm both sentences. A rejection identifies a particular rule to change.
Next, invent small sample instances and try the required actions. Can you create a branch with no copies? Can a member register two phone numbers? Can the same member borrow the same copy later? Test a valid boundary case as well as a normal one. Also try invalid cases, such as a loan referring to a nonexistent copy, and identify the exact constraint that rejects each one.
Recognize a fan trap
Suppose Faculty has 1:N links to both Department and Instructor. Two departments and three instructors can belong to the same faculty, but the model does not record which department employs each instructor. Joining through Faculty would pair each instructor with every department of that faculty.
The required connection is Department–Instructor. If each instructor belongs to one department and each department belongs to one faculty, use the chain Faculty 1:N Department 1:N Instructor. The faculty of an instructor then follows through the department. Keep a separate direct faculty link only if it records a genuinely different fact.
Recognize a chasm trap
A rental model links Branch to Employee and Employee to Car through “looks after.” Cars may have no assigned employee. A car without a caretaker then has no path to its branch, even though the business still needs to know where it is.
Add a direct Branch–Car relationship. Branch location and employee care are separate facts, so the cycle now has a reason. Making care mandatory would reject valid unassigned cars without recording their location independently.
Record rules beyond the diagram
An ER diagram does not express every business rule. “A member may have at most 10 copies on loan at once” counts open loans across rows; “the due date is 21 days after the loan date” compares values within a loan. Write both rules next to the model, then choose an enforcement mechanism for each.
Row-local value checks often fit CHECK. Rules that count other rows or require a parent to have children need a mechanism such as a trigger, transaction-level check, or application code. Check concurrent changes too: separate actions that each seem valid must not together break the same business limit.
Key Takeaways
- Review requirements, diagram rules, and table constraints as separate checks.
- A fan trap misses the needed connection between two branches of a relationship pattern.
- A chasm trap loses a path when an optional intermediate link is absent.
- A cycle is useful when its links record different facts.
- Record and enforce business rules that relationship marks cannot express.
Entity-Relationship Modeling examples
1Turn requirements into entities and keys
12 steps
- 1IntroductionStart with the data to remember
A training center needs a record of its courses, trainers, and participants. It also needs to know who enrolls in which course and what score they receive.
Build the conceptual model first: identify the things, their facts, and their links. Each kind of thing is an entity type; a candidate key identifies each instance even as data changes. Tables and SQL come later, once these meanings are clear enough to discuss with the people who use the data.
- 2ExampleMark the candidate things
Read: “Each course has a code, a title, and credits. Trainers teach courses. Participants enroll and receive a score.”
Course, Trainer, and Participant are candidate entity types. Code, title, and credits describe a course, so they are attributes. Score needs a closer look because it describes a participant in one particular course.
- 3ExplanationSeparate a type from one member
Student names a category; Amira Haddad, student number 20417, is one instance. The same distinction applies to departments: Mathematics Department and History Department are two instances of Department.
Use one singular name for each type. Creating a different type for every current department would confuse the category with the members it is meant to describe.
- 4ChallengeDoes this need an entity type?
A center needs to store its own address and director, even though it has only one center. Should Center be modeled as an entity type?
---reveal---
Yes. Center has facts that the database needs to keep. An entity type can have one instance; a count of one is not a reason to discard the concept.
- 5TipAsk what an unclear noun means
If requirements use both “learner” and “participant,” check whether they mean the same thing. Merge synonyms before adding boxes.
Also turn vague sentences into concrete questions. “Trainers teach courses” leaves open whether trainers can share a course. Ask about that possibility before selecting relationship constraints.
- 6ExplanationGive each fact a useful form
An attribute domain states its valid values, such as dates or credits from 1 to 30. An address can be composite when street, postal code, and city need separate use.
A member can have several phone numbers, making phones multivalued. The two distinctions answer different questions: parts within one value versus several values belonging to one instance.
- 7ExampleChoose stored facts and derived values
Store date of birth and derive current age from it. A person born on 2000-03-15 is 26 on 2026-10-29; the same stored birth date supports a different age after the next birthday.
A return date can be
NULLwhile a loan is open. Null represents a missing or inapplicable value, not a second phone number or a value that should be calculated. - 8ExplanationRequire a minimal identifier
A candidate key uniquely identifies every instance and has no unnecessary parts. If student number alone is unique, the combination of student number and last name is not minimal.
Choose one candidate as the primary key. A composite key is valid when its components are needed together, such as flight number and date for a scheduled flight.
- 9ChallengeCheck a proposed key
A club gives each member a unique permanent number. Two members may share a name and email. Is (member number, email) a candidate key?
---reveal---
No. Member number already gives uniqueness, so email is an unnecessary component. Email also cannot identify a member alone because sharing is allowed. The number is the minimal candidate here.
- 10Key InsightKeep identity stable
A natural key comes from the domain, such as ISBN. A surrogate key is generated only for identification. Either must identify the intended instance reliably.
An email can be a candidate only when every instance has one and sharing is forbidden. Even then it may change, which is a reason to choose a stable surrogate primary key and preserve email’s separate uniqueness rule.
- 11ChallengeCombine entity and key choices
A learning center now records each department’s budget and manager. Department names can repeat across branches, but every department receives a globally unique department number. What should Department become, and what identifies it?
---reveal---
Use a Department entity type with department number as its key. Its own facts justify the entity, and repeated names make name unsuitable as its identifier.
- 12RecapReview the first design decisions
The model now distinguishes types from instances and properties from independent records. Each fact has a useful form: simple parts, multiple values, or a derivation.
Check every proposed identifier against all allowed instances, not just the current sample. A unique and minimal candidate gives relationships a dependable way to point to the right instance.
2Build relationships from business rules
14 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionDecide what each link records
- 2ExampleAttach score to the enrollment
- 3ExplanationUse roles for a recursive link
- 4ExampleKeep a supply triple together
- 5ChallengeIdentify the complete fact
- 6ExampleAsk both maximum questions
- 7ExplanationCombine the bounds
- 8ChallengeTranslate a new rule
- 9TipSeparate current state from history
- 10ExampleGive repeated events identities
- 11ExplanationChoose when a property gets a box
- 12Key InsightStore each conceptual link once
- 13ChallengeExtend a current-assignment model
- 14RecapCheck meaning and both bounds
3Convert a relationship between diagram styles
12 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionKeep the rules while changing the drawing
- 2ExplanationRead Chen’s three shapes
- 3ExamplePlace ratio and participation marks
- 4Key InsightNotice the pair-style reversal
- 5ChallengeInterpret a participation pair
- 6TipCheck arrows and recursive roles
- 7ExplanationRead the destination end
- 8ExampleConvert the employee rule
- 9ChallengePlace the correct end marks
- 10ConnectionConvert a relationship with its own facts
- 11ChallengeConvert a weak identifier too
- 12RecapRead both sentences after conversion
4Model owned identities and inherited roles
14 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionSeparate two kinds of structure
- 2ExampleComplete the room identifier
- 3ExplanationDraw the identifying structure
- 4ChallengeIs dependency enough?
- 5Key InsightCarry nested owners into the key
- 6ExplanationA student is the same person
- 7ExampleWork down or work up
- 8ChallengeFollow two inheritance paths
- 9ExplanationAsk about both and neither
- 10ExampleTest four people
- 11ChallengeChoose the membership constraints
- 12ConnectionLet a value determine a subtype
- 13ChallengePreserve identity and valid membership
- 14RecapCheck identity before choosing symbols
5Map the model and check its constraints
21 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionMake the model’s rules enforceable
- 2ExampleStart with a member table
- 3ExampleGive phone values separate rows
- 4ChallengeKeep the right stored value
- 5ExamplePlace a one-to-many reference
- 6Key InsightCheck what the foreign key guarantees
- 7ExampleMap one-to-one with three checks
- 8ChallengeDiagnose a nearly correct mapping
- 9TipPlan self-references and cycles
- 10ExampleCreate one row per enrollment
- 11ExampleCount the actual relationship rows
- 12ChallengeKeep repeat terms without duplicates
- 13ExampleMap a three-way rule
- 14ExampleCarry a weak key into its table
- 15ChallengeValidate the whole target identity
- 16ExplanationShare a key across superclass tables
- 17ExampleCompare the other three layouts
- 18ChallengeChoose a layout for both and neither
- 19ExampleTrace four people through the tables
- 20ChallengeConnect mapping to membership enforcement
- 21RecapMatch each rule to its declaration
6Build and review the library schema
14 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionFollow one complete library design
- 2ExampleDistinguish the book from its copies
- 3ExampleGive every loan its own identity
- 4ExplanationAdd the two extra value tables
- 5ChallengeReference a numbered copy
- 6ExampleTest availability with actual loans
- 7Key InsightFind the rules still missing
- 8TipReview in both directions
- 9ExampleFind a fan trap
- 10ChallengeRepair an incomplete path
- 11ExampleKeep a path for unassigned cars
- 12ChallengeChoose the right enforcement level
- 13ChallengeReview a changed copy design
- 14RecapFinish with facts and questions
Entity-Relationship Modeling practice questions
Set 1: Identify entities and preserve their links10 Practice Questions
Question 1 of 10
Show answerHide answer
Question 2 of 10
Show answerHide answer
Question 3 of 10
Show answerHide answer
Question 4 of 10
Show answerHide answer
Question 5 of 10
Show answerHide answer
Question 6 of 10
Show answerHide answer
Question 7 of 10
Show answerHide answer
Question 8 of 10
Show answerHide answer
Question 9 of 10
Show answerHide answer
Question 10 of 10
Show answerHide answer
Set 2: Read constraints and choose table structures10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Set 3: Choose identifiers and test model changes10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Set 4: Diagnose constraints and information loss10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Set 5: Transfer the design rules to new cases10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
match_record(left_id, right_id). Both columns are NOT NULL foreign keys, and the only key is PRIMARY KEY (left_id, right_id). Rows (L1, R1) and (L1, R2) are both accepted. What constraint change enforces the maximum on both sides?Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Stuck on your own question? Homework Help
Key Terms
A
Alternate candidate key
Arrow constraint
Associative entity
Attribute
Attribute-defined specialization
B
Binary relationship
Book edition
Business rule
C
Candidate key
Cardinality ratio
Chasm trap
CHECK constraint
Chen notation
Completeness constraint
Composite attribute
Composite foreign key
Composite key
Conceptual design
Copy
Crow’s foot end marks
Crow’s foot notation
D
Deferrable foreign key
Derived attribute
Disjoint specialization
Domain
E
Entity instance
Entity type
Entity-relationship model
F
Fan trap
Foreign key
G
Generalization
H
Historical snapshot
I
Identifying relationship
Inheritance
J
Junction table
L
Lattice
Loan
Logical design
M
Membership-flag mapping
Minimum–maximum pair
Multivalued attribute
N
N-ary relationship mapping
Natural key
Non-identifying relationship
NOT NULL constraint
NULL
O
ON DELETE CASCADE
Overlapping specialization
Owner
P
Partial key
Partial participation
Partial specialization
Participation constraint
Participation line
Physical design
Primary key
R
Ratio label
Recursive relationship
Redundant relationship
Relational schema
Relationship attribute
Relationship degree
Relationship instance
Relationship type
Repeated event
Requirements
Role
S
Self-referencing foreign key
Simple attribute
Specialization
Stored current result
Strong entity type
Subclass
Subclass-only mapping
Superclass
Superclass-plus-subclass mapping
Surrogate key
T
Ternary relationship
Total participation
Total specialization
Type-column mapping
U
UNIQUE constraint
W
Weak entity type
About this lesson
Make your own Study Materials
Turn your notes, slides and documents into Study Guides, Practice Questions, Flashcards and 6 more tools.