Introduction
The entity-relationship (ER) model describes the data of an application before any table is designed. It says which things exist (entities), what is recorded about them (attributes) and how they are connected (relationships), together with the counting rules that the real world imposes: a student belongs to exactly one department, a course can have many sections, a section cannot exist without its course.
The ER model is a conceptual model. It has no tables, no foreign keys and no SQL; those appear only when the diagram is mapped to relations (see Mapping ER Diagrams to Relations). Its value is that every later design decision (which table holds which foreign key, which key is composite, whether a column may be NULL) can be read off the diagram's cardinality and participation constraints.
Working with an ER model comes down to reading the constraints on a diagram correctly, counting the minimum number of tables a diagram needs, and recognising weak entity sets and the keys of relationship sets.
Prerequisites
None within the syllabus. Familiarity with sets and ordered pairs helps, since a relationship set is a set of tuples of entities.
Core concepts
| Term | Meaning |
|---|---|
| Entity | A distinguishable object: one student, one course. |
| Entity set (entity type) | The collection of entities of one kind, with the same attributes. Drawn as a rectangle. |
| Attribute | A property of an entity or relationship. Drawn as an oval (Chen style). |
| Domain | The set of allowed values of an attribute. |
| Key attribute | An attribute (or set) whose value is unique for every entity of the set. Underlined. |
| Relationship | An association among entities, for example "Asha enrols in section 2 of DBMS". |
| Relationship set | A set of relationships of one kind; mathematically a subset of . Drawn as a diamond. |
| Degree | The number of participating entity sets: binary (), ternary (). |
| Role | The function an entity plays in a relationship; needed when an entity set participates twice (recursive relationship). |
Kinds of attributes
- Simple versus composite. A composite attribute has parts, for example
namewithfirstandlast. Drawn as an oval with child ovals. - Single-valued versus multivalued. A multivalued attribute can hold several values for one entity, for example
phone. Drawn as a double oval. - Stored versus derived. A derived attribute is computed from others, for example
agefromdob. Drawn as a dashed oval and not stored. - NULL. An attribute may be NULL when the value does not apply or is unknown.
Notation convention. These notes draw Chen-style diagrams as in Elmasri and Navathe: rectangles for entity sets, ovals for attributes, diamonds for relationship sets, double rectangles and double diamonds for weak entity sets and their identifying relationships, double lines for total participation. Korth, Silberschatz and Sudarshan list attributes inside the entity rectangle instead and mark "one" with an arrowhead; the meaning of the constraints is the same.
Mapping cardinalities of a binary relationship
For a binary relationship set between entity sets and :
| Ratio | Each is related to | Each is related to |
|---|---|---|
| One-to-one (1:1) | at most one | at most one |
| One-to-many (1:N), on the one side | any number of | at most one |
| Many-to-one (N:1) | at most one | any number of |
| Many-to-many (M:N) | any number of | any number of |
Participation
- Total participation of in : every entity of appears in at least one relationship of (an existence dependency). Double line.
- Partial participation: some entities of may appear in no relationship. Single line.
Cardinality is an upper bound and participation is a lower bound. Together they form the (min, max) pair of each entity set in each relationship.
Weak entity sets
A weak entity set has no key of its own. Its entities are identified only through an identifying (owner) entity set and a partial key (discriminator) that distinguishes the weak entities belonging to one owner. Rules:
- The identifying relationship is many-to-one from the weak set to the owner (each weak entity has exactly one owner).
- The weak entity set participates totally in the identifying relationship.
- The key of a weak entity set is (key of owner, partial key). The partial key is underlined with a dashed line.
Example: SECTION with partial key sec_no is weak, owned by COURSE. Section 1 of course CS301 and section 1 of course CS302 are different sections; sec_no alone is not unique, but (course_id, sec_no) is.
How it works: reading a diagram

