By the end of this chapter you'll be able to…

  • 1Distinguish simple, composite, single-valued, multi-valued, derived and key attributes
  • 2Separate cardinality constraints from participation constraints and read them from an English statement
  • 3Identify a weak entity set, its discriminator, and the composite key it receives
  • 4Explain why a ternary relationship is not equivalent to three binary relationships
  • 5State the disjoint and total constraints on a specialisation hierarchy
  • 6Apply all seven ER-to-relational mapping rules and count the resulting tables
  • 7Distinguish superkey, candidate key, primary key and foreign key precisely
  • 8Count superkeys for one candidate key and for several using inclusion-exclusion
  • 9Choose which side of a one-to-one relationship carries the foreign key and justify it
  • 10Name the ER constraints that no relational schema can express and how they are enforced instead
💡
Why this chapter matters in GATE
The ER model can state constraints the relational model cannot, so design is about deciding which survive the translation into tables and which must be enforced by triggers. GATE asks this concretely: how many tables an ER diagram needs, how many superkeys a relation has, and where a foreign key belongs in a one-to-one relationship.

Before you start — revise these

🔗
Basic set notation, including subsets and the size of a power set
🔗
The idea of a table with named columns
🔗
Familiarity with the notion of uniqueness in a list of records

ER Model & Relational Model

Database design begins with a description of the world and ends with a set of tables, and the two are not the same kind of thing.

The organising fact is that the ER model can express constraints the relational model cannot. An ER diagram says every loan must have a customer, that a dependant cannot exist without an employee, that a manager manages exactly one department. A relational schema knows only tables, columns, keys and foreign keys.

Design is therefore about which constraints survive the translation and which must be enforced somewhere else, by an assertion, a trigger, or application code.

The second organising fact is that the number of tables is decided by the relationship's cardinality, not by the number of boxes in the diagram. A many-to-many relationship needs its own table; a one-to-many does not.

The third is that a key is a statement about all possible instances, not about the data currently present. A column that happens to be unique today is not a key unless the world guarantees it always will be.

1. Entities and Attributes

An entity is a thing distinguishable from other things; an entity set is a collection of entities of the same type, drawn as a rectangle.

Attributes are properties of entities, drawn as ellipses, and five distinctions matter.

Simple attributes are atomic; composite attributes decompose, as an address decomposes into street, city and postal code.

Single-valued attributes hold one value; multi-valued attributes hold several, as a person may have several phone numbers, drawn with a double ellipse.

Derived attributes are computed from others, as age is computed from date of birth, drawn with a dashed ellipse. They are stored nowhere.

A key attribute uniquely identifies an entity and is underlined.

A null value means one of three quite different things: the value is unknown, the value does not exist, or the value is not applicable. The relational model does not distinguish them, which is a well-known weakness.

2. Relationships, Cardinality and Participation

A relationship associates two or more entities, drawn as a diamond, and its degree is the number of participating entity sets.

The cardinality ratio bounds how many entities of one set may relate to one entity of another. Four cases exist: one-to-one, one-to-many, many-to-one and many-to-many.

Participation says whether every entity must take part. Total participation, drawn with a double line, requires every entity of the set to appear in at least one relationship instance. Partial participation does not.

These two are independent and are frequently confused. Cardinality limits how many; participation requires at least one.

Relationships may have their own attributes. A works-on relationship between employee and project carries hours, which belongs to neither entity alone.

A recursive relationship relates an entity set to itself, and then each side needs a role name, as an employee supervises other employees.

Ternary Relationships

A relationship of degree three relates three entity sets at once, and it is not generally replaceable by three binary relationships.

Consider a supplies relationship among Supplier, Part and Project, recording that a particular supplier supplies a particular part to a particular project.

Three binary relationships would record that a supplier supplies a part, that a supplier serves a project, and that a project uses a part. All three can be true without the ternary fact holding, because the supplier might supply that part only to a different project.

Information is lost in the decomposition, which is why the ternary diamond is kept.

The cardinality notation also changes meaning. Writing "one" on the Project side of a ternary relationship means that a given supplier and part combination relates to at most one project, not that a project relates to at most one of anything.

A ternary relationship always maps to its own table, holding all three primary keys, with the combination determined by the cardinality constraints as the key.

3. Weak Entity Sets

A weak entity set has no key of its own and depends on another entity for identification, drawn with a double rectangle.

The identifying or owner entity set supplies the missing identification through an identifying relationship, drawn with a double diamond.

The discriminator, or partial key, distinguishes weak entities belonging to the same owner and is underlined with a dashed line.

