Candidate Keys, ER-to-Relational Mapping, and Normalization Revision
Prerequisite Knowledge
This lecture builds on the following concepts from earlier lectures. If any feel unfamiliar, review the linked notes before proceeding.
Previously Covered in This Subject
- Keys: super keys, candidate keys, and primary keys — covered in Lecture 2
- Cardinality ratios, and total versus partial participation — covered in Lecture 2
- From ER diagram to relational schema — covered in Lecture 3
- Functional dependencies — covered in Lecture 4
- The normalization process: 1NF, 2NF, 3NF, BCNF — covered in Lecture 4
- Attribute closure and Armstrong's rules (F+ and X+) — covered in Lecture 5
- FD-set equivalence and minimal covers — covered in Lecture 5
- Relational algebra: union, intersection, and set difference — covered in Lecture 7
- SQL IN and NOT IN — covered in Lecture 8
This session is a full revision pass driven by quiz questions and an old question paper. It covers how a primary key is actually chosen, how to read the "one" and "many" sides of an ER diagram, how to map a one-to-many relationship with total participation into relations, why we normalize at all, the exact definitions of 1NF, 2NF, 3NF and BCNF, how to find candidate keys using closure, how to check FD-set equivalence, and how to answer relational-algebra and SQL questions. Everything is interleaved with extended student Q&A, because the biggest confusions of the course live here.
The session moves in the professor's order: the three quiz questions open the discussion, the old paper's questions drive the rest, and the exam guidance at the end collects what is being fixed in the answer keys and what is expected of you in the exam hall.
9.1 Choosing a Primary Key from Candidate Keys
9.1.1 The Quiz Question and Its Four Options
Hook — a quiz that everyone got right, whatever they marked. A quiz question asked: "A primary key is chosen from the set of candidate keys mainly based on …" with four options: (1) the number of attributes it contains, (2) its ability to uniquely identify tuples in a relation without redundancy, (3) the alphabetical order of the attributes' names, (4) whether its data type is numeric or string. One student argued for the number of attributes, on the grounds that the choice "depends completely on the administrator." The professor's resolution surprised everyone: all four answers are correct — and so is anything else you could imagine.
Q: Shouldn't the answer be "the number of attributes it contains"? If I am taking a primary key from a set of candidate keys, it depends completely on the administrator. A: We have a set of candidate keys — maybe three, four, five, or six of them. The administrator can take whatever decision the administrator wants to take. The administrator may decide on the number of attributes — larger or lesser. Of course that is one way, but it is redundant reasoning, because it is a candidate key first of all — it can be anything. This is really at the prerogative of the database administrator. So in this question all four answers are correct: whatever you have marked is correct for every one of you, since we are choosing one of the candidate keys from that set to be a primary key. And beyond that, it can be anything — the administrator may decide to use a candidate key based on his or her preference, which can be completely non-justifiable to any third person.
Q: I still want to understand why "number of attributes" is actually a correct answer. A: The correct answer is all four of them. If you have marked any of them, it is a correct answer. It is not just the number of attributes: it can be the first one, the second one, the third one, the fourth one, or any other type as well. The options will be updated very soon, but the idea is that if you have a set of candidate keys, you can choose the primary key based on the number of attributes, on alphabetical order, on numeric or string data type, or anything else.
Both questions ask the same thing — "why is option 1 also right?" — so they collapse into one canonical Q&A: any criterion, including none at all, is legitimate, because the choice belongs to the administrator.
9.1.2 What This Tells You About Keys
Two definitional facts make the discussion sharp. A candidate key (a minimal set of attributes that uniquely identifies every tuple; there can be many in a relation) and a primary key (the one candidate key the database administrator picks out of that set) differ only in the act of picking. Because every candidate key already satisfies the job of unique identification, any of them can be chosen as the primary key — the "ability to uniquely identify tuples without redundancy" is not a distinguishing criterion among candidate keys; it is the property they all share. Similarly, the number of attributes, the alphabetical order of names, and the data type are all acceptable tie-breaking preferences, but none of them is a rule.
The deep point the professor wants preserved: picking a primary key is an administrative decision, and it may be one that no third party can justify. In real databases, the choice is guided by practical needs — smallest key, stable values, fastest lookups — but formally, anything in the candidate-key set works.
Assumption & scope: "Any candidate key works" is a statement about uniqueness and identification, not about performance. Every candidate key identifies tuples; but different candidate keys give different lookup speeds (a numeric 4-byte key is faster to compare than a 50-character string key), different stability (a birth date never changes, a phone number does), and different storage footprints. The administrator weighs these practical factors. What the quiz means is: nothing in the relational model forces one candidate key over another.
Visual intuition: picture a shelf of candidate keys — A alone, CD, E, BC — each with a tag saying "uniquely identifies every row." The primary key is just the one the administrator lifts off the shelf. The remaining candidates do not stop being keys; they remain usable for indexing, joins, and unique constraints.
Pitfalls:
- Thinking "fewest attributes wins" is a rule — it is a preference. A one-attribute candidate key is not automatically the primary key.
- Confusing "candidate key" with "primary key" in answers: candidate keys are the set; the primary key is one designated member.
- Believing the primary key choice must be justified to anyone — the professor's point is that it may be a pure prerogative, though good design practice does give reasons.
Recap + bridge: A primary key is chosen from the candidate-key set, and the choice is the administrator's prerogative — any criterion (or none) is formally acceptable. This is why the quiz is being keyed "all correct." With key vocabulary set, the session moves to the question that confuses students far more: how to read which side of a relationship is "one" and which is "many."
Real-world & domain connection: Primary-key selection is a daily decision in database administration. When a schema offers several natural keys (employee ID, email, Aadhaar-style national ID, phone), a DBA picks one — often the smallest, most stable, and fastest to index — and design tools and textbooks treat the candidates as equal alternatives precisely because the choice is administrative. A poorly chosen primary key (a mutable phone number, a huge string) creates real costs: slower indexes, cascade-update chains, and brittle foreign keys. The professor ties this to the rest of the course: candidate keys, super keys, and prime attributes return in every normalization definition from 2NF to BCNF.
Exam note: every option of this question is being marked correct, and the answer key will be updated. If you marked any one of the four, you got it right.
9.2 Reading a "One-to-Many" Relationship
9.2.1 The Diagram-Reading Rule
Hook — why the diagram that looks obvious is the one that started the longest debate. The session's second discussion began from a quiz about mapping one-to-many relationships, and the professor's own first diagram turned out to be drawn the wrong way around. Reading the "one" and "many" labels correctly turned out to be the biggest confusion point of the course — worth the full re-explanation arc that follows.
The rule, stated simply: the entity on the side marked "one" can be related to at most one entity on the other side; the entity on the side marked "many" can be related to many entities on the other side. The "one" is an "at most one" — an entity on the one side may even be related to zero entities on the other side. The "many" side means "at most many," so zero is allowed there too.
The professor draws two "bags" (entity sets) X and Y connected by a relationship. If the diagram is read as "X to Y is one-to-many," then X is the one side: any entity in the X bag has a relationship with at most one entity in the Y bag (possibly none). Meanwhile, any entity in the Y bag can have a relationship with many entities in the X bag. In the ER diagram, the "one" label goes on one side of the relationship diamond and the "many" label on the other — one on this side, many on the other side.
Total participation changes the minimum, not the maximum: when X has total participation in a relationship, every entity of X must participate — it is impossible for an X entity to sit out of the relationship. In the diagrams used here, total participation is shown with a double line next to the entity.
9.2.2 The Bag Example: Students and Mentors
The example that made this concrete: a bag of 85 students and a bag of 20 mentors, with a relationship "student is mentored by mentor." Reading the one-to-many side:
- Each student can have at most one mentor. A student with no mentor is fine — "at most one" allows zero.
- Each mentor can have many students — say, several of the 85 students.
So "student to mentor is one-to-many" means a student has at most one mentor, and a mentor has many students. The same example with different roles: in a student–advisor relationship, one student can have at most one advisor, while an advisor can advise many students.
Worked reading — 85 students, 20 mentors. Draw two bags: STUDENT (85 dots) on the left, MENTOR (20 dots) on the right. Connect them with a relationship diamond labeled MENTORED_BY. The "1" label sits on the MENTOR side, the "N" (many) label on the STUDENT side. Reading rules:
- Take any single student (say, student 17): follow the lines outward — at most one mentor line comes out of it. Student 17 has one mentor, or none.
- Take any single mentor (say, mentor 3): lines from many students point at it. Mentor 3 could mentor 4 students, 12 students, or any subset of the 85.
Now reverse the reading to test your understanding: "an advisor advises many students; a student has at most one advisor" — the advisor bag is the many side, the student bag is the one side. If instead every student must have a mentor, the STUDENT side gains total participation: the "at most one" maximum stays, but the minimum rises from zero to one. Sense-check: one-to-many always contains a one (at most one) and a many (zero or more) — the numbers 85 and 20 never appear in the labels; they only count how many entities live in each bag.
9.2.3 The Great "One-to-Many vs Many-to-One" Debate
This is the largest and most instructive Q&A of the session, because the students pushed back repeatedly and the professor re-explained from several angles. The full arc matters: question → initial explanation → student disagreement → correction → re-explanation → final agreed reading.
Q: I don't understand how the diagram on the left — the two circles with a line — indicates one-to-many, because we have many X's mapping to one single Y. Shouldn't it be the opposite: one X can have many Y's? A: I think you are right here. You are right. Look at it this way: if there is a student and an advisor, one student can have at most one advisor, however an advisor can advise more than one student. So student-to-advisor is one-to-many: one student has at most one advisor, an advisor has many students. So the diagram we drew — is that correct? Still not convinced? No issues, I will start once again in discussion.
The student spotted that the professor's first drawing was reversed — many X's were mapping to a single Y, which makes the X side the many side. The professor accepted the correction on the spot and re-explained with the student–advisor example.
Q: Okay, a student can be related to at most one mentor, and a mentor can have many students — that part is understood. But then how is that "one-to-many"? That should be "many-to-one" in this case. A: This is a picture from school mathematics — a domain and a co-domain, two bags. A bag of students, say 85 of them, and a bag of mentors, say 20 of them. When I say a student can have at most one mentor, every student can be related to at most one mentor — correct. Now look from the mentor side: a bag of many mentors; a mentor can have many students whom he or she is advising. One mentor is mentoring many students possibly. Under one particular mentor there can be more than one student. So student-to-mentor is one-to-many: the student has at most one mentor, the mentor has many students to mentor.
Here the professor reaches for the school-mathematics picture — a function from a domain bag to a co-domain bag — to explain why the direction matters: read each bag's own constraint, then name the relationship from the pair of constraints.
Q: But many places — I think in the textbook also — it is the reverse. I have posted a screenshot in the chat window; can you look at it? A: I have to look at it. However, this is what one-to-many is: it means at most one. Anyone can verify — has anyone seen this in the material? Can anyone second this student's reading?
Q (second student): The recording said something different from what the PPT said. My understanding has been: "one-to-many" means "at most one" — this is related to "at most one." Is it clear to you that a student can be related to at most one mentor? And "many" means a mentor can have at most many students? That part is clear. What is not understood is how that is "one-to-many" — it should be "many-to-one." A: Fine — let us separate the question from the diagram. Is the concept clear — a student has at most one mentor, a mentor has many students? Yes? Good. Then the only question left is the name.
Note the professor's move at this point: separate the concept (which everyone now agrees on) from the name. When a second student reported that the recorded material also reads "one-to-many" as "at most one," the professor deferred checking the textbook screenshot but committed to the concept: the label "1" means "at most one."
Q: Right — the ambiguity is only about whether it should be called one-to-many or many-to-one. I understand the concept "student to mentor" completely; the confusion is just the naming. A: Fair. Then let me read it across. Here is A and B; this side is one, this side is many, and this is total participation. Which of them will have at most one relationship — A or B? ... B is having at most one, and A is having many. So if I say A to B, then A has many and B has one relationship. Whatever I call it — one-to-many or many-to-one — I represent after that, in plain terms, that B is the one who is having at most one of the relationships. That is what matters.
Q: So if this is X and this is Y, and the diagram shows many on the X side and one on the Y side, you are saying that "X to Y" is equivalent to "many to one" — many X's can have a relationship with a single Y, but each individual X can have at most one Y. Is that how we read it across? A: Yes. Yes, sir. Here this will indicate that many of X can have a relationship with a single Y, but each individual X can have at most one Y. Correct. That is more than fine for you to represent. We should not worry too much about the intermediate nomenclature — how you write it as one-to-many or many-to-one. Whatever you have read in the earlier sessions is the exact correct nomenclature. Read it carefully: X to Y means X is related to Y with at most one, and Y is related to X with many. That is more than fine.
The settled reading: "X to Y" means X is related to Y at most one-to-many — read the pair of constraints on each side, never just the first word.
Comparison — the three cardinality ratios at a glance. The same two bags, X and Y, under each ratio:
| Ratio | X side constraint | Y side constraint | Example |
|---|---|---|---|
| 1:1 | each X at most one Y | each Y at most one X | student–locker |
| 1:N | each X at most one Y | each Y many X's | student–mentor (one side: student; many side: mentor) |
| M:N | each X many Y's | each Y many X's | student–course |
The reference text uses the same reading with l..h bounds: a 1..1 on an edge means "exactly one," a 0..* means "zero or more." The textbook even warns explicitly that the 0..* on one edge is easy to misread as the reverse — exactly the trap the class hit.
When to pick which: choose the ratio by the maximum on each side: a max of 1 on one side and unlimited on the other gives 1:N; the side with max 1 is the "one" side, whatever you decide to call the pair.
9.2.4 What Was Resolved
The professor first drew the diagram, a student spotted that it was drawn the wrong way around, and the professor accepted the correction on the spot — an honest error-correction moment that is itself worth keeping. The settled reading of a diagram marked "1" on the Y side and "many" on the X side: many X's connect to a single Y; each individual X connects to at most one Y. The label "one-to-many" versus "many-to-one" depends on which entity you start from, and the professor explicitly tells students not to lose marks over the naming — the representation of which side is "1" (at most one) and which side is "many" is the part that must be right.
Two mental models are worth holding together:
- From the one side: the entity has at most one relationship (zero allowed).
- From the many side: the entity may have many relationships, and every entity in a total participation set must have at least one.
Pitfalls:
- Reading "one-to-many" as "one X has many Y's" without checking which side the "one" label sits on — the label is a constraint on its own side, not a description of the other side.
- Forgetting that "one" means "at most one" — a student with zero mentors is legal under 1:N unless total participation is drawn.
- Treating "one-to-many" and "many-to-one" as different facts. They are the same fact read from opposite ends; the exam-relevant part is which entity is the one side and which is the many side.
- Adding total participation from memory — it changes the minimum (zero → one), never the maximum.
Recap + bridge: "One-to-many" is a constraint pair — one side holds at most one relationship, the other may hold many. The naming debate was about labels, not facts; the representation of 1 and many is what must be right. This reading rule is used immediately in the next section, where the mapping of a one-to-many relationship into relations depends on knowing exactly which side is "one" and whether that side has total participation.
Real-world & domain connection: Cardinality reading is the skill behind every real schema. A bank that says "a branch belongs to exactly one bank" is a 1:N with total participation on the branch side; a college's "each student has one advisor" is a 1:N with total participation on the student side. Misreading a side means modeling "advisor advises many students" backwards — an error that surfaces later as wrong foreign keys and wrong queries. Tools that generate diagrams, and the (min, max) notation covered later in this session, both encode exactly these per-side constraints.
9.3 Mapping a Binary One-to-Many Relationship with Total Participation
9.3.1 The Quiz Question
Hook — two answers that both look right, and the total-participation clue that decides between them. The second quiz question: "Which of the following statements accurately represents the correct mapping of the ER construct to the relational model for a binary one-to-many relationship with entities X and Y, X being on the one side, Y being on the many side, and X having total participation?" Two answer options carried the discussion:
- Option B: a new association relation is created containing the primary key of both X and Y as foreign keys.
- Option C: the merged form — X's relation and the relationship relation are combined into one, since X has total participation.
9.3.2 The Two-Step Construction
The professor works the mapping in two steps, and the second step is the teaching point.
Step 1 — the separate association relation. Build the relationship relation, call it X_Y. It holds the key of X and the key of Y — both of them foreign keys pointing back to their own entity relations (assuming the relationship carries no attributes of its own). This is option B: a new association relation whose attributes are the primary keys of X and Y as foreign keys. This relation is always correct as an intermediate step.
Inputs & outputs of the mapping. In: a binary 1:N relationship R between entity sets X (one side) and Y (many side), with X's participation total. Out: a relational schema with primary keys and foreign keys. The two candidate designs are:
- Design B (association relation): three relations — X, Y, and X_Y, where X_Y holds the keys of both entities as foreign keys. Always safe; costs an extra relation and an extra join whenever you combine X with its Y.
- Design C (merged): two relations — one merged relation for X plus the relationship, and Y unchanged.
Step 2 — the merge. Because X has total participation, every entity of X appears in the relationship X_Y. The set of X-entities and the set of X-entities inside X_Y are the same set. So merging the X relation with the X_Y relation costs nothing and removes a join: the combined relation contains the key of X, the key of Y (as a foreign key), and the other attributes of X. Because each X has at most one Y, the key of X still uniquely identifies every row, so the primary key of the merged relation is X's key and Y's key enters as a foreign key. The Y relation stays as it is: key of Y plus its own attributes.
The key claim, reconciled with the standard mapping: the merged relation's primary key is X's key. The check is dimensional: each X tuple pairs with at most one Y tuple (the "one" side), so X's key alone still tells every row apart — no two rows share an X key. Y's key is a foreign key: it references Y, and the same Y may appear in many rows.
The general rule the professor states: whenever there is a one-to-many relationship and the one side has total participation, join those relations, because whatever entities exist on the one side also exist in the relationship — the merge is lossless and shrinks the schema (three relations become two).
Worked mapping — a concrete instance. Suppose X = DEPARTMENT, key dept_id; Y = EMPLOYEE, key emp_id; the relationship is "each department has one manager (at most one), each employee manages many departments' worth of relationships" — read as 1:N with DEPARTMENT on the one side and total participation (every department must have a manager).
- Step 1 (option B): DEPARTMENT(dept_id, name, location), EMPLOYEE(emp_id, ename, salary), and MANAGER(dept_id, emp_id) where both columns are foreign keys.
- Step 2 (option C): merge MANAGER into DEPARTMENT: DEPT_MGR(dept_id, name, location, emp_id), with
dept_idthe primary key andemp_ida foreign key to EMPLOYEE. Every department appears — total participation — soemp_idis never null in the merged table; a single manager'semp_idcan repeat across rows (he manages several departments), which is exactly the redundancy that stays.
Sense-check: the merged design answers "who manages department 5?" with one row lookup instead of a join, and no row ever has a null manager — both promised by the total-participation condition.
9.3.3 The Null-Value Worry, Resolved
Q: If we follow the merge, is there not a possibility of null values in the resulting relation? I thought the recommended way — based on my understanding of the earlier sessions — was to create the separate relation for the keys of X and Y, because if we merge, there will be some null values within the new relation. So to avoid those null values, we create a separate relation and have the foreign keys to the original relation. A: Wait — in this case, does X have total participation? Yes. So the nulls cannot appear on the X side: every X is related to Y, so X's key is never null in the merged relation. On the Y side it can be there — sure. But that is exactly why the merge is chosen only for the total-participation side. In a good relational design, and in normalization, we want the least amount of redundancy and the least number of null entries. In the ER-diagram-to-relational portion, this reduces to a very straightforward diagram.
The null worry is real — but only on the other side. Merging the relationship into X is safe precisely because X's total participation means the relationship relation contains every X; the merged table can never hold an X with a blank. Y's key may hold nulls in some rows (a department row for an entity that is not yet tied to any Y — impossible here because of total participation, but possible in general). This is why the general mapping keeps the merge for the total-participation side only.
Q: I understand the easiest representation is what you have suggested. But taking the null thing into consideration, I don't understand how the first scenario — a separate relation — can be wrong. And do you think there are other attributes here in X? Let's say there are. Can an option exist in which other attributes can have null values? Then we keep only the non-null attributes in one relation and put the possibly-null ones in a separate relation. A: Not necessarily. What I am saying is that both the answers are correct. It again depends on the database administrator here, right?
Q (another student): Since X is having total participation, I don't think there will be any null entries at all. A: Absolutely right — null entries will not be there, at least on the X side, for sure, because every X is related to Y.
Q: The textbook also says — for a 1:N relationship — that you have to include the primary key of the one side as a foreign key of the many-side relationship. A: Correct, correct, correct. For that, answer C should be correct. Answer C is correct.
The last exchange ties the professor's merge to the textbook rule: the standard mapping for 1:N places the primary key of the one side as a foreign key inside the many-side relation. The professor's merged design is the same idea expressed as a merge into the one-side relation — the choice is which relation hosts the foreign key, and total participation decides which hosting is null-free.
Assumption & scope — when the merge is allowed, and when it breaks.
- Assumption 1: X's participation is total — every X appears in the relationship. If even one X sits out, the merged table needs a null for that row's Y key, and the merge's advantage over the association relation disappears.
- Assumption 2: the relationship is 1:N with X the one side. With M:N, a merge would duplicate X rows per Y partner and X's key would no longer identify rows — the association relation becomes mandatory.
- Assumption 3: the relationship carries no attributes of its own (or they can ride along). A relationship with rich attributes still maps cleanly in the merged design, but the association relation keeps those attributes closer to the relationship's semantics.
- What breaks if they fail: wrong keys (an M:N merged as 1:N produces duplicate primary keys), or nulls where the design promised none.
Comparison — Design B versus Design C.
| Dimension | B: association relation X_Y | C: merged (total participation) |
|---|---|---|
| Number of relations | 3 (X, Y, X_Y) | 2 (X∪relationship, Y) |
| Nulls | Possible in X_Y if participation partial; none forced | None on the X side, by construction |
| Joins to answer "X's partner" | One extra join | None |
| Safety | Always correct, any cardinality/participation | Correct only with total participation on the one side |
| Redundancy | Least | Slightly more (Y key repeats for a Y linked to many X's) |
When to pick which: use C when the one side has total participation (the professor's exam rule); otherwise use B — unless there is total participation, "there is always a chance of null entries."
9.3.4 The Settled Answer
Both B and C are correct, and C is the most accurate answer for this course's treatment of the ER portion: B is the un-merged intermediate step (always safe, three relations), while C is the final, least-redundant design (two relations), justified specifically because X's total participation guarantees no nulls on the X side and so allows a clean merge. The professor also restates the general principle for exam use: a new relation is created whenever we merge, decompose, or join — the merge is mostly for the total-participation case; otherwise, unless there is total participation, there is always a chance of null entries.
Recap + bridge: Mapping a 1:N relationship starts with the always-safe association relation (option B) and, when the one side has total participation, merges it into the one-side relation (option C) — the lossless shrink that eliminates a join without introducing nulls. Both are correct; C is most accurate. The same "least redundancy, fewest nulls" thinking is the reason the next section gives for normalization: why we normalize at all.
Real-world & domain connection: This mapping decision is made in every database design tool and every hand-drawn schema. A library's "a copy belongs to exactly one book, and every copy must belong to a book" is a total-participation 1:N — merge the copy's book foreign key directly into the copy relation (which is, of course, how it is always drawn in practice). A hospital's "a patient may or may not have a primary doctor" is partial participation — a nullable doctor foreign key, or a separate linking relation, is the honest model. Reading total participation on the diagram and choosing B or C accordingly is the entire skill.
9.4 Why We Normalize: The Goals of a Good Database Design Schema
9.4.1 The Four Characteristics
Hook — the schema is fine until someone else has to read it. You have mapped an ER diagram into relations and it works for you. Is it a good design? The professor's answer lists the goals of a good database design schema — and says outright that the entire normalization machinery exists to achieve them. If your schema fails one, normalization is the remedy.
After building a relational schema from an ER diagram, the next question is whether that schema is good. The professor lists the characteristics of a good database design schema; the point of the entire normalization machinery is to achieve them:
- Proper semantics. Every relation and every attribute must mean something clear. A relation R with attributes A, B, C, D, E "does not make any sense for anyone else apart from you" — even if you wrote the meaning in the schema description. The application development team and the maintenance team may be different people, so the schema itself must carry meaning: give A its real attribute name, B its real attribute name. This is the first part of a good design.
- Least amount of redundancy, and no anomalies. Redundancy is not a space problem — "20, 25, 30 years ago people might say okay, the space is the issue" — it is a correctness problem. Whenever an attribute value repeats, an update must propagate everywhere the value repeats, and any missed spot creates discrepancy.
- No spurious tuples — lossless join. As you move from one normal form to the next, you decompose relations and later join them back. If the join manufactures wrong tuples (spurious tuples), the database again contains wrong information. Whenever a relation is decomposed, the join must be lossless.
- Scalable, and long lasting. The professor closes the list with the goals a good schema must survive by: it must scale as data and users grow, and it must last — a schema that must be redesigned every few years has failed its primary purpose. The first three characteristics make the schema correct today; these last two make it survive tomorrow.
The first three characteristics are named directly in the session; the professor then adds "scalable, and long lasting" as the goals that round out a good schema.
Scope — what "good design" does not mean here. These are goals for relational schemas built from ER diagrams, judged before physical tuning. They say nothing yet about query speed or storage engines; the performance dimension appears when the professor discusses denormalization and NoSQL below. Normalization is a correctness discipline first.
9.4.2 Redundancy Creates Uncertainty: The Email-ID Example
The concrete argument: suppose there is a functional dependency between email ID and name, and the name value repeats across many tuples. If the name changes at one place, it must change at every place where the email ID appears. If you retrieve the data later and 17 of 20 occurrences say one thing while 3 say another, there is a discrepancy — and a discrepancy creates uncertainty in the database: "which is the correct answer, the one the 17 are saying or the one the 3 are saying?" Redundancy causes uncertainty, and uncertainty does not allow you to take a decision. This is the core reason normalization exists: to remove redundancy so that a single fact is stored in a single place.
Worked example — 20 rows, 17 say one thing, 3 say another. A relation PERSON(email_id, name) stores the same email's owner twenty times (say across twenty address-book rows). The FD email_id → name holds: one email, one owner. Now the owner changes their name from "R. Verma" to "R. Sharma".
- The update is issued once, but it must land in all 20 rows. It lands in 17.
- Later, a query asks: what is the owner of this email? The database answers "R. Verma" (17 rows) and "R. Sharma" (3 rows) — two different answers to one question.
- There is no way to know which is correct without trusting one copy over the others. The data has lost its certainty, and a decision based on it (mailing a bill to the wrong name) fails.
Sense-check: with no redundancy — name stored once, in a separate OWNER table keyed by email — a single update changes a single row, and the query always gets one answer. That is the entire point of normalization in one example.
The professor's chain is the lecture's core argument: redundancy → discrepancy → uncertainty → inability to decide. Each normal form removes one source of redundancy, so a single fact lives in a single place.
9.4.3 Denormalization in Real Life (and the NoSQL Link)
The professor adds an important real-world caveat: in real life, people denormalize relations. BCNF is a beautiful, near-redundancy-free schema, "an absolutely impeccably nice relational schema" — but maintaining it means many relations, and so many joins. Joins cost storage and retrieval overhead. So some schemas deliberately live with a little redundancy and a few null entries to make retrieval faster. "In few real life cases we denormalize to second normal form as well." This performance-versus-redundancy trade-off is flagged as essential for the later part of the course, when NoSQL is discussed — "just mind you, this discussion ... about NoSQL ... the performance aspect is very important."
Recap + bridge: Normalization buys correctness — one fact, one place — at the price of joins. Real systems sometimes pay redundancy to buy speed, even back to 2NF, and the professor flags this trade-off as the bridge to the course's later NoSQL discussion, where the performance aspect is decisive. The exact definitions of the normal forms (1NF, 2NF, 3NF, BCNF) are the next topic.
Real-world & domain connection: The normalization/denormalization trade-off is an everyday decision in real database design. E-commerce order tables are routinely denormalized (storing the product name alongside the order line) so that product renames don't trigger historical order rewrites; analytics warehouses store wide, duplicated facts on purpose because joins at petabyte scale are unaffordable. The professor explicitly ties the decision to NoSQL: document stores like MongoDB and key-value stores sacrifice normalization for performance by design. Knowing what normalization costs is what makes the trade-off a decision rather than a violation.
9.4.4 First Normal Form: Atomic Cells
First normal form is the base: every cell of every tuple holds a single, unique entry. The professor's argument is practical, not formal. Suppose one cell holds three phone numbers separated by commas: "V has three entries with a comma here." To find a person's phone number you cannot simply read the cell — you must write an algorithm that searches inside the cell, and that takes time and computation power. 1NF says each cell carries exactly one value, so retrieval stays simple. This is the foundation the other normal forms build on.
Worked example — the comma-separated phone cell. PERSON(pid, name, phones) with a row (101, 'V', '555-0101, 555-0102, 555-0103'). To answer "does V have 555-0102?" the database engine cannot use a plain equality comparison — it must scan the string, split on commas, and compare each piece. Every query does this; an index on phones is useless (the index would need to know about the delimiters); updates must re-serialize the whole list.
The 1NF fix: split into one row per phone — PERSON_PHONE(pid, phone) holding three rows (101, '555-0101'), (101, '555-0102'), (101, '555-0103'). Now "does V have 555-0102?" is one indexed equality lookup, and adding a fourth number inserts one row.
Sense-check: the same data, restructured so that every cell holds exactly one atomic value — retrieval stays simple, exactly as the professor said.
Pitfalls:
- Treating normalization as a space-saving exercise — the professor is explicit: "20, 25, 30 years ago people might say the space is the issue"; today it is a correctness issue.
- Believing a schema with proper semantics only needs a comment in the description — the schema itself must carry the meaning, because the team that maintains it may never see your comments.
- Thinking any decomposition is safe — a decomposition whose join produces spurious tuples silently inserts wrong information; that is why lossless join is a named goal.
- Forgetting 1NF is assumed by everything after it — 2NF, 3NF, BCNF are all defined "given 1NF."
Real-world & domain connection: Every one of these goals shows up as a real failure mode. Proper semantics: column names like col1 in a production schema force every future query to be reverse-engineered. Redundancy: a customer address stored in five tables drifts apart — the classic data-quality complaint of every CRM team. Spurious tuples: a poorly decomposed schema that joins into phantom rows has caused countless wrong BI reports. And the atomic-cell rule of 1NF is why phone-number, tag, and "multi-value" columns are routinely split into child tables in production designs.
9.5 The Normal-Form Definitions at a Glance
9.5.1 The Key Vocabulary, Revisited
Hook — one relation, four increasingly strict rules. The entire normalization ladder is four sentences long: 1NF says cells are atomic, 2NF bans partial dependencies, 3NF bans transitive dependencies, BCNF demands every FD's left side be a super key. The difficulty is not the rules — it is the vocabulary they are built on, so the professor revisits it first.
- A super key is a set of attributes that uniquely identifies every tuple.
- A key is a minimal super key — a minimal set of attributes that uniquely identifies every tuple.
- If more than one minimal set exists, they are candidate keys; one of them is chosen as the primary key.
- A prime attribute is an attribute that is part of any candidate key.
The standard reference formulation agrees, and adds the naming: if a relation has more than one candidate key, one is arbitrarily designated the primary key and the rest are called secondary keys. An attribute is prime if it is a member of some candidate key — membership in the primary key alone is not enough.
9.5.2 Second Normal Form: No Partial Dependencies
A functional dependency (FD) says the values of the attribute set determine the values of the attribute set ; both sides may be sets, and may be a single attribute. An FD is a full functional dependency when the left side is the complete candidate key — the left side cannot be shrunk. A partial dependency is an FD where is a proper subset of a candidate key. If, hypothetically, the candidate key is ABC, then an FD from AB (a proper subset of the key) to some non-prime attribute is not allowed — that is exactly what violates 2NF.
Formalize — the 2NF condition, built up.
- Start: a relation in 2NF must be in 1NF.
- Split each candidate key from the rest of the schema. A non-prime attribute is fully functionally dependent on when holds but no proper subset determines .
- is partially dependent on when some with exists — the dependency holds even with part of the key removed.
- Rule: a relation is in 2NF if every non-prime attribute is fully functionally dependent on every candidate key — equivalently, no partial dependency exists.
The two conditions that together make an FD a 2NF violation: (i) is a proper subset of a candidate key, and (ii) is not a prime attribute. If either fails, the FD does not violate 2NF.
The reference text makes the same point with the classic EMP_PROJ example: key , with — Ename is determined by part of the key, so it is partially dependent and the relation fails 2NF. Note the reference's historical definition is stated against the primary key; the professor's version — every candidate key — is the general definition, and the quiz question below makes that generalization explicit and examinable.
9.5.3 Third Normal Form: No Transitive Dependencies
3NF adds a stricter rule: a transitive dependency — the professor's phrasing: "from alpha to beta is there, if alpha is not a super key and beta is not a prime attribute" — is not allowed. In the informal framing used in the session: a transitive dependency is a non-prime attribute determining a non-prime attribute. If the middle attribute (or the target) happens to be a candidate key or a prime attribute, the chain is not a transitive dependency in the violating sense.
Formalize — the 3NF condition in its general form. A relation is in 3NF if, for every nontrivial FD , either:
- (a) is a super key, or
- (b) is a prime attribute.
The professor's phrasing "alpha is not a super key and beta is not a prime attribute" is exactly the negation of this: an FD violates 3NF only when it fails both clauses at once. The classical shape is the transitive chain where is a key, is neither a key nor part of one, and is non-prime — the standard reference example is EMP_DEPT with and , where the manager's ssn is reachable only through a non-key attribute.
Why transitive dependencies are banned: they carry redundancy. When the non-prime attribute repeats, anything it determines repeats with it, and any change must be propagated everywhere — the same redundancy-uncertainty argument as before. 3NF "is an even stricter form" that refuses this too.
9.5.4 BCNF: The Left Side Must Be a Super Key
BCNF is the sharpest rule: for every FD , must be a super key — no exceptions, no carve-outs for prime attributes on the right. So BCNF is strictly stronger than 3NF: 3NF allows when is not a super key provided is prime; BCNF forbids it regardless.
The three conditions side by side.
Where ranges over candidate keys. The ladder of strictness: every BCNF relation is in 3NF, every 3NF relation is in 2NF, every 2NF relation is in 1NF — each rule is a superset of the previous demands.
Comparison — 2NF, 3NF, BCNF at a glance.
| Normal form | What it bans | Exact condition | Carve-out allowed? |
|---|---|---|---|
| 2NF | Partial dependency | proper subset of a candidate key, non-prime | None needed — both conditions required to violate |
| 3NF | Transitive dependency | not a super key AND not a prime attribute | Yes: prime saves an FD with non-superkey |
| BCNF | Any FD with non-superkey left side | must be a super key | None at all |
When to pick which: the exam's rule of thumb — check BCNF first via left-side closures (fast), and use 3NF/2NF only when the question asks specifically; a schema in BCNF automatically satisfies the others.
9.5.5 The 2NF Definition Question from the Quiz
A follow-up quiz question tested the wording of the 2NF definition.
Q: For 2NF: option (a) said "a relation is in 2NF if it contains no partial dependency" — with some further clause about a composite key being in 1NF — and option (d) said "every non-prime attribute is fully functionally dependent on any candidate key." I think (d) is correct — full functional dependency is the right notion. A: You are right: (d) is correct. (a) is not the correct answer; it should be fully functional dependency — every non-prime attribute is fully functionally dependent on any candidate key. Yes, this option was also wrongly written; I will correct it.
Q: Does 2NF care only about the primary key, or does it apply to any candidate key? The question asks: "whether we have to check only the primary key or even if any non-prime attribute is fully functionally dependent on any candidate key then we can say it is not in 2NF." A: It is not only related to the primary key — it is for any candidate key. Both answers are correct. Don't worry — both will be marked as correct; if anyone has marked either of them, both of you will get full marks.
Pitfalls:
- Dropping the word "full": "no partial dependency" without "full functional dependency on every candidate key" is the wrongly-worded option (a) — half the definition is missing.
- Checking 2NF against the primary key only. The rule is every candidate key; a partial dependency on a non-primary candidate key still violates 2NF.
- Calling any chain of FDs a "transitive dependency": the violating chain requires the middle attribute to be neither a key nor part of a key, and the target non-prime. A chain through a candidate key is safe (this exact trap appears in section 9.6).
- Forgetting 1NF is a precondition — 2NF, 3NF, BCNF all assume atomic cells.
Recap + bridge: 2NF bans partial dependencies (proper-subset left side with non-prime right side), 3NF bans transitive dependencies (non-superkey left side AND non-prime right side), BCNF demands every FD's left side be a super key with no exceptions. These definitions are used verbatim in the next section's worked example, where the quiz's FD set is checked against all three.
Real-world & domain connection: These definitions are not just exam material — they are the acceptance criteria of every schema review. A designer who can name the normal form of a table, and the specific FD that violates it, has found the exact redundancy that will later produce an update anomaly in production. Tools that suggest decompositions (and every textbook algorithm for 3NF and BCNF synthesis) are built on the three conditions above; knowing them by heart means the tool's output is never a black box.
Exam note: in the 2NF definition question, the correct notion is full functional dependency of every non-prime attribute on every candidate key — not the primary key alone. Both the "primary key" and "any candidate key" wordings were accepted, and the answer key is being updated so students who marked either get full marks.
9.6 Worked Example: Finding Candidate Keys and Checking 2NF, 3NF, BCNF
9.6.1 The Given Functional Dependencies
Hook — one FD set, one relation, and a quiz whose options are all flawed. The third quiz question gives a relation and asks which statement about its normalization is correct. Answering it requires the whole toolkit: candidate keys via closure, then 2NF, 3NF, BCNF checked FD by FD. The discussion ends with the professor promising to fix every option of the question — the method is the lesson.
The third quiz question gives a relation and this set of functional dependencies (confirmed in the discussion):
The relation's attributes are exactly . The question asks which statement about normalization is correct. The way to answer: find all candidate keys, then check each normal form's condition FD by FD.
9.6.2 Finding the Candidate Keys with Closure
The method — attribute closure. The closure of an attribute set , written , is the set of all attributes reachable from by following FDs. Compute it by the fixed-point rule: start with ; repeatedly, whenever an FD has its entire left side inside the current set, add . Stop when nothing new can be added.
An attribute set is a candidate key exactly when its closure is the whole relation, and no proper subset also closes to the whole relation. The search procedure for a small relation: test every single attribute; every attribute that does not close to the whole relation moves up to the pairs; every pair that does not close moves to triples; and so on. Any set that closes to everything is a candidate key, and all of its supersets are dismissed (they are super keys, not candidate keys).
The professor computes four closures:
Start with A. From and add B and C; from add D; from add E. Since covers everything, A is a candidate key.
Start with C and D. From add E; from add A; from and add B and C. CD is a candidate key.
Start with E. From add A; from and add B and C; from add D. E is a candidate key.
Start with B and C. From add D; from add E; from add A. BC is a candidate key.
That is exactly four candidate keys: A, CD, E, BC. The single attributes B, C, D each close to themselves or less (B closes to and no further), and BD closes only to because needs C — so no other minimal combination exists. Because every attribute appears in at least one candidate key, every attribute of the relation is prime.
Why no other candidates exist — the exhaustive argument.
- Singles: , (no FD has a left side inside ), . Only A and E close to the whole relation, so only A and E are single-attribute keys.
- Pairs from the leftovers : — a key. — a key. — CD → E needs C, so D never grows past D, B never grows past {B,D}: not a key.
- Triples and beyond are all supersets of BC or CD, so super keys, never candidate keys.
- The search is finite: 5 singles + 10 pairs + 10 triples + 5 quadruples + 1 quintuple = 31 subsets, of which only the minimal closers (A, E, BC, CD) win.
9.6.3 Checking 2NF
A partial dependency needs a proper subset of a candidate key on the left and a non-prime attribute on the right. Look at : B is a proper subset of the candidate key BC — the shape of a partial dependency. But D is a prime attribute (D belongs to the candidate key CD). The second condition fails, so does not violate 2NF. No other FD has a left side that is a proper subset of a candidate key. The relation is in 2NF.
The 2NF check, FD by FD.
| FD | Left side a proper subset of a candidate key? | Right side non-prime? | Violates 2NF? |
|---|---|---|---|
| No (A is itself a candidate key) | — | No | |
| No | — | No | |
| No (CD is a candidate key) | — | No | |
| Yes (B is a proper subset of the candidate key BC) | No — D is prime (D ∈ CD) | No | |
| No | — | No |
The one suspicious FD, , has the right shape (proper subset of the candidate key BC on the left) but the wrong target (D is prime). Since a violation needs both conditions, the relation passes 2NF. Sense-check: every non-prime attribute is fully functionally dependent on every candidate key — and here there are no non-prime attributes at all, so the requirement is satisfied by definition.
9.6.4 Checking 3NF
For 3NF, each FD must have as a super key or prime. Check one by one:
- : A is a candidate key, so a super key — fine.
- : same — fine.
- : CD is a candidate key — fine.
- : B is not a super key, but D is a prime attribute — fine.
- : E is a candidate key — fine.
No FD violates 3NF, so the relation is in 3NF. (For completeness: it is not in BCNF, because BCNF demands the left side be a super key with no exception, and fails that demand.)
The full verdict on this relation: candidate keys ; every attribute prime; in 2NF ✓, in 3NF ✓, not in BCNF ✗ (the single FD with B not a super key). Sense-check: the only FD that could cause trouble is , and D's primality saves it everywhere except under BCNF, which has no saving clause.
9.6.5 The Quiz Options Were Flawed — and the Answer Key Is Being Fixed
Q: Is the answer (a) — "the relation is in 2NF"? It is not violating 2NF. A: You are right in one way — (a) earns half a point. But the reason written in the option is wrong: it says "there is no transitive dependency," and 2NF has nothing to do with transitive dependencies — 2NF is only about partial dependencies (full functional dependency). So (a) should have said "because there is no partial dependency — every non-prime attribute is fully functionally dependent on every candidate key." That is the best answer possible.
Q: Then what about the option that says it is not in 2NF because of being a partial dependency? A: is a partial dependency in shape, yes — but D is a prime attribute, so it does not violate 2NF. That option is wrong.
Q: What about "not in 3NF"? A: If I select that option I am factually wrong: we just checked each FD, and the relation is in 3NF. So anyone who said "not in 2NF" or "not in 3NF" is wrong. All the options are wrong in one way; the most appropriate answer is still (a), because it at least gets the conclusion right — the relation is in 2NF.
The professor's verdict: every option of this question needs revision; the option that claims 2NF is the most appropriate answer as written, and the answer key will be updated so that no one loses marks over the flawed wording.
Q: But there is a transitive dependency here — from C to E and E to A, no? C to E, E to A. A: Where is C to E? I don't see C to E. The FD is CD to E, and CD is a candidate key; E is also a candidate key. A transitive dependency means a non-prime attribute determining a non-prime attribute. Since E is a candidate key, E to A is not a transitive dependency in the violating sense — the chain is safe. And that is exactly why it is important to understand what transitive dependency means: only a non-prime attribute to a non-prime attribute creates the redundancy we are eliminating.
The student's proposed chain fails twice. First, there is no FD — the set has , and CD is itself a candidate key. Second, even the existing chain has E as a candidate key, so its left side is a super key — under 3NF, an FD from a super key is always fine. The student's reading is a textbook example of the trap: calling any multi-hop FD chain "transitive" without checking the status of the attributes in the middle.
Pitfalls:
- Declaring a 2NF violation by shape alone — a partial dependency also needs a non-prime right side; D is prime here.
- Quoting "no transitive dependency" as the reason a relation is in 2NF — 2NF is defined by partial/full functional dependency, not transitivity.
- Claiming a chain like is transitive when one of its FDs doesn't exist ( is not ) or when its attributes are keys.
- Stopping the candidate-key search early — missing BC would make every prime-attribute argument wrong.
Recap + bridge: For this FD set, the closure method yields exactly four candidate keys (A, CD, E, BC), every attribute is prime, and the relation sits in 2NF and 3NF but fails BCNF on . The question that follows is the natural one: why must every candidate key be checked — why was BC tested when no FD mentions it?
Real-world & domain connection: This exact exercise — FD set in hand, keys found by closure, normal form verified FD by FD — is the professional's route to deciding whether a schema needs decomposition. Every real schema review starts here: write the FDs, compute the keys, name the violating FD, fix it. The BCNF shortcut shown in section 9.10 is the same skill optimized for exam speed.
9.7 Why Check Every Candidate Key? Closure, Armstrong's Rules, Minimal Cover
9.7.1 The Question That Started It
Hook — "BC isn't even in the FD list. Why are we testing it?" During the candidate-key search, a student asked why BC needed to be checked as a candidate key at all — after all, BC was not written among the given FDs. The answer opens the theory behind the closure: a given FD set is never the whole story.
Q: Why do we have to check whether BC is a candidate key? It is not a functional dependency in the given list, and nothing in the set needs it. A: That check impacts the correctness of the database design. When a set of functional dependencies is given, there is something called the closure of functional dependencies: using Armstrong's rules we can derive other functional dependencies that are possible but not written in the set. There is also a minimal cover — a minimal set of FDs equivalent to the original. From the minimal cover we create a relational schema: for whatever is on the left-hand side and the right-hand side, we create a relation, and that is how we move across to create 3NF and BCNF schemas. So a given set of FDs is not the whole story; using Armstrong's rules we can have other FDs that are not even written here. That is also the fundamental rule when we check whether functional dependencies are lost while decomposing — if we do not check whether something is a candidate key, we are not doing a proper job.
The idea, unpacked. From the five written FDs, Armstrong's rules derive plenty of FDs that are never written down — and all of them are real constraints. In the worked example: and give by transitivity; and give ; and the fact that BC closes to the whole relation means all hold. None of these appears in the written set, yet every one of them is a constraint the database must respect. If the schema designer only planned around the written five, the schema could silently violate its own data's real structure — which is why "check every candidate key" is the fundamental rule for detecting lost dependencies during decomposition.
Formalize — Armstrong's axioms. A set of inference rules that generate exactly the FDs implied by a given set (sound: they never generate a false FD; complete: they generate every implied FD). For attribute sets :
Two convenient derived rules are the union rule (if and , then ) and the decomposition rule (if , then and ). The closure of an FD set is the set of all FDs derivable from by these rules. A minimal cover of is an equivalent set of FDs — same closure — that is as small as possible: no redundant FDs, no redundant attributes on either side. Textbook algorithms build 3NF and BCNF schemas directly from a minimal cover: for each FD in the cover, form a relation with attributes .
Worked derivation — the hidden FDs of the quiz set. Take the written set .
- Transitivity on and : . (So from section 9.6, was never an accident — the whole chain is Armstrong-derived.)
- Transitivity on and : .
- Union rule on , , : .
- BC's closure being the whole relation is itself a statement about the closure : , , are all in , even though the written set never mentions BC.
Sense-check: every one of these derived FDs holds in every legal instance of the relation — that is what "implied by the set" means. A candidate-key check that ignores them is checking a false picture of the schema.
9.7.2 The Search Is Finite
Q: But in that situation there will be unlimited numbers of subsets and subsets and subsets. A: No — we are checking candidate keys, not all super keys; super keys and candidate keys are different. A is a candidate key; E is a candidate key. Anything you attach to A or E becomes a super key, not a candidate key, so those combinations are gone — A is individually a candidate key, E is individually a candidate key. B, C, D are individually not candidate keys, so we check their combinations: BC is a candidate key, CD is a candidate key; what other combination can you check? BD — B and D: B alone gives {B, D}, no E, so BD is not a candidate key. That's it — it is finished. It is not infinite; it is a very good question, but the search is over the minimal combinations only.
The search is finite because of a simple pruning rule: once a set is a candidate key, every superset is only a super key — never a candidate key. In the quiz example: A and E are candidate keys, so all 15 supersets containing A or E are eliminated immediately. Among the remaining singles , only pairs matter: BC and CD are keys; BD fails (its closure stops at ); any triple containing a pair that failed cannot be minimal... and in fact every triple contains a key or BC/CD anyway. Total sets examined: five singles and three pairs — not "unlimited."
This is the practical algorithm for a small relation: test every single attribute, then every minimal pair, and so on; stop early because any candidate key you find kills all its supersets as candidate-key candidates (they remain super keys only).
Scope — when the search genuinely explodes. The pruning rule makes small relations trivial, but the number of subsets is exponential in the number of attributes in the worst case (a relation with attributes has subsets). The professor's point stands for exam-size relations — hand-searchable — while real-world tools rely on the closure algorithm and automated key discovery, which is why the candidate-key hunt is always paired with the closure computation rather than brute-force enumeration.
Recap + bridge: A written FD set is never the whole story — Armstrong's axioms expand it to the full closure , and the minimal cover is what schema-synthesis algorithms actually consume. Candidate-key checking is the practical guard against losing dependencies during decomposition, and the search is finite because candidate keys prune their own supersets. The next section moves from theory to the exam hall: the old paper's ER-to-relational question.
Real-world & domain connection: "Lost dependency" is not an abstract phrase — it is the reason decompositions produce schemas that accept data the original constraints forbade. Real design tools compute the closure and minimal cover silently; when a tool warns "FD lost in decomposition," it is running exactly the checks the professor insists students run by hand. The same machinery detects whether two FD sets describe the same constraints — the subject of section 9.11's old-paper question.
9.8 Old Paper Question 1: From an ER Diagram to a Relational Schema
9.8.1 The Setup and the Conversion
Hook — "In the ER diagram portion you must go full marks." The old question paper's first question is an ER diagram (book, author, publisher, and user entities with a library flavor) to be converted to a relational schema. The professor uses it to rehearse the conversion recipe and to tell students exactly what is expected of them in the exam.
The entity relations come first: book is one entity, author is one entity, periodical/paper is a separate relation, user is an entity — each with its attributes. Then the relationships: "has" between book and author is one-to-n (1:N), and there is no total participation, so we keep "has" as a separate relationship schema. The same pattern repeats for each relationship in the diagram. The professor's compact rule: for a 1:N relationship without total participation, keep the relationship as its own relation; the merge into the one-side's relation is reserved for the total-participation case, because without total participation there is always a chance of null entries.
The conversion recipe, step by step (the professor's exam checklist). Given any ER diagram:
- Identify the entities — one relation per entity: BOOK, AUTHOR, PUBLISHER, USER, PERIODICAL.
- Identify the attributes — the simple attributes of each entity become the relation's columns; composite attributes flatten into their components.
- Identify the keys — the primary key of each entity relation.
- Identify the relationships — decide each relationship's mapping: for 1:N without total participation, keep a separate relationship relation holding both primary keys as foreign keys; for 1:N with total participation on the one side, merge (section 9.3); for M:N, always a separate relation; for 1:1, a foreign key on the total-participation side.
- Write the foreign keys — every relationship relation carries the participating entities' keys as foreign keys, pointing back to their entity relations.
The exam question papers follow the same style as this old paper: the entity relations first, then each relationship's mapping with its foreign keys, with the cardinality and participation read from the diagram.
Worked conversion — the library fragment. Suppose the diagram shows BOOK(book_id, title), AUTHOR(author_id, name), and the relationship "has" (an author has written a book), 1:N, no total participation anywhere.
- Entity relations: BOOK(book_id, title) with key book_id; AUTHOR(author_id, name) with key author_id.
- Relationship "has": no total participation on the one side (an author may have written no books yet, or a book may have several authors — the diagram's N says many), so keep it separate: HAS(book_id, author_id) with both columns foreign keys. If the relationship carried attributes (e.g., year), they join this relation.
- The 1:N reading: one book is "had" by at most one author-role (the N side: many books per author)... read the diagram's side labels exactly as in section 9.2 before choosing.
Sense-check: every relationship on the diagram must appear in the output as either a merged foreign key or its own relation; after the conversion, the schema has all primary keys and all foreign keys, and nothing else was invented.
The professor's confidence check: given an ER diagram, you should be able to identify the entities, identify the attributes, identify the relationships, identify the keys, and convert them into a relational schema with the foreign keys. "In the ER diagram portion you must go full marks."
9.8.2 Reading Cardinality on the Bank–Branch Example
To make the reading of cardinality concrete, the professor reads a bank–branch relationship: a bank can be associated with many bank branches, while a bank branch can be related to at most one bank. Both sides have total participation here: every bank must have at least one bank branch, and every bank branch must belong to a bank. Reading each side: "every bank can have at most many bank branches" (the many side, with the minimum forced to one by total participation) and "every bank branch can have at least one and at most one bank" (the one side).
Worked reading — bank and branch, both sides total. Draw BANK and BRANCH connected by "has." The "1" label sits on the BANK side of each branch, the "many" label on the BRANCH side, and both edges are double lines (total participation).
- From a branch: at most one bank — every branch belongs to exactly one bank (total: at least one; the "1" label: at most one).
- From a bank: many branches — every bank owns at least one branch (total: at least one) and may own many (the "many" label).
So "bank to branch is 1:N with total participation on both sides" reads as a minimum of 1 and a maximum of N on the bank side, and a minimum of 1 and a maximum of 1 on the branch side. Sense-check: if a bank could exist with zero branches, the bank side would lose its total participation — the double line is the entire difference.
Q: Could you read one cardinality relationship to make it clear — from author to book, say? Also, are the two notations — minimum/maximum cardinality and this kind of cardinality — the same? A: From author to book, the reading is the same style as the bank–branch example. The first and second questions are the same; this min/max one is different — I will take it next.
The professor distinguishes the two notations explicitly: the "1 / N" side-label style read here, and the (min, max) style to be covered next — they encode the same facts (per-side minimums and maximums) in different visual forms, and the next section shows how to read the (min, max) form.
9.8.3 Practice and the Standing Offer
The professor pushes hard on practice: "Are you 50, 60, 70 percent confident that you can represent that? Practice still needs to be done." There is no substitute for practice — "I can't practice for you." Students can email their attempts at the three practice questions and get feedback ("is my practice correct or not — do I need something more or less?"). There is also a standing offer for an optional one-on-one practice session: write a mail to reserve half an hour, planned midweek (Monday or Tuesday), organized by a student volunteer, with the professor available to solve and discuss questions live. A commitment from earlier weeks is repeated: to show what a database looks like inside an entire application end to end.
Pitfalls:
- Stopping after the entity relations — every relationship must also be mapped, and every foreign key must be placed and labeled.
- Merging a 1:N relationship without checking total participation — without it, nulls appear and the merge's justification collapses.
- Reading the "many" side as "one-to-many = one X has many Y's" without verifying which side the "1" label is on.
- Forgetting relationship attributes: if the diagram gives the relationship attributes (dates, roles), they must live in the relationship relation (or the merged relation), not be dropped.
Recap + bridge: ER-to-relational conversion is a five-step recipe — entities, attributes, keys, relationships, foreign keys — with 1:N-without-total-participation kept separate and 1:N-with-total-participation merged. The exam expects this to be done faultlessly. The next section answers the student's pending question: the (min, max) notation, read side-by-side with this one.
Real-world & domain connection: This conversion is the first step of every database project — the ER diagram is the blueprint, and the relational schema is the build. Design tools automate it, but their output is only as good as the reading of cardinality and participation, which is exactly what this section rehearses. Bank–branch modeling is a canonical real example: banks hold many branches; branches belong to exactly one bank; total participation on both sides is a business rule, not a choice.
9.9 Reading (min, max) Cardinality Notation
9.9.1 The Notation and the Textbook
Hook — a second notation for the same constraints, and a professor who corrects himself mid-answer. The session's earlier Q&A asked whether the "1 / N" side-label notation and a minimum/maximum notation are the same. The answer comes now: a different ER notation writes a (min, max) pair on each entity's side of a relationship edge — and even the professor momentarily read it backwards before catching himself, which is exactly the trap to avoid.
A different ER notation writes a (min, max) pair on each entity's side of a relationship edge. The textbook — the professor explicitly names it: "what is written in the book is Navathe also" — covers it on page 83 (bottom) and shows a diagram on page 85. The professor's reading rule, as he eventually settled it: the (min, max) written on an entity's side describes how that entity participates in the relationship — the minimum and maximum number of relationship instances that each entity of that set can appear in (equivalently, for a binary relationship, how many entities on the other side it can connect to).
Formalize — the notation's precise meaning, reconciled with the reference. The reference text (the same "Navathe" treatment) attaches a pair of integers (min, max) to each participation of an entity type E in a relationship type R, subject to and . The meaning, verbatim from the reference: for each entity in , must participate in at least min and at most max relationship instances in at any point in time. Two consequences follow directly:
So the notation is the general form of everything seen so far: the "1" label is a maximum of 1 on that side; the "many" label is an unbounded maximum; and the double line for total participation is exactly . A side labeled (1,1) is "one side plus total participation"; a side labeled (0,N) is "many side without total participation."
A caution from the reference is worth keeping: some other notations — particularly UML — place the (min, max) pair on the opposite side of the edge from this book's convention. So a screenshot from another source can genuinely look reversed; the rule "the label describes the entity it is written beside" only holds within one notation's convention. This is precisely why the professor's first instinct (reading the labels as describing the other side) must be corrected.
9.9.2 The Department–Employee Example, Including the Professor's Own Confusion
The example on the page is a WORKS_FOR-style relationship between departments and employees, with (1,1) on the department side and (2,30) on the employee side. Reading it strictly from the notation:
- A department participates in the relationship between 1 and 1 times — every department is rated (1,1) in WORKS_FOR.
- An employee participates between 2 and 30 times — "an employee can be related to minimal two and maximal 30 departments, that is how we read it across."
The professor is openly uncertain at first and corrects himself on the fly: he starts by reading the labels as if they described the other side (a department has min 1, max 1 employees; a department has min 2, max 30 employees), then stops: "it should be the opposite one ... if I read the diagram on page 85 as it is, without worrying about real life, a department can have minimal 1 and maximal 1; an employee can be related to 2 and maximal 30."
The (min, max) assignment — (1,1) on the department side and (2,30) on the employee side — and the side-to-side reading rule are confirmed by the reference's definition: the label describes the participation of the entity on whose side it is written, and this is what the professor commits to. The professor's mid-answer self-correction is the lesson in miniature: reading "a department has 1 to 1 employees" describes the employee's participation, not the department's.
Worked reading — department–employee, strictly by the rule. The diagram: DEPARTMENT — WORKS_FOR — EMPLOYEE, with (1,1) written on the edge next to DEPARTMENT and (2,30) written next to EMPLOYEE.
- Department side (1,1): every department appears in exactly one relationship instance — each department has exactly one employee-connection. The minimum equals the maximum, so participation is total and the maximum is one: an "at most one" side with a mandatory minimum.
- Employee side (2,30): every employee appears in at least 2 and at most 30 relationship instances — each employee connects to between 2 and 30 departments.
The professor's own misreading is the guardrail: "a department has at least 2 and at most 30 employees" is wrong under this convention, because the (2,30) sits on the employee's side of the edge. Sense-check: with the rule in hand, every (min, max) pair answers one question — "how many times may a single entity of this set participate?" — and never "how many entities of the other set relate to it?"
Q: Can we read it the other way — a department is associated with minimum two employees and maximum 30 employees, and an employee can be associated with only one department? A: No, no, no — this is on this side only, that is what I know of: whatever is on a side describes that side. Left-hand side is related to this only. It is different from the other notation — in this notation we read from this side, and in the other one we read from that side. Please go ahead and read the book as well.
Comparison — the two notations, side by side.
| Notation | Form | What it expresses | Side read |
|---|---|---|---|
| Cardinality ratio + participation | "1" / "many" labels, single/double lines | Maximum cardinality (1 vs many) and minimum participation (partial vs total), drawn separately | The label constrains its own side |
| (min, max) | one pair per edge, per entity | Minimum and maximum participation count in one symbol; partial, total | The pair describes the entity beside it |
The two notations encode the same facts: "(1,1)" = one-side label plus double line; "(0,N)" = many-side label without double line. The professor's point stands: in this notation read from the side the label is written on; in the other, read the side labels similarly — never mix the conventions mid-diagram.
9.9.3 Why It Still Matters, and the Exam Note
The professor is explicit about scope: "you will not get this type of question in your mid-semester or mid-semester makeup — I will not give these questions, so you may not worry about it right now." But: "in case in your real life you come in touch with something like this, you should still be able to read it — that this is related to this side."
Pitfalls:
- Reading the pair as describing the other entity — the exact mistake the professor made and corrected; the pair belongs to the entity beside it.
- Forgetting that means partial participation and means total participation — the double line and the (1, x) minimum are the same constraint in different costumes.
- Expecting every notation to place labels on the same side — UML and other notations may reverse the placement, so the meaning (per-entity participation counts) matters more than the picture.
- Treating the example's (2,30) as "every employee works in 30 departments" in real life — the diagram states a constraint; real-life plausibility is a separate modeling question.
Recap + bridge: The (min, max) notation is the general participation constraint — is the minimum number of relationship instances per entity, the maximum, with partial and total — and each pair describes the entity on whose side it is written. Not exam-tested, but expected as literacy. With cardinality reading settled in both notations, the session returns to the old paper: which FDs violate BCNF.
Real-world & domain connection: Tools that generate ER diagrams from databases, and standards that exchange schemas between systems, frequently use (min, max) or l..h bounds (the same rule written as a range). Reading them is a transferable skill: a system integrator meeting a schema in (min, max) form must know which side a constraint belongs to, or every cardinality is misread. The professor's framing — "in real life you should still be able to read it" — is the actual reason the notation is taught even though it is not exam-tested.
Exam note: (min, max) cardinality reading is not tested in the mid-semester or the mid-semester makeup exam; knowing the correct side-to-read rule is expected only as general literacy, and the textbook (Navathe, pages 83 and 85) is the authority for the notation.
9.10 Old Paper Question 2: Which Functional Dependencies Violate BCNF?
9.10.1 The Shortcut: Only the Left-Hand Side Matters
Hook — a BCNF question you can answer without finding a single candidate key. The old paper asks which functional dependencies violate BCNF. The professor's shortcut: BCNF never looks at the right-hand side — only at whether each FD's left-hand side is a super key. That single fact removes nearly all the work.
For BCNF, there is a shortcut that saves most of the work: you do not need to enumerate all candidate keys. BCNF only worries about whether the left-hand side of each FD is a super key (or candidate key). So for each given FD, compute the closure of its left-hand side; if the closure is not the whole relation, that FD violates BCNF; if the closure is the whole relation, it is fine. "I need not even find out in this question all the candidate keys as well."
Why the shortcut works. BCNF's condition: every FD must have a super key. An attribute set is a super key exactly when is the whole relation — that is the definition of "uniquely identifies every tuple." So the check per FD is: compute , compare with the relation's attribute set. Two outcomes, no third:
- whole relation → is a super key → the FD passes BCNF.
- whole relation → is not a super key → the FD violates BCNF.
Nothing about matters. Compare with 3NF, where a prime could save the FD — in BCNF there is no saving clause.
9.10.2 The Worked Walk-Through
The paper's BCNF question gives FDs whose left-hand sides include B, BF, C, and CH. The discussion names the left sides B, BF, C, and CH and walks the check for CH in full — that walk is the method. The check for CH:
From add B; from add C and D; and from there the professor notes A and B, C are reachable as well — but E is not: "from CH I cannot find out E." Since misses at least one attribute of the relation, CH is not a candidate key and not a super key — the FD with CH on the left violates BCNF. The other left-hand sides (B, BF, C) are super keys, so their FDs pass.
Worked check — the left-side table. Suppose the relation's attributes are and the FDs include and (the steps the professor names), plus whatever the diagram gives for B, BF, and C. The method, applied:
| FD left side | Closure walk | BCNF verdict | |
|---|---|---|---|
| B | , then onward | whole relation | passes (super key) |
| BF | superset of B | whole relation | passes (super key) |
| C | closure via the given FDs | whole relation | passes (super key) |
| CH | , , … but E unreachable | — misses E (and F) | violates |
The reasoning for CH in full: start with ; adds B; adds C and D; the professor notes A (and B, C again) become reachable from there; but E is never reached — no FD's left side becomes available that leads to E. Since one attribute (E) is missing, CH is neither a super key nor a candidate key. Sense-check: "only this one passes, all the others are violating" — exactly one FD fails BCNF, and its left side is CH, the only left side whose closure falls short.
Q: My solution finds that only one FD satisfies BCNF and all the others do not. I am not sure whether my solution is correct. A: You are correct. If you say CH: from CH, CH to B; from B we find CD; so from CH we can find B, C, D — and even more — but we cannot find E. That is why CH is not a candidate key or a super key, so it is violating here as well. Yes — for an FD to survive BCNF, its left side must be a super key; only this one passes, all the others are violating. If you want, write a mail to me and I will logically argue out why the others are not super keys.
9.10.3 "Determine All the Keys" — the Companion Question
The same paper also asks the inverse task: determine all the keys of a relation. The professor warns about the standard slip — declaring a single attribute a key when only a combination is a key: "you need to be careful of saying 'A is a key, B is a key.'" In this question, AB is a key, AC is a key, and BC is a key; individually, none of A, B, C is a key. And with these as the keys, none of the FDs violates BCNF — every FD's left side is a super key.
The two sub-questions of the paper use different FD sets: the "B, BF, C, CH" walk belongs to the BCNF-violation part, while the "AB, AC, BC" answer belongs to the determine-all-keys part — keep the two readings distinct.
Worked verification — AB, AC, BC as the only keys. A relation over whose keys are exactly AB, AC, and BC. The standard FD set that produces exactly this key structure is:
Check each key candidate by closure:
Each pair closes to the whole relation. The singles do not: , , — no single attribute reaches anything else, since every FD needs two attributes on the left. So none of A, B, C is a key, while AB, AC, BC all are.
BCNF check: every FD's left side (AB, AC, BC) is a super key — so no FD violates BCNF. Compare with the other part of the paper, where CH's FD fails: there, one left side was not a super key; here, all are. Sense-check: the professor's warning — "be careful of saying 'A is a key'" — is the whole lesson: with no single-attribute key in sight, declaring one is the classic slip that this question punishes.
Pitfalls:
- Enumerating all candidate keys for a BCNF question — the shortcut checks left-side closures only and skips the key search entirely.
- Stopping the closure walk too early: CH reaches B, C, D, A — a partial closure still violates BCNF; the test is equality with the whole relation, not "did it grow?"
- Declaring single attributes as keys when only combinations are keys — the professor's flagged slip in the companion question.
- Carrying the FD sets across sub-questions — the BCNF part and the determine-all-keys part use different relations and different FDs.
Recap + bridge: BCNF questions collapse to per-FD left-side closure checks — a left side whose closure is the whole relation passes; anything else violates. The companion "determine all keys" task is the inverse skill, with combination-keys the point of caution. The next old-paper question uses closures again, but for a different purpose: deciding whether two FD sets are equivalent.
Real-world & domain connection: The left-side closure check is what schema tools run when they tell you a table "violates BCNF — consider decomposing on FD ." It is also why BCNF is the design target in practice: every redundancy traced to an FD with a non-superkey left side is a redundancy the left-side check would have caught. The "determine all keys" skill is the everyday reverse exercise — naming the keys of a real table before judging its normal form.
9.11 Old Paper Question 2(c): Are Two FD Sets Equivalent?
9.11.1 The Method
Hook — a question whose right answer is "no," and where the marks live in the proof. The old paper's question 2(c) asks: given two sets of functional dependencies, F1 and F2, are they equivalent? The answer here is "no" — and the professor's point is that the one-word answer is worth almost nothing. The proof structure is where the marks are.
The question: given two sets of functional dependencies F1 and F2, are they equivalent? Two FD sets are equivalent when every FD in one set can be derived from the other set, and vice versa — i.e., their closures are the same. The concrete check: take each FD of F2, and test whether its right-hand side is reachable from its left-hand side using only the FDs of F1; then repeat in the other direction.
Formalize — equivalence of FD sets. Two FD sets and are equivalent, written , exactly when — every FD implied by one is implied by the other. Because computing full closures is expensive, the practical test is pairwise:
- Forward: for every FD in , compute with respect to ; check . If every is reachable, covers .
- Backward: the same test with the roles swapped.
Both directions must pass. One failure anywhere — one FD whose right side is unreachable — proves non-equivalence, and naming that FD is the proof.
In the paper's example, F2 contains , and F1 contains and . The professor checks: "can we find out A to CD from A to C and A to D? Yes — by the union rule, from and we derive ." So that FD of F2 is derivable from F1. The other direction fails: F2 also contains (along with ), and F1 contains no H anywhere.
Worked check — the two directions, fully written. Suppose and .
Forward check (is every FD of derivable from ?):
The forward direction fails on the last line: H appears nowhere in , no FD of can ever produce H, so cannot be derived — the closure of E in F1 never reaches H.
Backward check: even the reverse direction would also fail (F1's FDs cannot all be derived from F2 — e.g., needs decomposition of ), but one failure in one direction is already enough.
Conclusion: and are not equivalent, with as the named witness. Sense-check: the professor's rule of thumb — "if there is an attribute on the right of any FD that does not appear on the right of any derivable FD in the other set, look there first."
Q: In F1 there is no H anywhere — then how can it be equivalent? A: It is not equivalent — that is exactly the point. But you have to prove that it is not equal: you have to show that is not there — that H is not derivable from F1. Since E's closure in F1 never reaches H, cannot be derived, so the two sets are not equivalent. That is how we need to see it — and so on and so forth for the remaining dependencies as well.
The student's instinct — "there is no H in F1" — is exactly right, but the exam demands it as a derivation argument, not a glance. The one-line proof: "H is not in , so no FD of has H on its right side; can then never contain H, and ".
9.11.2 The Lesson on Proofs
The real lesson is how to present the proof, not just the one-word answer. The professor's script for any such question, which he says works "very, very well" in such examinations:
- Write your understanding of the topic — what is equivalence, what is a functional dependency.
- Write what the question asks — to check whether the sets are equivalent, you must test each FD of one set against the closure of the other.
- Perform the check and show the specific FD that fails.
- Conclude with the reason: "not equivalent because of that reason."
"Just by saying 'no' and nothing else" loses the marks that the reasoning earns. The evaluator can then see that you know what equivalence means, what checking equivalence requires, and that you actually checked it. Even when the answer is "no, they are not equivalent," this structure "would have a very heavy weight." The professor's closing warning: mind the time limit — you have that responsibility as well.
Pitfalls:
- Answering "no" without proof — the professor is explicit: the one-word answer loses the marks that the reasoning earns.
- Checking only one direction — equivalence demands both directions; F1 covering F2 says nothing about F2 covering F1.
- Announcing non-equivalence by intuition ("there's no H in F1!") without writing the closure argument — the intuition is correct, but the proof is the derivation statement.
- Mistaking "the union rule derives " for a proof of equivalence — deriving some FDs is not deriving all FDs.
Recap + bridge: Two FD sets are equivalent exactly when each set derives the other; checking is pairwise closure testing in both directions; a single underivable FD (here ) settles the answer, and the four-step proof script — understanding, question, check, conclusion — carries the marks. The next paper question applies the same set-theoretic thinking to relational algebra and SQL.
Real-world & domain connection: FD-set equivalence is the theory behind schema validation in real projects: when two designers submit FD lists for the same business rules, equivalence checking tells whether they described the same constraints before any decomposition is built. Database tools verify "does this new constraint change the closure?" with exactly the pairwise test worked here. And the four-step answer script is not exam theatre — it is the standard form of a technical report: context, question, method, conclusion.
9.12 Relational Algebra and SQL: Borrowers with No Books Checked Out
9.12.1 The Question and the Relations
Hook — the "not in the list" question, in two languages. The paper's relational-algebra/SQL question: retrieve the name of all borrowers who do not have any books checked out. The relevant relations are BORROWER (with name and card_number) and BOOK_LOANS (with card_number for every book on loan). The twist: relational algebra and SQL express the same set-difference idea differently, and the professor walks both.
The professor flags the wording "checked out" as ambiguous — it could mean "has borrowed nothing" or "has returned nothing." He states the assumption "checked out means nothing is borrowed" and proceeds, since the point is the query-writing technique, not the reading of the question.
9.12.2 The Relational-Algebra Logic
The professor's logical flow: first find the list of all card numbers present in BOOK_LOANS — these borrowers do have books out. Then the borrowers we want are exactly the ones whose card numbers are not in that list. In relational algebra this is a set difference:
The professor describes the subtraction of card numbers in words ("find out all the card numbers which are not there") but does not write the relational algebra on screen; the expression above is the same logic written symbolically. It matches the standard treatment: the join pairs each borrower with every loan they hold; projecting on name removes duplicates, yielding exactly the set of names that appear in BOOK_LOANS; the difference with all borrower names keeps the rest. It may be possible that some borrowers have no entry at all in BOOK_LOANS — those are exactly the ones the difference keeps.
Why the join, and why the projection? A borrower with three books out appears in three joined rows; the projection collapses them to one name. The difference operator then works on sets, so the two sides must be the same shape — both are sets of names. The expression reads, in plain words: "every borrower's name, minus the names of borrowers who appear in the loans table."
For completeness, the same query could be written with an anti-join style — — but set difference is the textbook-grade tool the professor builds with, and the language maps directly onto SQL.
Worked run with real data. BORROWER:
| name | card_number |
|---|---|
| Amit | 1001 |
| Bina | 1002 |
| Chetan | 1003 |
| Deepa | 1004 |
BOOK_LOANS:
| card_number | book_id |
|---|---|
| 1001 | B1 |
| 1002 | B2 |
| 1001 | B3 |
Step 1 — join: rows (Amit,1001,B1), (Amit,1001,B3), (Bina,1002,B2), plus any loans rows with no matching borrower would be dropped by the inner join. Step 2 — project on name: {Amit, Bina}. Step 3 — subtract from all borrower names {Amit, Bina, Chetan, Deepa}:
Answer: Chetan and Deepa are the borrowers with no books checked out. Sense-check: each of them has no row in BOOK_LOANS, and each of the others has at least one — exactly the professor's reading of the question.
9.12.3 The SQL Version
In SQL, the "card numbers not in the loans list" idea maps directly to NOT IN:
SELECT name
FROM borrower
WHERE card_number NOT IN (SELECT card_number FROM book_loans);
The professor's spoken version walks through the same shape: join borrower and book loans, collect the card numbers that appear in the loans, then select borrower names whose card numbers are not in that set — "I would have to say 'not in': card numbers not in book loans." The point to take away: SQL provides IN and NOT IN as first-class provisions, and the set-difference question is where they shine. The professor adds the honest disclaimer: "I am not 100% sure this is the exact final query, but this is the logical flow" — and reminds students that these queries "take some effort," so similar ones must be practiced.
The same data, through the SQL engine. The subquery SELECT card_number FROM book_loans returns {1001, 1002}. The outer query keeps borrower rows whose card_number is not in that set: 1003 (Chetan) and 1004 (Deepa) survive; 1001 and 1002 are filtered out. Output:
name
-----
Chetan
Deepa
Sense-check: exactly the set the relational algebra produced — the two notations describe the same operation, so a correct translation must give identical results.
Pitfalls:
- Forgetting that the subquery list may contain NULLs: if BOOK_LOANS.card_number had a NULL row, SQL's NOT IN evaluates every comparison against NULL as unknown, and the query silently returns no rows at all — the classic empty-result surprise. When the column can be NULL, the safe form is NOT EXISTS:
SELECT name
FROM borrower b
WHERE NOT EXISTS (SELECT 1 FROM book_loans l WHERE l.card_number = b.card_number);
- Trying to write the difference as
BORROWER minus joinwithout projecting — both sides of a set difference must have matching shapes; comparing names with name–card_number pairs is not a valid expression. - Reading "checked out" differently from the examiner — the professor's assumption ("nothing is borrowed") is stated and must be restated in your answer.
Recap + bridge: "Borrowers with nothing out" is a set-difference question: all borrowers minus borrowers present in the loans table, written as in relational algebra and as NOT IN in SQL. The session closes by gathering its exam lessons: how to structure answers, and what to practice.
Real-world & domain connection: The query runs against a library management system — borrowers, book copies, book loans — the classic domain where relational algebra's set operations and SQL's NOT IN are used daily. The same shape answers countless business questions: "customers with no orders," "students with no enrollments," "warehouses with no stock movements." Set difference is one of the most reused patterns in real analytics, which is why the professor insists the "NOT IN / set difference" family be practiced.
9.13 How to Structure an Exam Answer (and Exam Logistics)
9.13.1 The Structure That Earns Marks
Hook — the answer script that carries "very heavy weight." Across the session, the professor repeatedly returns to one theme: how an answer is structured matters as much as its conclusion. The equivalence question was the vehicle; the recipe is general.
Consolidated from the equivalence discussion, the answer-writing recipe: open with your understanding of the topic, restate what the question asks, show the check (closure computations, FD-by-FD validation), and close with the reason-based conclusion. This structure signals mastery to the evaluator and carries "very heavy weight" — even for a question whose final answer is "no." Keep the time limit in view while doing it.
The four-part answer script, with the equivalence question as the worked example.
- Your understanding of the topic — define equivalence, define a functional dependency: "Two FD sets are equivalent when every FD of one can be derived from the other — their closures are the same."
- What the question asks — restate the task: "I must test each FD of F2 against F1's closure, and each FD of F1 against F2's closure."
- The check — show the actual computation: covers ; never reaches H, so is underivable.
- The reason-based conclusion — "F1 and F2 are not equivalent because cannot be derived from F1."
The evaluator sees, in order: that you know what equivalence means, that you know what checking it requires, and that you actually checked it. Even for a "no" answer, that visible reasoning is where the marks live.
9.13.2 Typed or Scanned? The Open Question
Q: For the questions, do we have to give answers on the computer itself, or could both options be possible? A: I am not sure about it. The instructions say there could be two possibilities — either you have to type, or there is typing and scanning also. You will have to discuss with the team who is there. I am not certain.
Q: Sometimes the exam restricts scanning and uploading — and some of our questions need drawings. A: Yes, so you will have to see for it — some exams restrict scanning and upload, especially when diagrams need to be drawn. Discuss it with the team.
Two students raised the same point from different angles — what format must answers take, and what if diagrams are involved — so they form one canonical Q&A: the format (typing only, or typing plus scanning) is not yet settled, and scanning/upload restrictions are a known possibility for drawing-heavy questions. Confirm with the exam team; do not assume.
The movies question in the paper (a second-part question about movies) was flagged but not discussed: the professor notes it "may take some time" and defers it — the FD-set equivalence question (Q2c) was the one he chose to develop fully.
9.13.3 Say Something: The Cost of Fearing Wrong Answers
Early in the session, when few students were answering, the professor paused the content to make a point about participation that applies directly to exam preparation: our education system mostly works on being correct all the time, and sometimes, fearing that an answer might be wrong, we take no action at all. That fear is the real loss. "Even if you consider it as a gambling game — just pick one of them." Saying something matters more than being right: "whatever be your reasoning, that's secondary — but just say something. It is important, trust me, it is important to say something." The reasoning can be fixed later; a mind that freezes in silence cannot be corrected. In a revision session this plays out visibly — the students who spoke up (even with wrong guesses) were the ones who got the deepest explanations, because their wrong answers surfaced the exact confusion the professor could then resolve.
The professor's analogy — answering as a gamble. When fear of being wrong blocks action, treat the attempt as a gamble: "just pick one of them." The expected value of a wrong guess is a correction; the expected value of silence is nothing — no feedback, no learning, no marks. The same logic transfers to the exam hall: a partially reasoned attempt earns partial credit and shows the evaluator your thinking; a blank page shows nothing and can be corrected by no one.
Pitfalls:
- Answering a "no" question with only the word "no" — the reasoning structure is where the marks are.
- Writing the closure check without showing the walks — the evaluator must see the computations, not just the conclusion.
- Planning an answer script that exceeds the time budget — "mind the time limit; you have that responsibility as well."
- Sitting out of practice because an attempt might be wrong — the session's own lesson: wrong answers surfaced the deepest explanations.
Recap + bridge: Structure the exam answer in four parts — understanding, restatement, check, conclusion — and never fear writing a reasoned attempt. The practice list from the old paper (ER-to-relational conversion, BCNF violation check, FD-set equivalence, SQL/relational-algebra query) plus the quiz lessons are collected next in the exam guidance summary.
Real-world & domain connection: The four-part script is the standard shape of technical communication beyond the exam: requirements understanding first, problem restatement, method and computations, evidence-based conclusion — the structure of a good bug report, design doc, or incident postmortem. The professor's "say something" lesson is likewise professional: in reviews, standups, and design meetings, the people who voice tentative ideas get the corrections that turn them into experts.
Exam Guidance Summary
The exam-relevant facts of this revision session, collected in one place.
- Quiz answer keys are being revised. Question 1 (primary key choice): all four options are correct — any marked option gets the marks. Question 2 (1:N with total participation mapping): B and C are both correct; C is the most accurate. Question 3 (normalization of ): the option claiming "in 2NF" is the most appropriate answer, but the reasoning given in the options was wrong (2NF is about partial dependency / full functional dependency, not transitive dependency); updated keys will be released. The 2NF-definition question: "every non-prime attribute is fully functionally dependent on every candidate key" is the correct statement; both "primary key" and "any candidate key" wordings are marked correct.
- ER-diagram questions: go for full marks. Expected of you: identify entities, attributes, relationships, keys, and foreign keys; convert to a relational schema. The exam question papers follow the same style as the old paper practiced here.
- (min, max) cardinality reading will not appear in the mid-semester or the mid-semester makeup — but you should still know how to read it (Navathe pages 83 and 85).
- BCNF questions have a shortcut: check only whether each FD's left-hand side is a candidate key or super key; you do not need all candidate keys.
- "Determine all keys" questions: be careful not to declare a single attribute a key when only a combination is a key.
- FD-set equivalence: equivalence means each FD of one set derivable from the other; prove non-equivalence by naming a specific FD that cannot be derived (e.g., when F1 has no H).
- Answer-writing strategy: write your understanding of the topic, what the question asks, the check you perform, and the reason-based conclusion — it carries heavy weight with the evaluator; respect the time limit.
- Answer format (typed vs scanned) is not yet known — confirm with the exam team; scanning/uploading is sometimes restricted for exams requiring drawings.
- Practice list: the three old-paper questions (ER-to-relational conversion; BCNF violation check; FD-set equivalence) plus the SQL/relational-algebra query question. Practice is non-negotiable — "there is no substitute for practice." Email attempts for feedback; optional live half-hour practice session midweek by mail.
- SQL/relational-algebra questions take effort — practice queries of the "NOT IN / set difference" family.
Key Industry Applications
- Primary-key selection is a real DBA decision. In practice a database administrator picks the primary key from the candidate set by preference — smallest key, stability, lookup speed — and the choice need not be justifiable to anyone else. This is exactly why database design tools and textbooks treat candidate keys as equal alternatives.
- Denormalization for performance. Real systems often deliberately keep redundancy (sometimes back to 2NF) to avoid expensive joins — the professor explicitly flags this performance trade-off as the bridge to the course's later NoSQL discussion. E-commerce orders and analytics warehouses are everyday examples: duplicated facts are kept where reads must be fast.
- Redundancy breeds uncertainty. The email-ID-to-name example is a small model of real data-quality failures: duplicated facts drift apart (17 copies say one thing, 3 say another), and the database loses trustworthiness. Every CRM and master-data project exists to fight exactly this.
- Library systems (borrowers, book copies, book loans) are the everyday domain for relational algebra set difference and SQL NOT IN queries — and the same shape answers "customers with no orders," "students with no enrollments," and similar business questions.
- Bank–branch modeling shows how cardinality plus total participation reads in a real domain: every bank has branches, every branch belongs to exactly one bank.
- Reading (min, max) notations is a transferable skill: even though not exam-tested, real-world ER diagrams (and tools that generate them) use this notation, so knowing which side a label describes matters beyond the course.
- The exam answer script is the professional report shape. Understanding, restatement, check, conclusion — the same four parts structure design documents, bug reports, and incident write-ups; and the "say something" lesson applies in every technical review.
DDA Lecture 9 notes · Candidate Keys, ER-to-Relational Mapping, and Normalization Revision
Sections Breakdown
The primary-key quiz and its resolution: any candidate key is a valid primary key, and the choice is the database administrator's prerogative.
The side-label reading rule for one-to-many: each label constrains its own side, 'one' means at most one, and the full student debate over one-to-many versus many-to-one.
Mapping a binary 1:N relationship with total participation: the always-safe association relation, then the lossless merge into the one-side relation.
Why normalize: proper semantics, least redundancy, no spurious tuples, and a schema that scales; redundancy as a correctness problem and the email-ID example.
The four definitions at a glance: 1NF atomic cells, 2NF partial dependencies, 3NF transitive dependencies, BCNF super-key left sides, and the quiz wording question.
Worked example on A->B, A->C, CD->E, B->D, E->A: closures, the four candidate keys A, CD, E, BC, and FD-by-FD 2NF, 3NF, BCNF checks.
Why every candidate key must be checked: Armstrong's axioms, the closure F+ of an FD set, minimal covers, and why the key search stays finite.
Old paper question 1: converting an ER diagram into a relational schema, with the bank-branch total-participation reading and the professor's exam checklist.
The (min, max) cardinality notation: each pair describes the entity beside it, min > 0 means total participation, and the professor's own self-correction.
Old paper question 2: the BCNF shortcut — only left-side closures matter; CH+ misses E so CH's FD violates; and 'determine all keys' with AB, AC, BC.
Old paper question 2(c): FD-set equivalence as same-closure, proved by naming an underivable FD (E->H), with the four-step answer script.
Borrowers with no books checked out: relational algebra set difference and SQL NOT IN, with a NULL warning and the NOT EXISTS alternative.
How to structure an exam answer: understanding, restatement, check, conclusion; typed-versus-scanned logistics; and the professor's 'say something' lesson.
The session's exam-relevant facts: re-keyed quiz answers, full marks in ER conversion, BCNF shortcuts, and the answer-writing strategy.
How the session's ideas apply in practice: DBA key choice, denormalization, data-quality drift, library queries, and bank-branch modeling.
Exam Revision Notes
Below is the distilled, exam-ready core. Every entry comes from the full explanation above. Use this section for rapid review; return to the main notes when a point needs more context.
Choosing a Primary Key from Candidate Keys
Must-know: A primary key is the one candidate key the DBA chooses; any criterion is formally acceptable - the quiz keyed all four options correct.
⚠️ Top pitfall: Thinking 'fewest attributes wins' is a rule; it is only a preference, and the DBA's choice needs no third-party justification.
Self-check: Why is 'ability to uniquely identify tuples' not a distinguishing criterion among candidate keys?
Connects to: 9.5 The Normal-Form Definitions at a Glance
Reading a One-to-Many Relationship
Must-know: Each side's label describes that side: 'one' = at most one relationship (zero allowed); 'many' = zero or more. Total participation changes the minimum, not the maximum.
⚠️ Top pitfall: Reading 'one-to-many' as 'one X has many Y's' without checking which side carries the '1' label; the label constrains its own side.
Self-check: In 'student has at most one mentor, mentor has many students', which entity is the one side and what does total participation add?
Connects to: 9.3 Mapping a Binary One-to-Many Relationship with Total Participation, 9.9 Reading (min, max) Cardinality Notation
Mapping a Binary One-to-Many Relationship with Total Participation
Must-know: 1:N with total participation on the one side: the merge (option C) is most accurate - primary key of the merged relation is the one side's key, other side's key is a foreign key; without total participation use the separate association relation.
⚠️ Top pitfall: Merging when the one side lacks total participation - rows would carry null foreign keys; the merge is justified only by total participation.
Self-check: Why is the primary key of the merged relation X's key and not Y's?
Connects to: 9.2 Reading a "One-to-Many" Relationship, 9.4 Why We Normalize: The Goals of a Good Database Design Schema
Why We Normalize: The Goals of a Good Database Design Schema
Must-know: Goals of a good schema: proper semantics, least redundancy and no anomalies, no spurious tuples/lossless join, plus scalable and long lasting. Redundancy is a correctness problem, not a space problem.
⚠️ Top pitfall: Treating redundancy as a space problem; 1NF is assumed by all later normal forms; any decomposition must preserve a lossless join.
Self-check: Why does redundancy create uncertainty in the email-ID-to-name example?
Connects to: 9.5 The Normal-Form Definitions at a Glance
The Normal-Form Definitions at a Glance
Must-know: 2NF: every non-prime attribute fully functionally dependent on every candidate key (no partial dependency). 3NF: alpha->beta violates iff alpha is not a super key AND beta is not prime. BCNF: every FD's left side must be a super key.
⚠️ Top pitfall: Checking 2NF only against the primary key; the rule applies to any candidate key.
Self-check: When does an FD with a non-superkey left side still satisfy 3NF?
Connects to: 9.6 Worked Example: Finding Candidate Keys and Checking 2NF, 3NF, BCNF, 9.10 Old Paper Question 2: Which Functional Dependencies Violate BCNF?
Worked Example: Finding Candidate Keys and Checking 2NF, 3NF, BCNF
Must-know: Closures A+, CD+, E+, BC+ all reach the whole relation: candidate keys are A, CD, E, BC. B->D is partial in shape but D is prime, so the relation is in 2NF and 3NF; BCNF fails on B->D.
⚠️ Top pitfall: Judging B->D a 2NF violation by shape alone - a partial dependency also needs a non-prime right side.
Self-check: Why is E->A not a transitive dependency in the violating sense?
Connects to: 9.5 The Normal-Form Definitions at a Glance, 9.7 Why Check Every Candidate Key? Closure, Armstrong's Rules, Minimal Cover, 9.10 Old Paper Question 2: Which Functional Dependencies Violate BCNF?
Why Check Every Candidate Key? Closure, Armstrong's Rules, Minimal Cover
Must-know: Armstrong's axioms (reflexivity, augmentation, transitivity) generate the closure F+; a minimal cover is an equivalent minimal FD set used for schema synthesis; candidate-key checks guard against lost dependencies.
⚠️ Top pitfall: Assuming only FDs written in the set hold - Armstrong's rules derive hidden FDs (e.g., A->D from A->B and B->D).
Self-check: Why does finding A as a candidate key eliminate all supersets containing A from the search?
Connects to: 9.6 Worked Example: Finding Candidate Keys and Checking 2NF, 3NF, BCNF, 9.11 Old Paper Question 2(c): Are Two FD Sets Equivalent?
Old Paper Question 1: From an ER Diagram to a Relational Schema
Must-know: ER-to-relational conversion: identify entities, attributes, relationships, keys, then foreign keys; 1:N without total participation keeps a separate relationship relation; with total participation on the one side, merge.
⚠️ Top pitfall: Merging a 1:N relationship without total participation - nulls appear; the merge is reserved for the total-participation case.
Self-check: In the bank-branch reading, what does the double line add to each side's minimum?
Connects to: 9.2 Reading a "One-to-Many" Relationship, 9.3 Mapping a Binary One-to-Many Relationship with Total Participation, 9.9 Reading (min, max) Cardinality Notation
Reading (min, max) Cardinality Notation
Must-know: A (min,max) pair describes the entity on whose side it is written: each entity participates in at least min and at most max relationship instances; min=0 partial, min>0 total. Not exam-tested, but expected as literacy.
⚠️ Top pitfall: Reading the pair as describing the other entity - the professor's own mid-answer mistake; the pair belongs to the entity beside it.
Self-check: What does (2,30) on the employee side mean under the settled reading rule?
Connects to: 9.2 Reading a "One-to-Many" Relationship, 9.8 Old Paper Question 1: From an ER Diagram to a Relational Schema
Old Paper Question 2: Which Functional Dependencies Violate BCNF?
Must-know: BCNF shortcut: closure of each FD's left side; if it misses any attribute the FD violates. CH+ = {C,H,B,D,A} misses E, so CH's FD violates; the others pass. AB, AC, BC are keys; none of A, B, C individually.
⚠️ Top pitfall: Declaring a single attribute a key when only a combination is a key (A, B, C individually are not keys; AB, AC, BC are).
Self-check: Why does BCNF's check ignore the right-hand side of every FD?
Connects to: 9.5 The Normal-Form Definitions at a Glance, 9.6 Worked Example: Finding Candidate Keys and Checking 2NF, 3NF, BCNF
Old Paper Question 2(c): Are Two FD Sets Equivalent?
Must-know: Equivalence means the same closure: each FD of one set derivable from the other. Prove non-equivalence by naming an underivable FD (E->H when F1 has no H). Answer structure: understanding, question, check, conclusion.
⚠️ Top pitfall: Answering 'no' without the proof - the reasoning structure carries heavy weight with the evaluator.
Self-check: Why is deriving A->CD by the union rule not enough to show equivalence?
Connects to: 9.7 Why Check Every Candidate Key? Closure, Armstrong's Rules, Minimal Cover, 9.6 Worked Example: Finding Candidate Keys and Checking 2NF, 3NF, BCNF
Relational Algebra and SQL: Borrowers with No Books Checked Out
Must-know: Borrowers with no books: pi_name(BORROWER) - pi_name(BORROWER join BOOK_LOANS) in relational algebra; SELECT name FROM borrower WHERE card_number NOT IN (SELECT card_number FROM book_loans) in SQL.
⚠️ Top pitfall: NULLs in the NOT IN subquery silently return zero rows; use NOT EXISTS when the column can be NULL.
Self-check: Why must the projection be applied before the set difference?
Connects to: 9.13 How to Structure an Exam Answer (and Exam Logistics)
How to Structure an Exam Answer (and Exam Logistics)
Must-know: Answer structure: understanding, restate the question, show the check, reason-based conclusion. Mind the time limit. Typed vs scanned format unconfirmed - ask the exam team.
⚠️ Top pitfall: Answering 'no' with only the word 'no' - the reasoning earns the marks; a blank attempt earns nothing.
Self-check: What are the four parts of the professor's answer script?
Connects to: 9.11 Old Paper Question 2(c): Are Two FD Sets Equivalent?, 9.6 Worked Example: Finding Candidate Keys and Checking 2NF, 3NF, BCNF
Exam Guidance Summary
Must-know: ER questions: full marks expected (entities, attributes, relationships, keys, foreign keys). BCNF: check left sides only. Equivalence: name the underivable FD. Answer script: understanding, question, check, conclusion.
⚠️ Top pitfall: Declaring single attributes keys when only combinations are keys; answering 'no' without the proof structure.
Self-check: Which quiz answers are being re-keyed in this session?
Connects to: 9.1 Choosing a Primary Key from Candidate Keys, 9.3 Mapping a Binary One-to-Many Relationship with Total Participation, 9.5 The Normal-Form Definitions at a Glance, 9.6 Worked Example: Finding Candidate Keys and Checking 2NF, 3NF, BCNF, 9.10 Old Paper Question 2: Which Functional Dependencies Violate BCNF?, 9.11 Old Paper Question 2(c): Are Two FD Sets Equivalent?, 9.12 Relational Algebra and SQL: Borrowers with No Books Checked Out, 9.13 How to Structure an Exam Answer (and Exam Logistics)
Key Industry Applications
Must-know: The session's concepts map to everyday practice: DBA key choice, denormalization trade-off, data-quality drift, set-difference queries, bank-branch modeling, (min, max) literacy.
⚠️ Top pitfall:
Self-check: Why does the professor tie denormalization to the later NoSQL discussion?
Connects to: 9.1 Choosing a Primary Key from Candidate Keys, 9.2 Reading a "One-to-Many" Relationship, 9.4 Why We Normalize: The Goals of a Good Database Design Schema, 9.9 Reading (min, max) Cardinality Notation, 9.12 Relational Algebra and SQL: Borrowers with No Books Checked Out
Was this lecture useful?
BitsNotes AI Assistant
Subject Notes AssistantConfigure AI Chat
Choose how to access the chatbotSigned in as
Powered by BitsNotes — 20 messages per day. No API key needed. Want unlimited access? Use "Bring Your Own Key" mode.
Sign in to use AI Chat
Get 20 free AI messages per day to ask questions about your lecture notes. Sign in with Google or GitHub — it takes 5 seconds.
Sign In to BitsNotesSwitch to "Bring Your Own Key" tab above for unlimited access with any OpenAI-compatible provider.