DEV Community

Cover image for 3NF vs BCNF: Normalisation Answers Interviewers Push Back On
NostrobeAI
NostrobeAI

Posted on

3NF vs BCNF: Normalisation Answers Interviewers Push Back On

Normalisation questions often start with definitions and then turn into a test of whether you understand the trade-offs. A useful answer gives the rule, then explains what it prevents and where the rule has limits. State the assumptions behind your example, especially the candidate keys and functional dependencies. That makes it possible to defend the normal form you claim instead of relying on a table’s current sample rows.

What is normalisation, and why use it?

Normalisation organises columns and tables to reduce redundant data and avoid insertion, update and deletion anomalies. It divides a large relation into smaller related tables connected by keys.

Follow-up: “Can you show me an anomaly?” Consider this table:

employee_id employee_name department_id department_name
17 Asha D4 Support
28 Ravi D4 Support

If the department is renamed, both rows need an update. Missing one leaves contradictory names. A new department with no employees yet cannot be recorded without inventing an employee row. If Asha is the last employee in Support, deleting her row also deletes the only record of that department. Separating department facts from employee facts avoids those problems. The department table can hold one row per department, while the employee table refers to its department by ID. That is the central practical reason to normalise: each fact has a clear home, so a change does not need to be repeated across unrelated rows.

What do 1NF, 2NF, 3NF and BCNF require?

1NF requires atomic values and no repeating groups. 2NF adds that each non-key attribute depends on the whole candidate key, not just part of a composite key. 3NF removes transitive dependencies of non-key attributes. BCNF requires every determinant in a non-trivial functional dependency to be a superkey.

Follow-up: “What does partial dependency mean?” In an order line relation keyed by (order_id, product_id), order_date depends on order_id alone. That is a partial dependency, so move order_date to an order table. “And transitive?” If employee_id determines department_id, and department_id determines department_name, department_name depends transitively on employee_id. Store department details with department_id instead.

What is a functional dependency?

X → Y means that any two rows with the same X value must have the same Y value. For example, student_id → student_name.

Follow-up: “Can we infer dependencies from the current rows?” No. Dependencies come from the meaning and rules of the data. A sample may happen to show one student name per course, but that does not establish that course determines student_name.

How can a relation be in 3NF but not BCNF?

3NF permits a non-trivial dependency X → A when X is a superkey or A is prime (part of a candidate key). BCNF removes that prime-attribute exception.

Follow-up: “Give me the classic case.” Let the relation be (student, subject, teacher), with each teacher teaching exactly one subject. The candidate keys are (student, subject) and (student, teacher): a student takes a subject with its assigned teacher. Thus subject and teacher are prime. The dependency teacher → subject satisfies 3NF because subject is prime, but teacher is not a superkey, so BCNF fails. Splitting it into (teacher, subject) and (student, teacher) removes that redundancy, but the dependency (student, subject) → teacher can no longer be checked inside one table; enforcing it needs a join. BCNF is not automatically the best choice if enforcing dependencies locally matters.

What are 4NF and 5NF?

4NF addresses non-trivial multivalued dependencies: independent sets of values should not be forced into every combination in one relation. 5NF, or project-join normal form, addresses join dependencies not implied by candidate keys.

Follow-up: “How do you fix a multivalued dependency?” Separate the independent facts into their own relations. These forms are less common in everyday design, but they can appear in exams.

What makes a decomposition lossless and dependency-preserving?

A lossless decomposition joins back to exactly the original rows, with no information lost and no spurious tuples added. A sufficient condition is that the shared attributes form a key of at least one resulting relation. Dependency preservation means each original functional dependency can be enforced on one relation without joining tables.

Follow-up: “Which property matters more?” Losslessness is essential to preserve the data. Dependency preservation is desirable, though a BCNF decomposition can sacrifice it. A spurious tuple is a false row created when decomposed relations are joined; it can happen when the shared attributes are not a key of either piece.

How do you calculate attribute closure?

X⁺ is the set of attributes determined by X under the functional dependencies. If X⁺ contains every attribute, X is a superkey; if no proper subset is a superkey, it is a candidate key.

Follow-up: “Show the steps.” For R(A, B, C) with A → B and B → C, start with A⁺ = {A}. Apply A → B to get {A, B}; then B → C gives {A, B, C}. A is therefore a candidate key. Closure also checks implication: if Y is in X⁺, the dependencies imply X → Y.

Should you always normalise to the highest normal form?

No. Normalisation improves write consistency and reduces redundancy, while each split may add joins to reads. Third normal form is a common practical stopping point for transactional systems; reporting and analytics may deliberately use denormalised schemas.

Follow-up: “Is duplicated data always a mistake?” Not necessarily. Denormalisation deliberately adds redundancy by combining tables or duplicating columns, often to reduce joins for frequent reads. A cached count or materialised total can be a deliberate read-performance trade-off if the system keeps it consistent on writes. Denormalisation also costs storage and makes write consistency your responsibility.

The full set of DBMS questions, including transactions, keys and indexing, is in our free DBMS interview questions page.

Top comments (0)