CS FundamentalsVery hardProduct company interview · GATE level
A relation R(City, Street, Zip) has FDs City, Street → Zip and Zip → City (candidate keys: {City, Street} and {Street, Zip}). Why is this the classic example where a lossless, dependency-preserving decomposition into BCNF is IMPOSSIBLE?
- A. Because it is always possible for every relation, including this one
- B. Because decomposing to remove the BCNF violation (Zip → City, since Zip alone is not a superkey) into R1(Zip, City) and R2(Zip, Street) loses the ability to directly check City, Street → Zip without rejoining the pieces, yet R1/R2 ARE each individually in BCNF and the decomposition is lossless — it is dependency preservation specifically that cannot be achieved alongside BCNF here
- C. Because this relation has no candidate keys at all
- D. Because Zip → City is a trivial dependency and doesn't need to be preserved
Correct answer: B. Because decomposing to remove the BCNF violation (Zip → City, since Zip alone is not a superkey) into R1(Zip, City) and R2(Zip, Street) loses the ability to directly check City, Street → Zip without rejoining the pieces, yet R1/R2 ARE each individually in BCNF and the decomposition is lossless — it is dependency preservation specifically that cannot be achieved alongside BCNF here
This is the textbook example showing BCNF cannot always be achieved while preserving all dependencies: splitting off Zip → City (since Zip isn't a superkey, violating BCNF) into R1(Zip, City) and R2(Zip, Street) gives a lossless, fully-BCNF-compliant pair, but City, Street → Zip can no longer be verified without joining R1 and R2 back together — demonstrating that BCNF and dependency-preservation can be mutually incompatible goals, unlike 3NF, which always admits a synthesis algorithm achieving both.
More DBMS and SQL questions
- The 3NF synthesis algorithm (based on a minimal cover of functional dependencies) is guaranteed to always produce a decomposition that is…
- Table Products(pid, pname, category, price, stock) rows: (1, 'Pen', 'Stationery', 10, 100), (2, 'Notebook', 'Stationery', 50, 0), (3…
- A database stores timestamps in UTC and converts to local time only at the application layer. A query does WHERE createdat BETWEEN…
- A column price NUMERIC (arbitrary precision decimal) is compared against a literal using price = 19.99. Why is this generally SAFE from…
- A relation R(A, B, C, D) has candidate key ABD (the ONLY candidate key) and FD AB → C (C is non-prime). Which normal form violation does…
- A query optimizer must decide between two equivalent plans for A JOIN B: (1) nested-loop join using an index on B, with A as the outer…