A weak entity always has total participation in its identifying relationship, because it cannot exist without an owner. That is what weak means.

The primary key of a weak entity set is the owner's primary key together with the discriminator.

The standard example is a dependant identified by an employee's number plus the dependant's name, since two employees may each have a dependant called Rahul.

4. Extended Features

Specialisation forms subgroups within an entity set, moving top-down from a general entity to more specific ones. Generalisation is the same relationship viewed bottom-up.

Two constraints apply to each such hierarchy.

Disjoint versus overlapping says whether an entity may belong to more than one subclass.

Total versus partial says whether every superclass entity must belong to some subclass.

Attribute inheritance flows downward: a subclass has all the superclass attributes plus its own, and participates in all the superclass relationships.

Aggregation treats a whole relationship as a single higher-level entity, so that another relationship can relate to it. It is needed when a relationship must itself participate in a relationship, which the basic model forbids.

The standard example has an employee working on a project at a branch, and a manager evaluating that whole assignment. The evaluation relates a manager to a works-on instance, not to any single entity, so works-on is aggregated into a box and the evaluation diamond attaches to that box.

A category, or union type, is the reverse of specialisation. It is a subclass whose members come from any of several superclasses, as an account owner may be either a person or a company. Its members inherit only from whichever superclass each belongs to, which is why it is drawn with a circle marked with a set union symbol.

5. The Relational Model

A relation is a set of tuples over a fixed set of attributes, each attribute drawn from a domain.

Being a set has two consequences that examiners test. There are no duplicate tuples, and there is no order among tuples or, formally, among attributes.

Actual SQL tables are multisets, not sets, permitting duplicates unless a key forbids them, which is one of the places practice departs from theory.

A schema is the description and an instance is the contents. The schema names the attributes and their domains and changes rarely; the instance is the set of tuples present at a moment and changes constantly.

Degree, or arity, is the number of attributes, and cardinality here means the number of tuples, which is an unfortunate clash with the ER sense of the word.

The key definitions form a hierarchy.

A superkey is any set of attributes that uniquely identifies a tuple.

A candidate key is a minimal superkey, meaning no proper subset of it is a superkey.

The primary key is the candidate key chosen by the designer, and the others become alternate keys.

A foreign key is a set of attributes referencing the primary key of some relation, possibly the same one.

Three integrity constraints are built into the model. Domain integrity requires each value to belong to its attribute's domain. Entity integrity forbids a null in any part of a primary key. Referential integrity requires every foreign key value either to be null or to match an existing primary key value.

Referential integrity also specifies what happens when the referenced row is deleted or updated. Cascade propagates the change to the referencing rows. Set null replaces the foreign key with a null, which is impossible if it is part of a primary key. Restrict, the default, refuses the operation outright.

A weak entity's foreign key must cascade, since the dependent row has no meaning without its owner and cannot be set to null.

6. Mapping ER to Relations

Seven rules cover the translation, and knowing them in order is worth several marks.

A strong entity set becomes a table with its attributes, and its key becomes the primary key.

A weak entity set becomes a table containing its own attributes plus the owner's primary key as a foreign key, with the combination of that foreign key and the discriminator as the primary key.

A many-to-many relationship becomes its own table, holding the primary keys of both participants plus any relationship attributes. The pair of foreign keys is the primary key.

A one-to-many relationship needs no table. The primary key of the one side is added to the table on the many side as a foreign key, along with any relationship attributes.

A one-to-one relationship can be merged into either side, and the better choice is the side with total participation, because that avoids nulls.

A multi-valued attribute becomes its own table, holding the owning entity's primary key plus the attribute, with both together as the primary key.

Specialisation has three options: one table per subclass plus one for the superclass; one table per subclass carrying inherited attributes, which works only for total and disjoint hierarchies; or one wide table with nulls and a type discriminator.

Composite attributes are simply flattened into their component columns, and derived attributes are not stored at all.

7. Worked Examples

Example 1. An ER diagram has entity sets Student, Course and Instructor. Student enrols in Course as many-to-many with an attribute grade. Instructor teaches Course as one-to-many. What is the minimum number of tables?

Apply the rules one at a time.

Student is a strong entity set, so it becomes a table. Course becomes a table. Instructor becomes a table. That is three.

The enrols relationship is many-to-many, so it needs its own table holding the student key, the course key and grade, with the pair of keys as the primary key. That is four.

The teaches relationship is one-to-many from Instructor to Course, so it needs no table. The instructor's key is added to Course as a foreign key.

The answer is four tables.

The general principle worth extracting: entity sets always cost a table, many-to-many relationships always cost a table, and one-to-many and one-to-one relationships never do.