Read Figure 1 line by line:
STUDENThas keyroll_no, compositename(first,last), multivaluedphone, storeddoband derivedage.BELONGS_TOis N:1 fromSTUDENTtoDEPARTMENT; the double line on theSTUDENTside says every student belongs to a department. A department may have no student (single line).OFFERSis N:1 fromCOURSEtoDEPARTMENT, with total participation ofCOURSE.HAS_SECTIONis the identifying relationship of the weak setSECTION(partial keysec_no): 1:N fromCOURSEtoSECTION, total on theSECTIONside.ENROLLSis M:N betweenSTUDENTandSECTIONand carries the attributegrade. The grade belongs to the pair (student, section), not to either entity alone.
Where a relationship attribute can live
An attribute of a 1:1 or 1:N relationship can be moved to an entity set: in a 1:N relationship it moves to the entity set on the N side (each such entity takes part in at most one relationship). In an M:N relationship it cannot move, because one student has many grades and one section has many grades. This is the ER-level reason why an M:N relationship always becomes its own table.
The (min, max) notation and its placement trap
Elmasri and Navathe also write a pair on the line between an entity set and a relationship : each entity of takes part in at least and at most relationships of . So means partial participation, means total participation.
Placement versus the 1:N labels. For BELONGS_TO the (min, max) pair next to STUDENT is (1, 1), because each student has exactly one department, and the pair next to DEPARTMENT is (0, N). The Chen ratio labels are written the other way round: "N" next to STUDENT and "1" next to DEPARTMENT. A ratio label says how many entities on that side can be associated with one entity on the other side; a (min, max) pair says how many relationships one entity on its own side takes part in. Mixing the two conventions reverses the cardinality.
Algorithms and pseudocode
Two counting procedures recur.
Key of a binary relationship set. Let and be the primary keys of and .
RELATIONSHIP-KEY(R between A and B)
if R is M:N then return K_A union K_B
if R is N:1 from A to B then return K_A // each a has at most one b
if R is 1:N from A to B then return K_B
if R is 1:1 then return K_A or K_B (either is a candidate key)The rule follows from the definition: in an N:1 relationship from to , a given occurs in at most one pair, so alone identifies the pair.
Key of a ternary relationship set. Without cardinality constraints the key is the union of the three keys. If the relationship is "many" on two sides and "one" on the third (each pair determines at most one ), the key is .
Mathematical explanation
A binary relationship set is a relation . With and :
- M:N allows any subset, so , and there are possible relationship sets.
- N:1 from to is a partial function : , and there are possible relationship sets (each picks one of partners or none).
- 1:1 is a partial injection: .
- Total participation of adds for N:1 (every appears, each at most once, so exactly) and in general for any ratio.
Total participation on both sides of a 1:1 relationship forces : each side needs at least as many partners as entities, and partners are unique.
Worked examples
Example 1: sizes of relationship sets. Let and .
- M:N: at most pairs; possible relationship sets.
- N:1 from to : at most 3 pairs; possible sets.
- 1:N from to (each has at most one ): at most 4 pairs; possible sets.
- 1:1: at most pairs. Counting all partial injections from to gives possible sets.
- 1:N from to with total participation of : exactly 4 pairs (every has exactly one ), possible sets.
Example 2: keys of the relationship sets of Figure 1.
| Relationship | Ratio | Key of the relationship set |
|---|---|---|
BELONGS_TO | N:1 from STUDENT | roll_no |
OFFERS | N:1 from COURSE | course_id |
HAS_SECTION | identifying, 1:N from COURSE | (course_id, sec_no) |
ENROLLS | M:N | (roll_no, course_id, sec_no) |
The key of ENROLLS has three attributes because the key of the weak set SECTION is itself (course_id, sec_no).
Example 3: a ternary relationship is not three binaries. SUPPLIES(supplier, part, project) records which supplier supplies which part to which project. Take the instance . Its three binary projections are , and . Joining the three projections gives 4 triples, including , which never happened. So the ternary relationship carries information that the three binary relationships lose.
Example 4: is it weak? PAYMENT(installment_no, amount) of a LOAN(loan_no). Installment number 3 exists for every loan, so installment_no is not unique by itself. PAYMENT is weak with partial key installment_no, owner LOAN, key (loan_no, installment_no). If payments carried a globally unique payment_id, PAYMENT would be a strong entity set with a 1:N relationship to LOAN.
Important properties and observations
- A weak entity set always has total participation in its identifying relationship; the converse is false.
STUDENTparticipates totally inBELONGS_TObut is strong, becauseroll_nois a key. - The identifying relationship is never M:N from the weak side: one weak entity has exactly one owner.
- A relationship set has no duplicate tuples. The same student cannot be enrolled twice in the same section through
ENROLLS. To record repeated events (attempts, visits), represent a distinguishable event entity/role, possibly weak and identified by the participants plus an event discriminator; a relationship attribute alone does not distinguish duplicate participant tuples. - Recursive relationships need roles.
SUPERVISESbetweenEMPLOYEEandEMPLOYEEhas roles supervisor and supervisee; a 1:N recursive relationship maps to one extra foreign key column in the same table. - Derived attributes are not stored; multivalued attributes cannot be stored in one column of a relation in first normal form, which is why they become separate tables.
- Attribute or entity? If a property has its own properties or is shared by several entities (a department name with a building and budget), model it as an entity set.
Related material. The extended ER model adds specialisation and generalisation (superclass and subclass entity sets, disjoint or overlapping, total or partial) and aggregation (treating a relationship as an entity so it can take part in another relationship). They map to relations by the options listed in Mapping ER Diagrams to Relations.
Common misconceptions.
- "Total participation means one-to-one." No: total participation is a minimum (at least one); the ratio is a maximum.
- "The partial key is a key." No: it is unique only among the weak entities of one owner.
- "A relationship attribute of a 1:N relationship must stay on the relationship." It may move to the N-side entity set.
GATE examination perspective
- Constraint reading. Given an ER diagram with double lines, arrows or (min, max) pairs, state which entity is on the "one" side. Check which convention is used before reading the labels.
- Minimum number of tables. This is a count after mapping; the deciding facts are M:N relationships, multivalued attributes and weak entity sets (worked in Mapping ER Diagrams to Relations).
- Keys of relationship sets. M:N gives the union of keys; N:1 gives the key of the many side; weak entities contribute the owner key plus the partial key.
- Counting instances. Maximum or minimum number of relationship instances from entity-set sizes and constraints, as in Example 1.
- Ternary versus binary. Whether three binary relationships can replace a ternary one: in general no.
Summary
Sources
- A. Silberschatz, H. F. Korth, S. Sudarshan, Database System Concepts, 7th ed., McGraw-Hill, 2019 (2020 copyright), Chapter 6: 6.2 The Entity-Relationship Model, 6.3 Complex Attributes, 6.4 Mapping Cardinalities, 6.5 Primary Key, 6.8 Extended E-R Features.
- R. Elmasri, S. B. Navathe, Fundamentals of Database Systems, 7th ed., Pearson, Chapter 3: 3.3 Entity Types, Entity Sets, Attributes, and Keys; 3.4 Relationship Types, Relationship Sets, Roles, and Structural Constraints; 3.5 Weak Entity Types; 3.9 Relationship Types of Degree Higher than Two.