Example 2. Classify each of the following and give the ER notation: a customer must have at least one account; an account belongs to exactly one branch; an employee may supervise many employees.

"A customer must have at least one account" is a participation constraint, not a cardinality one. It says total participation of Customer in the has relationship, drawn with a double line.

It does not limit how many accounts, so the cardinality on that side is many.

"An account belongs to exactly one branch" is both. The cardinality is many-to-one from Account to Branch, and the word "exactly" adds total participation of Account.

"An employee may supervise many employees" is a recursive relationship on Employee with two roles, supervisor and supervisee.

The word "may" signals partial participation, since some employees supervise nobody, and every employee except the top one has exactly one supervisor, making it one-to-many.

The lesson is that phrases like must and at least give participation, while exactly one and at most give cardinality.

Example 3. Map a weak entity set Dependant, with discriminator name and attribute relationship, owned by Employee with primary key empId, through an identifying relationship.

Dependant becomes a table.

It carries its own attributes, name and relationship, plus the owner's primary key empId as a foreign key.

The primary key is the pair (empId, name), because name alone cannot identify a dependant across the whole company but is enough within one employee's family.

The foreign key empId references Employee, and it must be declared with cascading delete, since a dependant cannot outlive its owner.

No separate table is created for the identifying relationship. A weak entity's identifying relationship is always many-to-one from the weak side, so it is absorbed exactly as any one-to-many relationship is.

Contrast with a strong entity holding the same data. If Dependant had its own dependantId, it would still be one table, but the primary key would be dependantId alone, and deleting an employee would leave orphans unless referential integrity forbade it.

Example 4. A relation has attributes and is the only candidate key. How many superkeys does have?

A superkey is any set containing a candidate key, since adding attributes to a key preserves uniqueness.

Every superkey must therefore contain both and .

The remaining attributes , and may be included or not, freely.

That gives superkeys: , , , , , , , .

The general formula is where is the number of attributes and is the size of the single candidate key.

The formula breaks when there are several candidate keys, because sets containing both keys would be counted twice, and inclusion-exclusion is needed.

For instance, if and were both candidate keys on the same five attributes, the count is those containing , plus those containing , minus those containing both: .

Example 5. A one-to-one relationship connects Employee and Department through manages, with Department having total participation and Employee partial. Where should the foreign key go, and why?

Either side is legal, since a one-to-one relationship can be merged into either table.

Put the foreign key on Department, the side with total participation.

The reason is nulls. Every department has a manager, so every row of Department will have a value in that column, and the column can be declared not null.

If instead the foreign key sat on Employee, then every employee who is not a manager would carry a null, and since most employees manage nothing, the column would be overwhelmingly null.

A unique constraint is required either way, because without it the schema would permit one employee to manage several departments, which the one-to-one cardinality forbids.

The general rule: merge a one-to-one relationship into the side with total participation, and always add a uniqueness constraint on the foreign key.

Example 6. Which ER constraints cannot be expressed in a pure relational schema, and how are they enforced?

Cardinality on the many side of a many-to-many relationship cannot be expressed. A schema cannot say a student enrols in at most six courses; the relationship table accepts any number of rows.

Total participation of the referenced side cannot be expressed by a foreign key. A foreign key on Account referencing Branch guarantees every account has a branch, but nothing guarantees every branch has an account.

The asymmetry is worth stating clearly. A foreign key enforces total participation on the side holding the key, and says nothing about the side referenced.

Disjointness in a specialisation cannot be expressed if the mapping uses one table per subclass, since nothing prevents the same key appearing in two of them.

Three enforcement mechanisms exist beyond the schema. An SQL assertion states a condition over the whole database and is checked on every change, though few systems implement it. A trigger runs procedural code on insert, update or delete and is what real systems use. Application-level checks are the weakest, since another program can bypass them.

The design consequence is that a schema alone is not a specification. The ER diagram remains the authoritative statement of what the world requires, and the schema is a partial implementation of it.

Summary

The ER model expresses constraints the relational model cannot, so design is about deciding which survive translation and which must be enforced by assertions, triggers or application code.

Attributes are simple or composite, single or multi-valued, and derived attributes are never stored. A null conflates unknown, non-existent and inapplicable.

Cardinality bounds how many; participation requires at least one. They are independent, and words like must and at least signal participation while exactly one signals cardinality.

A weak entity has no key of its own, always participates totally in its identifying relationship, and takes the owner's primary key plus its discriminator as its key.

Specialisation carries disjoint-or-overlapping and total-or-partial constraints, and attributes and relationships inherit downward. Aggregation exists so a relationship can itself participate in a relationship.

A relation is a set, so it has no duplicates and no order, though SQL tables are multisets. A superkey identifies uniquely, a candidate key is a minimal superkey, and the primary key is the chosen candidate. Domain, entity and referential integrity are built in.

In mapping, entity sets always cost a table and many-to-many relationships always cost a table, while one-to-many and one-to-one relationships never do. A multi-valued attribute costs a table. A one-to-one relationship should merge into the side with total participation, with a uniqueness constraint added.

With a single candidate key of size among attributes there are superkeys, and several candidate keys require inclusion-exclusion.

A foreign key enforces total participation only on the side holding it, which is why triggers exist.

Key formulas & results

Everything to memorise for the exam hall, in one card. Screenshot this for revision.

The organising principle
the ER model expresses constraints the relational model cannot
Design decides which constraints survive translation into tables and which must be enforced by assertions, triggers or application code.
Cardinality versus participation
cardinality bounds how many; participation requires at least one
They are independent. Words like must and at least give participation; exactly one and at most give cardinality.
Weak entity key
primary key of weak entity = owner's primary key plus discriminator
A weak entity always has total participation in its identifying relationship, because it cannot exist without an owner.
Table counting rule
entity sets always cost a table; many-to-many relationships always cost a table; one-to-many and one-to-one never do
Multi-valued attributes also cost a table. This rule answers most minimum-table questions directly.
Superkey count, single candidate key
2 to the power (n minus k), for n attributes and one candidate key of size k
Every superkey contains the candidate key, and the remaining attributes are freely included or excluded.
Superkey count, several candidate keys
inclusion-exclusion over the sets of supersets of each candidate key
With keys AB and CD among five attributes: 8 plus 8 minus 2, which is 14.
Key hierarchy
superkey is unique; candidate key is a minimal superkey; primary key is a chosen candidate key
Minimality is what separates a candidate key from a superkey, and it means no proper subset is also unique.
One-to-one placement rule
merge into the side with total participation and add a uniqueness constraint
Total participation guarantees the column is never null, and uniqueness is what actually enforces the one-to-one cardinality.
Foreign key asymmetry
a foreign key enforces total participation only on the side that holds it
Every account having a branch is enforceable; every branch having an account is not, and needs a trigger.
⚠️

Traps GATE sets — and how to dodge them

These are the exact option-traps and misreads that cost marks under negative marking.

WATCH OUT
Reading a double line as a cardinality constraint
The double line is total participation, meaning every entity must appear at least once. Cardinality is written separately as 1 or N on the edge.
Why it happens: Both notations sit on the same edge of the diagram, so they are easy to conflate.
WATCH OUT
Creating a separate table for a one-to-many relationship
Add the one side's primary key as a foreign key on the many side. Only many-to-many relationships need their own table.
Why it happens: The relationship has a diamond, so it looks like it deserves its own box.
WATCH OUT
Giving a weak entity its own single-attribute primary key
The discriminator is only unique within one owner. The primary key is the owner's key together with the discriminator.
Why it happens: The discriminator looks like a key because it is underlined, though with a dashed line.
WATCH OUT
Replacing a ternary relationship with three binary ones
All three binary facts can hold without the ternary fact holding. Keep the ternary diamond and map it to a table with all three keys.
Why it happens: Binary relationships are more familiar and the decomposition looks lossless.
WATCH OUT
Using 2 to the power n minus k when there are several candidate keys
Count supersets of each key and subtract the overlaps by inclusion-exclusion, since sets containing two keys would otherwise be double counted.
Why it happens: The formula is memorised without its condition, and questions often give more than one key.
WATCH OUT
Calling any uniquely-valued column a candidate key
A key is a claim about every possible instance. If the world permits a duplicate, the column is not a key regardless of the current rows.
Why it happens: Uniqueness is checked against the sample data shown in the question.
WATCH OUT
Believing a foreign key enforces participation on both sides
It constrains only the referencing side. Requiring every referenced row to be referenced needs an assertion or trigger.
Why it happens: The constraint links two tables, so it appears symmetric.
WATCH OUT
Storing a derived attribute as a column without saying so
Derived attributes are computed, not stored. If the design chooses to store one anyway, it must state how it will be kept consistent.
Why it happens: It appears in the diagram like any other attribute, in a dashed ellipse that is easily missed.

Exam-pattern practice

PYQ-style questions with full solutions. Work through them as a readiness check — mark yourself honestly and get your gap report at the end.

Readiness check

Are you exam-ready for ER Model & Relational Model?

10 problems from this chapter. Try each one, reveal the worked solution, mark yourself honestly — get your gap report at the end.

10 questions~7 min

5-minute revision

The whole chapter, distilled. Read this the night before the exam.

  • The ER model expresses constraints the relational model cannot; design decides which survive
  • Derived attributes are never stored; composite attributes flatten into columns
  • A null conflates unknown, non-existent and inapplicable
  • Cardinality bounds how many; participation requires at least one; they are independent
  • Must and at least signal participation; exactly one and at most signal cardinality
  • A weak entity has total participation in its identifying relationship by definition
  • Weak entity key = owner's key plus discriminator
  • A ternary relationship is not three binary relationships, and always gets its own table
  • Specialisation carries disjoint-or-overlapping and total-or-partial constraints
  • Aggregation lets a relationship participate in another relationship
  • A relation is a set, so no duplicates and no order; SQL tables are multisets
  • Superkey unique, candidate key minimal, primary key chosen, foreign key references
  • Domain, entity and referential integrity are built in; referential actions are cascade, set null and restrict
  • Entity sets and many-to-many relationships always cost a table; one-to-many and one-to-one never do
  • Multi-valued attributes cost a table
  • Merge a one-to-one into the totally participating side and add a uniqueness constraint
  • Superkeys with one candidate key of size k among n attributes: 2 to the (n minus k)
  • A foreign key enforces participation only on the side holding it

GATE question blueprint

How this topic is asked, tier by tier — so you can prep to the pattern.

Typical weightage: 4

Question styleMarks eachTypical countWhat it tests
ER to relational mapping21
Relational model and keys11
Cardinality and participation11

Exam-hall strategy

Battle-tested tips from mentors and toppers for this topic under the sectional clock.

  1. For minimum-table questions, list the entity sets first, then add one table per many-to-many relationship and one per multi-valued attribute, and explicitly note that one-to-many relationships add only a foreign key. Watch for the word minimum, which permits merging one-to-one entity sets. For superkey counting, first establish how many candidate keys there are, since the simple power formula only applies to one. Read English constraint statements twice, separating the how-many clause from the at-least-one clause. If a question asks what a schema cannot enforce, the answer is almost always participation on the referenced side or an upper bound on a many side.

Beyond the exam

Where this skill shows up in the job you're competing for — and in life.

Object-relational mappers such as Hibernate and Django im…

Object-relational mappers such as Hibernate and Django implement exactly these mapping rules, and their inheritance strategies are the three specialisation options under different names

Data warehouse star schemas deliberately violate the mapp…

Data warehouse star schemas deliberately violate the mapping rules by denormalising dimensions, trading update anomalies for query speed on read-only data

Graph databases exist because ternary and higher-degree r…

Graph databases exist because ternary and higher-degree relationships are awkward in tables, and traversal queries over them are expensive as joins

Every migration tool must decide referential actions

Every migration tool must decide referential actions, and a cascade delete chosen carelessly in production is one of the classic ways to lose data

Schema documentation in regulated industries still uses E…

Schema documentation in regulated industries still uses ER diagrams because auditors need the constraints, not just the columns

Where else this topic is tested

Prepare once, score in every exam that asks it.

GATE CS
GATE DA
UGC NET Computer Science
ISRO Scientist SC
BARC Computer Science

Questions aspirants ask

Pulled from the Q&A community and mentor sessions.

It is the specification, not the implementation, and it stays useful after the schema exists precisely because it records constraints the schema drops. When a later change asks whether every branch must have an account, the diagram answers and the schema cannot.

Because the alternative is worse. Without nulls, a missing value forces either a sentinel that could collide with real data or a separate table for every optional attribute. The cost is three-valued logic in comparisons and the conflation of three different kinds of absence.

When the subclasses share most attributes and queries usually span all of them, since one table avoids joins entirely. It is a poor choice when subclasses differ sharply, because most columns are then null for most rows and no constraint prevents a row from carrying attributes of the wrong subclass.

The relationship table's key is derived from the participants. For a many-to-many binary relationship it is the pair of foreign keys; adding a surrogate identifier is an implementation convenience that does not change the logical key, and the original pair must still be declared unique.

Ask whether it has properties of its own or participates in relationships. A city stored only as a name is an attribute; a city with a population, a state and a set of branches is an entity. The same real-world thing can be either, depending on what the application needs to know about it.

Yes, and this is what makes the question interesting. Two entity sets in a one-to-one relationship with total participation on both sides can legitimately be merged into a single table, which is why exam questions usually say minimum rather than asking for the standard mapping.
Header Logo