- Learn
- Computer Science & IT
- Programming
- Database Design and Advanced SQL
- Database Normalization
Database Normalization
IntermediateLesson 4 of 8 in Database Design and Advanced SQL Course
What you will learn
- Find facts that a single wide table stores more than once, name the problems this causes when data changes, and see how splitting the table into related tables removes them.
- Spot redundant facts and the three update anomaliesRead a flat table, find the facts it repeats, and describe the modification, insertion and deletion anomalies that the repetition causes.
- Split a table into related tables and rebuild it with joinsDecompose a flat table into tables linked by keys and foreign keys, recover the original rows with joins, and see why a careless split creates false rows.
- Spot redundant facts and the three update anomalies
- State the rules in data as functional dependencies, derive the dependencies they imply, and use attribute closure to find every candidate key of a table.
- Identify functional dependencies from business rulesDefine a functional dependency, write the dependencies of a table from what its data means, tell full, partial and transitive dependencies apart, and test a proposed rule against stored data with SQL.
- Derive implied dependencies with Armstrong's axioms and closureUse Armstrong's axioms and the attribute closure algorithm to decide whether a dependency follows from a given set of dependencies.
- Find candidate keys and prime attributesDistinguish superkeys, candidate keys and primary keys, find every candidate key systematically with closure, and classify attributes as prime or non-prime.
- Identify functional dependencies from business rules
- Test tables against first, second and third normal form and decompose them until every non-key attribute depends on the key, the whole key and nothing but the key.
- Bring tables to first normal formRecognize multivalued cells and repeating groups, and restructure them into rows of a separate table so that every value is atomic.
- Remove partial dependencies to reach second normal formTest a table for partial dependencies on its candidate keys and decompose it into second normal form.
- Remove transitive dependencies to reach third normal formTest a table for third normal form with both the transitive-dependency definition and the superkey test, and decompose it into third normal form.
- Bring tables to first normal form
- Test and decompose tables into Boyce–Codd normal form, prove that a decomposition loses no information, check which rules it preserves, and choose between BCNF and 3NF.
- Test and decompose tables into Boyce–Codd normal formApply the BCNF test, explain how BCNF differs from 3NF, and use the BCNF decomposition algorithm step by step.
- Prove that a decomposition is losslessExplain what a lossless-join decomposition is, apply the shared-attribute test to a split into two tables, and extend the reasoning to splits into more tables.
- Preserve dependencies and choose between BCNF and 3NFTest whether a decomposition preserves every dependency, synthesize a 3NF design from a canonical cover, and decide between BCNF and 3NF when they conflict.
- Test and decompose tables into Boyce–Codd normal form
- Weigh the faster reads that deliberate redundancy can bring against its costs in writes, storage and consistency, and keep a denormalized design correct.
- Weigh the benefits and costs of denormalizationDescribe the common denormalization techniques, compare their read benefits with their write and consistency costs, and recognize situations that do and do not justify them.
- Keep a denormalized design consistent and documentedFollow a measured process for denormalizing, keep the copies synchronized with transactions, triggers or refreshes, and detect and repair drift.
- Weigh the benefits and costs of denormalization
Database Normalization study guide
1Recognize redundancy and update anomalies
A report can be convenient to read and still be difficult to maintain. An order-line table shows how repeated customer, order, and product facts create three kinds of anomaly. Separating those facts gives each change a clear place to happen, but the identifiers must preserve their connections. Follow the split through keys, foreign keys, migration, and joins to see both a successful repair and a split that creates false rows.
1.1 Spot redundant facts and the three update anomalies
A wide table can answer a report in one read while making ordinary changes surprisingly risky. To see why, separate the facts a row records from the values that happen to repeat.
Read the facts in an order line
The table order_items(order_id, order_date, customer_id, customer_name, customer_city, product_id, product_name, list_price, quantity) stores one row per product on an order. Its key is (order_id, product_id). Order 1001, dated 2026-03-02, has two lines for customer C7, Ana Ruiz in Lyon: P1, "Desk lamp", at 24.00 with quantity 2, and P3, "USB cable", at 6.50 with quantity 3. Order 1002, dated 2026-03-05, has one line for C9, Ben Okafor in Leeds: P1 with quantity 1.
Several facts appear twice. Order 1001 has one date and one customer, although both appear on two lines. C7 has one name and city, repeated on her lines. P1 has one name and current list price, repeated across orders. Redundancy means storing the same fact about the same thing again. Two different customers living in Lyon are two facts; that repeated city value alone is not redundancy.
Follow a change through the table
| Change | What goes wrong | Anomaly |
|---|---|---|
| Ana moves from Lyon to Paris | Updating one line leaves the other line saying Lyon | Modification |
| Add P4, "Monitor arm", priced 89.00 | There is no order to supply the required order key | Insertion |
| Delete order 1002 | Ben's only stored name and city disappear too | Deletion |
A modification anomaly, also called an update anomaly, makes one real change require several row changes. Contradictory copies are the main danger, beyond the extra storage. This statement updates all of Ana's existing copies:
UPDATE order_items
SET customer_city = 'Paris'
WHERE customer_id = 'C7';
It repairs this change, but a later program can still update only one line. The design continues to allow disagreement.
An insertion anomaly ties a fact to an unrelated event. A primary key cannot contain NULL, so a product cannot appear here until an order supplies order_id. Entering a fake order 0 would invent an event. A customer who has never ordered has the same problem.
A deletion anomaly removes a fact that should survive. Removing the USB cable line from order 1001 also removes the only record of that product's name and price. The intended action was to remove a line, not retire the product.
Locate the design problem
The table mixes orders, customers, products, and line quantities. A product name follows from product_id, although the row key also contains order_id. A customer's city follows from customer_id, which is not the row key. These rules explain exactly why the facts repeat.
Normalization restructures tables around these rules, called functional dependencies. Customer facts move to a customer table, product facts to a product table, and the order line keeps the quantity for its order-product pair.
Key Takeaways
- Redundancy repeats one fact about one thing, not merely the same value.
- A modification anomaly lets copies disagree after a partial update.
- Insertion and deletion anomalies tie the existence of unrelated facts together.
- Facts determined by part of a row key, or by another non-key column, signal where to split.
1.2 Split a table into related tables and rebuild it with joins
Splitting a table is useful only if the smaller tables still record the same relationships. Keep the identifiers that connect the facts, then verify that a join reconstructs the original rows.
Give each fact a home
A decomposition replaces one relation with smaller relations whose columns together cover the original. A projection selects columns and removes duplicate rows. For the order data, use:
| Table | Primary key | Other columns |
|---|---|---|
customers | customer_id | customer_name, customer_city |
orders | order_id | order_date, customer_id |
products | product_id | product_name, list_price |
order_lines | (order_id, product_id) | quantity |
orders.customer_id references customers; the two identifiers in order_lines reference orders and products. Ana's move now changes one customer row. P4 can be inserted directly into products. Deleting order 1002 and its lines leaves Ben's customer row in place.
Rebuild the report
SELECT ol.order_id, o.order_date,
c.customer_id, c.customer_name, c.customer_city,
p.product_id, p.product_name, p.list_price,
ol.quantity
FROM order_lines ol
JOIN orders o ON o.order_id = ol.order_id
JOIN customers c ON c.customer_id = o.customer_id
JOIN products p ON p.product_id = ol.product_id;
Each line finds its order, that order's customer, and its product. With the three original lines, the query returns those same three rows. A view can expose this joined report while writes use the separate tables.
Move existing data in the right order
Create the tables and their primary and foreign keys first. Fill customers and products before orders, then fill order_lines, because referenced rows must already exist. For example:
INSERT INTO customers
(customer_id, customer_name, customer_city)
SELECT DISTINCT customer_id, customer_name, customer_city
FROM order_items;
DISTINCT removes identical customer triples. If C7 has both Lyon and Paris, those triples differ, and the customer primary key rejects the duplicate identifier. Resolve which city is correct before migration; deduplication cannot decide a business fact. Perform the migration against a consistent set of source data so later writes do not escape the transfer.
Avoid false combinations
Suppose employee rows are (E1, Ana, D1, Sales) and (E2, Ben, D2, Sales). Splitting into (emp_id, emp_name, dept_name) and (dept_id, dept_name) loses the link between employee and department identifier. Joining on "Sales" matches each employee with both departments: four rows, including two spurious tuples, or false rows.
A lossless decomposition reconstructs exactly the original relation. A lossy split can add false rows: the missing information is which combinations belonged together. A dependency-preserving split also lets the rules enforced within individual tables together imply every original functional dependency.
More tables alone do not improve a design. Splitting customers into separate name and city tables joined on customer_id is lossless, but removes no repeated fact and adds work to queries that need both.
Key Takeaways
- Keep entity identifiers in the tables that need to reference them.
- Projection removes duplicate rows; SQL needs SELECT DISTINCT to do this.
- Load referenced rows before rows with foreign keys to them.
- A lossless join returns exactly the original rows, without spurious combinations.
- Dependency preservation allows rules to be checked without joining tables.
2Reason with functional dependencies and keys
Table design depends on rules about which values fix other values. Functional dependencies turn those rules into statements you can reason with. Deriving their consequences and computing attribute closures reveals the keys hidden in a schema. Finding every candidate key then makes it possible to distinguish prime from non-prime attributes and apply the normal-form tests correctly, even when the primary key tells only part of the story.
2.1 Identify functional dependencies from business rules
A functional dependency expresses a rule about all valid rows, including rows that have not been entered yet. Write the rule from the meaning of the data, then use stored rows to look for violations.
Read the arrow precisely
A functional dependency (FD), X → Y, means that any two rows agreeing on every attribute in X must agree on every attribute in Y. X is the determinant. Several attributes on the left act together.
The order-line rules are:
order_id → order_date, customer_id: each order has one date and customer.customer_id → customer_name, customer_city: each customer has one name and city.product_id → product_name, list_price: each product has one name and current list price.{order_id, product_id} → quantity: each order-product pair has one quantity.
One order can contain different quantities of different products. The last dependency therefore does not give order_id → quantity. Also, customer_id → customer_city does not reverse: several customers can live in the same city.
Separate rules from observations
The current rows might show Lyon paired only with Ana and Leeds only with Ben. That does not establish customer_city → customer_name; another customer in Lyon can join tomorrow. Two rows with one customer identifier but different cities do disprove customer_id → customer_city for those stored rows.
Ask, "Could two valid rows have the same X and different Y?" If yes, X → Y is not a business rule. Column names alone cannot settle this. product_id → list_price describes a current catalog price. It does not describe price_paid, which can differ between purchases.
Check a rule with SQL
For recorded, non-null cities, this query finds customer identifiers with conflicting values:
SELECT customer_id
FROM order_items
GROUP BY customer_id
HAVING COUNT(DISTINCT customer_city) > 1;
Every returned identifier needs investigation. No returned rows means the data currently agrees with the rule, not that future rows must obey it. COUNT(DISTINCT ...) ignores NULL; enforce NOT NULL when a city is required, and check missing values separately when cleaning data. An unknown value is not evidence that two known cities agree.
Classify the dependency
| Type | Meaning | Order-line example |
|---|---|---|
| Trivial | The right side is contained in the left | {order_id, product_id} → product_id |
| Full | No proper subset of the determinant determines the dependent attribute | {order_id, product_id} → quantity |
| Partial | A proper subset already determines the dependent attribute | The line key determines product_name through product_id alone |
| Transitive | A rule follows through an intermediate determinant | order_id → customer_id → customer_city |
A trivial dependency holds in every relation and creates no normal-form violation. Full and partial describe whether the entire determinant is needed. In the transitive example, customer_id does not determine the whole order-line row, yet determines the city. That separate customer fact is what the design should move.
Key Takeaways
- X → Y requires agreement on Y whenever two rows agree on all of X.
- Business rules establish FDs; sample rows can expose violations.
- An arrow cannot be reversed, and a composite left side cannot be split.
- A full dependency needs the whole determinant; a partial one does not.
- COUNT(DISTINCT ...) ignores NULL, so missing values need their own check.
2.2 Derive implied dependencies with Armstrong's axioms and closure
A short list of dependencies can imply many more. Attribute closure provides a reliable way to discover the attributes fixed by a starting set, without guessing every possible chain of rules.
Derive rules without changing their meaning
Armstrong's axioms are three rules for deriving FDs:
| Axiom | Valid step | Meaning |
|---|---|---|
| Reflexivity | If Y is contained in X, then X → Y | A set determines its own parts |
| Augmentation | X → Y gives XZ → YZ | Add the same attributes to both sides |
| Transitivity | X → Y and Y → Z give X → Z | Follow a chain of determinations |
XZ means the union of X and Z. The axioms are sound: every derived dependency really follows. They are also complete: every implied FD can be derived using them. The complete collection of implied dependencies is F⁺, the closure of an FD set F.
Three shortcuts follow. Union combines X → Y and X → Z into X → YZ. Decomposition splits X → YZ into X → Y and X → Z. Pseudotransitivity combines X → Y with WY → Z to give WX → Z. Decomposition applies to the right side; AB → C alone never licenses A → C.
Work through an implied dependency
Use R(A, B, C, D, E) with F = {A → B, B → C, CD → E}. First, transitivity gives A → C. Augment with D to obtain AD → CD. Then CD → E gives AD → E by transitivity. D remains necessary: A alone has no route to D or E.
Compute attribute closure
The attribute closure X⁺ contains every attribute determined by X under F.
- Start with the attributes in X.
- Find an FD whose entire left side is present, and add its right side.
- Keep scanning the rules until a complete pass adds nothing.
For A⁺, start with {A}. A → B adds B; B → C adds C. CD → E cannot fire because D is missing. The result is {A, B, C}.
For {A, D}⁺, start with both A and D. Add B, then C, and now CD → E adds E. The closure is {A, B, C, D, E}. Starting with {C, D} adds E only, giving {C, D, E}.
An FD can become usable after an earlier pass has finished. If the rules are listed as CD → E, B → C, A → B, the first pass from {A, D} adds only B. A later pass adds C and another adds E. Stopping after one scan gives an incomplete answer.
Use the result
X → Y follows exactly when all attributes of Y appear in X⁺. X is a superkey of R exactly when X⁺ contains all attributes of R. Thus AD is a superkey, while A is not, even though A determines several columns.
In the order table, order_id reaches customer name and city through customer_id. It still does not reach product_id or quantity. Add product_id, and the pair reaches all nine attributes.
Key Takeaways
- Armstrong's axioms are reflexivity, augmentation, and transitivity.
- Only a dependency's right side can be split without further evidence.
- Closure starts with the supplied attributes and repeatedly applies usable FDs.
- A composite left side fires only when all its attributes are present.
- X → Y follows exactly when Y is contained in X⁺.
- Complete attribute closure proves a superkey, but minimality still needs checking.
2.3 Find candidate keys and prime attributes
A key must identify rows for every valid population of a table. Closure tests whether a set can do that; minimality tests whether every attribute in that set is needed.
Keep the key terms separate
A superkey determines every attribute of the relation. A candidate key is a superkey with no removable attribute. Minimal means no proper subset works, not that the key has fewer columns than every other candidate key. A design chooses one candidate as its primary key. The others are alternate keys, represented in SQL by UNIQUE together with NOT NULL.
An attribute is prime if it belongs to at least one candidate key. It is non-prime if it belongs to none. The primary-key choice does not change this classification.
Find every candidate key systematically
First find attributes absent from every right side in the FD set. Nothing can add them through closure, so every key must contain them. Compute that starting set's closure. If it reaches the whole relation, it is the only candidate key: every possible key contains it, and any extra attribute would be removable.
If the closure is incomplete, try adding one remaining attribute at a time, then pairs, and continue as needed. Keep complete closures only when the starting set contains no smaller candidate key. Continue the search after the first success; different additions can produce different keys.
For R(A, B, C, D, E) with A → B, B → C, CD → E:
- A and D occur on no right side, so both are mandatory.
- {A, D}⁺ adds B, C, and E, reaching all columns.
- {A, D} is therefore the only candidate key.
- A and D are prime; B, C, and E are non-prime.
Handle overlapping keys
In teaching(student, course, instructor), each instructor teaches one course, and each student has one instructor for a given course. The rules are instructor → course and {student, course} → instructor.
student is mandatory, but alone determines nothing else. Adding course reaches instructor. Adding instructor reaches course. The two candidate keys are therefore {student, course} and {student, instructor}. Removing either attribute from either pair breaks uniqueness. All three attributes are prime, even if only one pair is chosen as primary key.
Do not mistake an identifier for normalization
For the order table, {order_id, product_id} is the only candidate key under its rules. Adding quantity gives a superkey, but quantity is removable, so the larger set is not a candidate key.
Adding a generated line_id creates a new way to identify a row. It does not remove product_id → product_name or customer_id → customer_city, so the repeated facts remain. The original order-product rule still needs a UNIQUE (order_id, product_id) constraint, with non-null identifiers, to prevent duplicate lines. Declaring a simple primary key cannot erase dependencies involving an alternate composite key.
Key Takeaways
- A candidate key is a minimal superkey; minimality is tested by removing attributes.
- Attributes absent from every FD right side belong to every key.
- Find all candidate keys before classifying prime attributes.
- A primary key is a choice among candidate keys, not the only possible key.
- A surrogate identifier leaves existing dependencies and redundancy intact.
3Normalize tables step by step to third normal form
Normalization builds from atomic values to tables whose facts depend on the right keys. Start by replacing lists and fixed repeating slots with rows. Then use the candidate keys to remove partial dependencies, followed by transitive dependencies. The order-line design provides a complete path through the first three normal forms, while overlapping keys show why the precise 3NF test is more reliable than a slogan about primary keys.
3.1 Bring tables to first normal form
First normal form makes each row and each value usable as relational data. It removes collections hidden inside cells, but it does not yet remove the redundancy caused by functional dependencies.
Store one value from the intended domain
A relation is in first normal form (1NF) when each attribute contains a single atomic value from its domain, without lists or nested tables. Rows are distinguishable by a key. In SQL, declare that key so duplicate rows cannot silently accumulate.
Consider employees(emp_id, emp_name, skills) with (E1, Ana, "SQL, Python") and (E2, Ben, "SQL"). The first skills cell holds two independently useful values. A text search for "SQL" can also match "NoSQL". Renaming a skill requires editing text fragments, and a foreign key cannot validate each embedded skill separately.
Move the collection into rows:
employees | employee_skills | ||
|---|---|---|---|
emp_id | emp_name | emp_id | skill |
| E1 | Ana | E1 | SQL |
| E2 | Ben | E1 | Python |
| E2 | SQL |
The employee key is emp_id; the skill-assignment key is (emp_id, skill). That composite key prevents the same skill from being assigned twice to the same employee. Its emp_id also references employees. Finding SQL users is now an exact comparison:
SELECT emp_id
FROM employee_skills
WHERE skill = 'SQL';
Recognize repeating groups
Columns named skill1, skill2, and skill3 spread the same collection across a fixed number of slots. Finding SQL users requires checking three columns. A fourth skill requires a schema change; employees with one skill leave empty slots. One row per employee-skill pair removes the fixed limit and gives every skill the same query and constraint rules.
Textbooks differ on whether atomic repeating columns themselves violate 1NF. The practical repair stays the same: store an independently managed collection as rows, connected by its owner's key.
Distinguish atomicity from small pieces of text
Atomicity depends on the domain and the operations the design needs. A full name can be one value when used as a whole. If the application needs family-name sorting, store the relevant name parts explicitly. A course code such as "CS-101" can remain its identifier while a separate department column supports department rules and queries. Splitting every string into its smallest possible pieces is not the aim.
Array and JSON types can hold documents that the application reads and writes as a whole. If individual elements need their own searches, foreign keys, or joins, a related table gives them those relational operations directly.
Check what 1NF leaves behind
Flattening the employee example into (emp_id, emp_name, skill) with key (emp_id, skill) also yields atomic values. It repeats Ana's name for every skill, because emp_id alone determines emp_name. The table is in 1NF but still needs second normal form. Likewise, every cell of order_items is atomic even though customer and product facts repeat.
Key Takeaways
- 1NF stores one atomic domain value per attribute and identifies rows by keys.
- Move independently managed lists to rows in a related table.
- Fixed numbered columns create a repeating group with an artificial size limit.
- Atomicity follows the intended use of a value, not the number of characters it contains.
- 1NF can still contain partial and transitive dependencies.
3.2 Remove partial dependencies to reach second normal form
Second normal form asks whether a non-prime fact needs an entire candidate key. If a smaller part of the key already fixes it, the table repeats that fact for each value of the remaining key attributes.
Apply the whole-key test
A table is in second normal form (2NF) when it is in 1NF and no non-prime attribute depends on a proper subset of any candidate key. Check every candidate key, including alternate keys. Prime attributes are excluded from this particular test.
A candidate key with one attribute has no nonempty smaller part that identifies an entity fact in these examples. When every candidate key is single-attribute, the 1NF table has no composite-key partial dependency to remove. A single-attribute primary key is not enough to conclude this if another candidate key is composite.
Work through the order-line key
The key of order_items is {order_id, product_id}. Compute the closures of its proper parts:
order_idreachesorder_date,customer_id,customer_name, andcustomer_city.product_idreachesproduct_nameandlist_price.- Neither part reaches
quantity; it needs the order-product pair.
The customer details in the first group follow through customer_id. They still depend on order_id alone, so they belong with the order-side facts at the 2NF stage.
Create orders(order_id, order_date, customer_id, customer_name, customer_city) and products(product_id, product_name, list_price). Keep order_lines(order_id, product_id, quantity). Each moved determinant becomes a key in its own table, and remains in order_lines as a foreign key. Joining on the identifiers reconstructs the original lines.
Verify both the repair and its limit
orders and products have single-attribute candidate keys under these rules. In order_lines, quantity depends on the full pair. All three tables pass 2NF. A product can now be added before any order, and changing its name changes one product row.
Customer details still repeat if Ana places order 1003. Both orders then store her name and city. This is a transitive dependency within orders, not a remaining dependency on part of its single-column key. Third normal form addresses it.
Transfer the method
For enrollments(student_id, course_id, student_name, course_title, grade), the pair (student_id, course_id) is the key. student_id → student_name and course_id → course_title show two partial dependencies. Split into students(student_id, student_name), courses(course_id, course_title), and enrollments(student_id, course_id, grade). The grade stays with the pair because a student can receive different grades in different courses.
The right side matters as much as the left. In teaching(student, course, instructor), the keys are student-course and student-instructor. instructor → course uses part of a candidate key, but course is prime because it belongs to the other key. It therefore does not violate 2NF.
Key Takeaways
- 2NF removes partial dependencies of non-prime attributes on any candidate key.
- Compute closures of proper key subsets to locate the facts to move.
- Keep each moved determinant as the reference that connects the tables.
- An attribute that needs the whole composite key stays with that key.
- 2NF can leave transitive dependencies in single-key tables.
- A partial dependency with a prime right side does not violate 2NF.
3.3 Remove transitive dependencies to reach third normal form
Third normal form separates facts that depend on a key through another determinant. Its precise test also handles tables with overlapping candidate keys, where the phrase "non-key column" can be misleading.
Test the determinant and the right side
A relation is in third normal form (3NF) when it is in 2NF and no non-prime attribute depends transitively on a candidate key. An equivalent test, often called Zaniolo's test, is:
For each nontrivial FD X → A with one attribute on the right, X is a superkey or A is prime.
A trivial FD passes automatically. For a nontrivial one, compute the determinant's closure. If it reaches the whole relation, it passes. Otherwise, check whether the right-side attribute belongs to any candidate key. The FD fails only when both tests fail.
Remove the customer dependency
The 2NF relation orders(order_id, order_date, customer_id, customer_name, customer_city) has key order_id. The FD customer_id → customer_name, customer_city fails the test: customer_id does not determine an order's date or identifier, and name and city are non-prime.
Move that customer fact into customers(customer_id, customer_name, customer_city). Keep orders(order_id, order_date, customer_id). The customer identifier is a key of the new customer table and a foreign key in orders. Ana's city now has one stored home even when she places many orders. Together with products and order_lines, these are the four final 3NF tables.
Work another transitive chain
Suppose staff(emp_id, emp_name, dept_id, dept_name, dept_floor) has emp_id → emp_name, dept_id and dept_id → dept_name, dept_floor. Each employee determines a department; the department determines its name and floor. The department identifier is not a superkey of staff, and the department details are non-prime.
Use staff(emp_id, emp_name, dept_id) and departments(dept_id, dept_name, dept_floor). Moving a department to another floor now changes one row. The staff table keeps the employee-to-department assignment.
Check all relevant dependencies
For the original relation, checking the listed FDs with single-attribute right sides suffices for the 3NF test. After decomposition, include dependencies implied on each smaller relation. If R(A, B, C, D) has A → B and B → C, a part (A, C, D) still has A → C even though B is absent. A⁺ within that part contains A and C but not D, so A → C violates 3NF there when AD is its only key.
Not every dependency involving a column outside the primary key is a violation. A customer email declared UNIQUE NOT NULL is an alternate candidate key. It may determine the name without breaking 3NF.
3NF also allows a prime right side. In teaching, the keys student-course and student-instructor make course prime. Thus instructor → course passes 3NF even though instructor is not a superkey. The instructor's course can still repeat across students; BCNF removes this exception.
Key Takeaways
- For every nontrivial X → A, 3NF requires a superkey X or a prime A.
- Move customer and department facts when their determinant is not a superkey and their attributes are non-prime.
- A foreign key keeps the original entity assignment after the split.
- Projected tables must be checked for implied dependencies too.
- Alternate keys count as superkeys, even when they are not the primary key.
- 3NF permits some redundancy through its prime-attribute exception.
4Reach BCNF with lossless, dependency-preserving designs
A table can meet 3NF while still repeating a fact, and a lossless split can still make a business rule harder to enforce. BCNF, losslessness, and dependency preservation address these different concerns. Work through the stricter test, prove joins with shared-attribute closures, and compare decomposition with 3NF synthesis. The final choice depends on both the redundancy removed and the checks the resulting tables can support.
4.1 Test and decompose tables into Boyce–Codd normal form
Boyce–Codd normal form uses a stricter rule than 3NF: a determinant must identify the whole relation. The stricter rule removes redundancy that 3NF can allow when all involved attributes belong to candidate keys.
Apply the BCNF test
A relation is in Boyce–Codd normal form (BCNF) if every nontrivial FD X → Y has a superkey X. Compute X⁺ and compare it with all attributes of the current relation. A prime right side provides no exception.
Every BCNF relation is in 3NF. Under the dependency model used here, a 3NF relation with only one candidate key is already in BCNF. The difference arises with overlapping keys.
In teaching(student, course, instructor), instructor → course and student-course → instructor give keys student-course and student-instructor. Instructor⁺ is only {instructor, course}, so instructor → course violates BCNF. It passes 3NF because course is prime. Kim's course repeats for every student Kim teaches, and a new instructor cannot be recorded without a student.
Split on a violation
For a current relation Ri and a violating determinant X, compute the attributes of X⁺ that lie in Ri. Make:
- A relation containing those attributes, including X.
- A relation containing X and the attributes of Ri outside that closure.
X appears in both parts and determines the whole first part. The split is therefore lossless. Repeat on any part that still fails BCNF, using the dependencies that hold on that part.
The teaching split is (instructor, course) and (student, instructor). Instructor is a key of the first part, and the pair is a key of the second. Each instructor-course fact is stored once.
Follow a complete decomposition
Use R(A, B, C, D, E), F = {A → B, B → C, CD → E}. Its only candidate key is AD.
- A → B fails BCNF because A⁺ is ABC, missing D and E. Split into
(A, B, C)and(A, D, E). - In
(A, B, C), B → C fails: B⁺ there is BC, missing A. Split into(B, C)and(A, B). - In
(A, D, E), the implied AD → E has a superkey determinant. No other nontrivial dependency with a smaller determinant holds there.
The result is (A, B), (B, C), (A, D, E). Every part passes BCNF. Notice that CD → E has no single table containing it. Losslessness has survived, but preservation still needs a separate test.
Recheck the smaller relations
An implied dependency can survive a split without its intermediate attribute. From A → B and B → C, the part (A, C, D) inherits A → C, which fails BCNF because A does not determine D. Merely scanning original FDs whose columns remain visible would miss it.
Different choices of the first violation can produce different BCNF layouts and preserve different dependencies. Key constraints enforce local BCNF FDs when candidate keys are declared with non-null key columns. They do not automatically enforce rules whose attributes have been separated across tables.
Key Takeaways
- BCNF requires a superkey for every nontrivial determinant.
- The prime-right-side exception distinguishes 3NF from BCNF.
- Splitting on X⁺ keeps X as a shared superkey of one part and is lossless.
- Repeat the BCNF test on each part using its projected dependencies.
- A BCNF result can lose dependency preservation.
- The order of chosen violations can change the final layout.
4.2 Prove that a decomposition is lossless
A decomposition must preserve the relationships encoded in the original rows. Keeping every column is necessary, but joining the new tables must also recover exactly the original combinations.
Understand what information can be lost
A lossless-join decomposition has this property for every relation satisfying its dependencies: join the projections and obtain precisely the original relation. Each original row contributes a projection to every part, so it can always reappear in the join. A lossy decomposition admits extra combinations, called spurious tuples. The lost information is which combinations were real.
Consider (E1, Ana, D1, Sales) and (E2, Ben, D2, Sales). Project to (emp_id, emp_name, dept_name) and (dept_id, dept_name). Both employees now match both department rows on "Sales". The four joined rows include false assignments of Ana to D2 and Ben to D1.
Use the two-table test
For a split of R into R1 and R2, find their shared attributes. Compute that set's closure under the original FDs. The split is lossless if the closure contains every attribute of R1 or every attribute of R2. Equivalently, the shared set is a superkey of at least one part. For decompositions governed only by FDs, the test is necessary as well as sufficient.
In orders(order_id, order_date, customer_id) and customers(customer_id, customer_name, customer_city), the intersection is customer_id. It determines all of customers, so the split passes. A projected order row cannot acquire a second, conflicting customer description during the join.
The department-name split fails because dept_name determines neither an employee row nor a department identifier. Repair it with (emp_id, emp_name, dept_id) and (dept_id, dept_name). Their intersection is dept_id, which determines the second part.
Distinguish a proof from a declaration
Losslessness follows from the FD, not from whether someone has written a primary-key declaration. SQL constraints help enforce the intended rules in future states. A foreign key normally points to a primary key or a non-null alternate unique key. Merely declaring a foreign key to a nonidentifying label cannot make that label determine facts it does not identify.
A successful join on one current data set is also weaker than a proof. The current data might contain distinct department names, while a later valid data set contains two departments named "Sales".
Build a proof for several tables
For F = {A → B, B → C, CD → E}, consider (A, B), (B, C), (C, D, E), and (A, D). Start with AD:
- Join AB. The shared A determines AB, so the combined attributes are ABD.
- Join BC. Shared B determines BC, giving ABCD.
- Join CDE. Shared CD determines CDE, giving ABCDE.
Each join is justified, so the complete reconstruction is lossless. Without AD, this particular design loses the original pairing of A with D. A general mechanical test called the chase can handle decompositions without a convenient sequence of two-table proofs. Both the BCNF decomposition algorithm and 3NF synthesis provide losslessness guarantees when performed correctly.
Key Takeaways
- A lossy join can add spurious rows even though every original row remains.
- For two parts, their intersection must determine all attributes of at least one part.
- Use the original dependencies to compute the shared set's closure.
- One successful sample join does not establish losslessness for every valid relation.
- A sequence of justified two-table joins proves losslessness for the full design.
4.3 Preserve dependencies and choose between BCNF and 3NF
Losslessness recovers the right rows; dependency preservation keeps the rules enforceable without joining those rows. BCNF can guarantee the first while sacrificing the second, so a design decision needs both checks.
Test the rules available in the parts
A decomposition is dependency-preserving if the union of the dependencies projected onto individual parts implies every original FD. A rule contained in one part is preserved directly. A rule spread across parts can still follow through a chain: AB and BC can preserve A → C through A → B and B → C.
For a general check of X → Y, start with a result set X. For each part Ri, take the attributes of the result that lie in Ri, compute their closure under F, and add only the closure attributes lying in Ri. Repeat over all parts until nothing changes. Preservation holds for that FD if the result contains Y.
The BCNF layout AB, BC, ADE for A → B, B → C, CD → E loses CD → E. Starting with CD, C in BC adds nothing, D in ADE adds nothing, and AB has no starting attribute. E is never reached through the local rules.
See the practical failure
Split teaching into (instructor, course) and (student, instructor). Store instructors (Kim, Databases) and (Lee, Databases), and assignments (Sam, Kim) and (Sam, Lee). Each table obeys its key, but the join gives Sam two instructors for Databases. The original student-course → instructor rule has been lost. No BCNF decomposition of this relation preserves both original rules.
Simplify the FD set
A canonical cover is an equivalent FD set without redundant dependencies or extraneous attributes. An attribute is extraneous if removing it from a dependency leaves the set equivalent. Combine dependencies sharing a left side after simplifying. A cover need not be unique or globally smallest.
For {A → BC, B → C, A → B, AB → C}, A → C follows through B, so the separate C on A's right is unnecessary. A on the left of AB → C is unnecessary because B → C holds. After merging duplicates, the cover is {A → B, B → C}. To test redundancy, remove the proposed rule and compute closure using the remaining set; including the removed rule would make the test circular.
Synthesize a 3NF design
- Find a canonical cover.
- For each distinct determinant, make a table containing it and its cover right side.
- If no table contains a candidate key of the original relation, add a table consisting of one candidate key.
- Remove tables contained entirely within other tables.
For A → B, B → C, CD → E, this gives AB, BC, and CDE. None contains key AD, so add AD. The result is lossless, dependency-preserving, and in 3NF; here all four parts also happen to be in BCNF.
When BCNF preserves the rules, it provides the stronger normal form without that enforcement cost. Otherwise, compare cross-table checks in BCNF with the redundancy left in 3NF. Keeping teaching intact preserves its student-course key, but instructor → course still needs a local trigger or application check. Fourth normal form concerns multivalued dependencies; fifth concerns join dependencies beyond these FD-based designs.
Key Takeaways
- Preservation means local projected FDs together imply all original FDs.
- A dependency can be preserved indirectly through several tables.
- The teaching split is lossless but loses the student-course uniqueness rule.
- A canonical cover removes redundancy and extraneous attributes without changing implications.
- 3NF synthesis adds a candidate-key table when no generated table contains one.
- 3NF synthesis guarantees 3NF, losslessness, and dependency preservation.
- 4NF and 5NF address further kinds of dependency.
5Decide when and how to denormalize
Faster reads sometimes justify storing a fact or calculation more than once. The useful comparison includes the writes needed to maintain it, contention on shared rows, and the cost of stale results. Start with a measured query problem, then choose a copy or summary with a clear source and freshness rule. Transactions, triggers, refreshes, and drift checks make that deliberate redundancy maintainable as the application changes.
5.1 Weigh the benefits and costs of denormalization
Denormalization adds deliberate redundancy to a normalized design when a measured read benefit justifies it. The decision moves work from reads to writes and creates copies that someone must keep consistent.
Choose a technique for a specific read
| Technique | Read benefit | New write responsibility |
|---|---|---|
| Copy customer city into orders | Regional reports avoid a customer join | A move updates every current-city copy |
| Store an order total or comment count | Reads avoid aggregation | Each relevant source change adjusts the total |
| Merge one-to-one tables | Reads fetch both groups of columns together | Writes share a wider table |
| Store a summary table | Reports read precomputed groups | Refresh the summary on an agreed schedule |
These changes follow a normalized design, where the source facts and their dependencies are already understood. A copy is useful only when its meaning, update path, and consistency cost are clear.
Compare the work for a page
A page displays 20 posts and their comment counts. If those posts average 500 comments each, computing the counts reads about 10,000 comment rows for that page. This query illustrates a page containing posts 11 through 30:
SELECT p.post_id, p.title, COUNT(c.comment_id) AS comment_count
FROM posts p
LEFT JOIN comments c ON c.post_id = p.post_id
WHERE p.post_id BETWEEN 11 AND 30
GROUP BY p.post_id, p.title;
The left join retains posts with no comments. Counting comment_id gives zero for them; counting all joined rows with COUNT(*) would give one for an unmatched post.
A stored posts.comment_count lets the page read 20 counts directly. In exchange, inserting a comment must increment its post's count in the same transaction; deleting a comment must decrement it. Moving a comment between posts affects both counts.
Include costs beyond storage
Copies take space and make writes more complex. Every missed adjustment can create an update anomaly. A popular post can also become a write hotspot: many comment transactions all need to update the same post row and wait for its lock. Fewer reads do not guarantee a faster system under heavy writes.
Good candidates have frequent expensive reads and manageable source changes. A value read rarely but changed constantly can cost more to maintain than to compute. Where stale data would cause serious harm, such as an account balance, consistency requirements dominate convenience.
Measure the query before changing the data model. Primary-key and foreign-key joins can be efficient, especially with suitable indexes. A query rewrite, index, or cache may meet the response target without introducing another authoritative-looking copy.
Tell a historical fact from a live copy
products.list_price is today's catalog price. order_lines.price_paid records the price of a particular sale and depends on the order-product pair. A later catalog change must leave the sale price intact. Storing both records different facts.
Copying the current list price into every order line to avoid a join is different: each copy must follow every catalog price change. That is denormalization because the same current fact is stored repeatedly.
Key Takeaways
- Denormalization follows a normalized design and a measured read problem.
- Copies, stored aggregates, merged tables, and summaries move work from reads to writes.
- Count child identifiers after a left join so parents with no children get zero.
- Frequent updates to one stored aggregate can create write contention.
- A historical sale price is a separate fact from the current catalog price.
5.2 Keep a denormalized design consistent and documented
Intentional redundancy needs an explicit consistency plan. Keep a source from which each copy can be rebuilt, and decide how fresh that copy must be before choosing its update mechanism.
Start with a measured decision
Begin with 3NF or BCNF, identify the slow queries, and measure them against the required response time. Try suitable indexes, query rewrites, and caching. Compare a database-managed materialized view with a hand-maintained summary before choosing how to store the redundant result.
A nightly regional sales report can stay normalized if its measured runtime fits its overnight window. If it misses that window after tuning, a summary refreshed before the report may help. A product rating displayed a million times a day offers a different balance: storing rating sum and count can avoid repeatedly scanning reviews.
Choose one source of truth
For comment counts, rows in comments are authoritative; posts.comment_count is derived. A rebuild recomputes from those rows:
UPDATE posts
SET comment_count = (
SELECT COUNT(*)
FROM comments c
WHERE c.post_id = posts.post_id
);
Here COUNT(*) counts real comment rows in the correlated subquery, so zero comments yields zero. Coordinate a rebuild with concurrent writes so it cannot overwrite a newer increment with an older snapshot.
Match the maintenance method to freshness
| Method | How it works | Main responsibility |
|---|---|---|
| Application transaction | Source and copy change together | Every writing path must use it |
| Trigger | Database code reacts to source changes | Handle inserts, deletes, and relevant updates |
| Scheduled refresh | Recompute at known intervals | Readers must accept the permitted delay |
| Materialized view | Store a query result managed by the database | Know when the system refreshes it |
In PostgreSQL, an ordinary materialized view changes when REFRESH MATERIALIZED VIEW runs, not whenever a source row changes. Some other systems support automatic maintenance for eligible views. "Managed by the database" does not specify freshness.
For a rating, store the sum and count, not just a rounded average. With sum 210 over 50 reviews, adding a score of 5 produces sum 215 and count 51, giving about 4.22. Editing or deleting a review must also adjust its contribution. Repeatedly updating a rounded average discards information needed for later calculations.
Detect drift and make repair possible
SELECT p.post_id
FROM posts p
LEFT JOIN comments c ON c.post_id = p.post_id
GROUP BY p.post_id, p.comment_count
HAVING p.comment_count <> COUNT(c.comment_id);
With a non-null stored count, this lists posts whose copy differs from the source count. A zero-comment post remains in the result of the left join and has actual count zero. Run checks against a consistent view of source and copy, investigate missed write paths, and rebuild from the authoritative rows.
Document each copy's source, update mechanism, permitted staleness, and rebuild procedure. Record the rule that would otherwise prevent the redundancy: copying a customer's current city into orders repeats customer_id → customer_city. That identifies the move operation that must update every copy.
Key Takeaways
- Measure the problem and try simpler performance changes before adding copies.
- Keep the normalized source authoritative and the copy rebuildable.
- Transactions and triggers must cover every source change, not just inserts.
- PostgreSQL materialized views need explicit refresh commands.
- Store a rating sum and count to preserve the inputs for future averages.
- Check for drift and coordinate repairs with concurrent writes.
- Document source, maintenance, allowed staleness, and rebuilding.
Database Normalization examples
1Repair a lab-loan table
10 steps
- 1IntroductionOne loan line mixes several subjects
A laboratory records
loans(loan_id, lab_id, lab_name, instrument_id, instrument_name, quantity), keyed by(loan_id, instrument_id). Each loan belongs to one lab; each lab and instrument has one name.A row combines a loan assignment, a lab description, an instrument description, and a line quantity. Follow what happens when these facts need to change independently, exposing a modification anomaly, a deletion anomaly, and an insertion anomaly.
- 2ExampleLocate the repeated lab fact
Loan 71 belongs to lab L4, "River Lab", and contains instruments I8 and I9. Loan 72 also belongs to L4 and contains I8. All three lines therefore store the lab name "River Lab".
The repeated fact is L4's name, not merely the repeated text. If a different lab happened to share that name, its name would be a separate fact. Instrument I8's name also repeats on two loan lines.
- 3ExplanationChange a name
L4 changes its name to "River Research". Editing only loan 71's first line leaves two rows with the old name. This is a modification anomaly: one business change needs several stored changes.
An update filtered by
lab_idcan change every current copy, but the next writer can still miss one. The schema continues to represent one lab fact in several places. - 4ChallengeWhich fact disappears?
Instrument I9 appears only on loan 71. Staff delete that line when the instrument is returned. Which independent information disappears too?
---reveal---
I9's name disappears, because that line was its only stored record. This is a deletion anomaly. Removing a loan line should not remove the instrument catalog entry.
- 5ConnectionA fact needs an unrelated event
A newly purchased instrument I10 has no loan yet. The line key requires a
loan_id, so this design has no place to record I10's name by itself. That is an insertion anomaly.A dummy loan would supply a key by inventing an event. A separate instrument table instead lets staff register the instrument before anyone borrows it.
- 6ExampleSeparate the four kinds of fact
Use
labs(lab_id, lab_name),loan_headers(loan_id, lab_id),instruments(instrument_id, instrument_name), andloan_lines(loan_id, instrument_id, quantity).The first three tables use their identifier as key; the last uses the pair. Each line references a loan and an instrument, and each loan references a lab. L4's name now has one home, and an instrument can exist without a loan.
- 7ExampleMove rows without guessing facts
Populate labs and instruments before loan headers and lines, so referenced rows exist first. To copy lab facts, use:
INSERT INTO labs (lab_id, lab_name) SELECT DISTINCT lab_id, lab_name FROM loans;If L4 has both old and new names,
DISTINCTretains both pairs. Resolve the intended current name before loading the keyed table; removing duplicate rows cannot resolve conflicting values. - 8ExplanationReconstruct through identifiers
A loan line joins its header on
loan_id, its instrument oninstrument_id, and its lab through the header'slab_id. Those links recover the original loan, lab, instrument, and quantity combinations.Joining on
lab_nameinstead would be unsafe if two labs share a name. A readable label does not necessarily identify the entity that owns the fact. - 9ChallengeCheck the repair as a whole
After the split, staff rename L4 and then delete the last loan line for I8. How many lab rows change, and does I8's name survive?
---reveal---
One row in
labschanges. I8's name remains ininstrumentsafter its last loan line is deleted. The lab identifier still links existing headers to the renamed lab. - 10RecapUse the split to check the design
For each original row, identify the facts about entities and the facts about their relationship. Entity descriptions belong with their own identifiers; the line quantity belongs with the loan-instrument pair.
Then trace the reverse route through joins. The design must let independent facts survive changes and recover the original combinations, with constraints that keep those links valid.
2Find all keys from a small FD set
14 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionBuild a key from rules
- 2ExplanationRead the combined determinant
- 3ChallengeReject an unsupported shortcut
- 4ExplanationUse the three axioms
- 5ExampleDerive HK → M
- 6ExampleStart with H alone
- 7ExampleAdd K to the starting set
- 8ChallengeCompute a different closure
- 9ExplanationFind the mandatory attribute
- 10ExampleCheck minimality and completeness
- 11Key InsightClassify prime attributes
- 12ChallengeDoes an extra column make another key?
- 13ChallengeConnect the key to the dependency
- 14RecapCarry the complete key picture forward
3Normalize workshop registrations
14 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionStart with a workshop roster
- 2ExampleReplace the participant list
- 3TipAvoid fixed participant slots
- 4ChallengeDoes flattening finish normalization?
- 5ExplanationWrite the rules behind the rows
- 6ExampleMove facts fixed by one key part
- 7ChallengePlace a registration result
- 8Key InsightRecognize the limit of 2NF
- 9ExplanationApply the precise 3NF test
- 10ExampleGive the room fact one home
- 11ChallengeTest another unique identifier
- 12ConnectionRemember the prime exception
- 13ChallengeCheck the whole repaired design
- 14RecapTrace each fact to its determinant
4Compare two decompositions of one schema
20 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionCheck three different promises
- 2ExampleEstablish the candidate keys
- 3ExplanationFind the first BCNF violation
- 4ExampleSplit on the closure of P
- 5ExampleSplit the second violation
- 6ChallengeWhy must a projected rule be kept?
- 7ExplanationProve a two-table split
- 8ExampleExtend the proof to the next split
- 9ChallengeA shared value is not enough
- 10ExplanationSeparate preservation from losslessness
- 11ExampleTry to recover QS → T locally
- 12ChallengeLocate the enforcement cost
- 13ExplanationPrepare a canonical cover
- 14ExampleMake relations from the cover
- 15ExampleAdd a surviving original key
- 16ExampleProve the synthesized join
- 17ConnectionUnderstand the general 3NF choice
- 18ChallengeChoose the design for local enforcement
- 19TipRecognize the next normal forms
- 20RecapRecord the separate verdicts
5Maintain a saved reaction count
12 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionMake the performance decision concrete
- 2ExampleEstimate the read benefit
- 3ExplanationInclude the write workload
- 4ChallengeDoes a busy page justify the copy?
- 5ExampleKeep the source and copy together
- 6ChallengeA deletion is also a source change
- 7ExplanationChoose freshness explicitly
- 8ExampleFind an incorrect counter
- 9TipCoordinate a rebuild
- 10ConnectionRetain inputs for derived averages
- 11ChallengeSpecify a complete maintenance plan
- 12RecapKeep the copy justified and repairable
Database Normalization practice questions
Set 1: Find anomalies and write dependable rules10 Practice Questions
Question 1 of 10
Show answerHide answer
Question 2 of 10
(shipment_id, supplier_id, supplier_name), keyed by shipment_id. The only row for supplier S18 is deleted when its shipment is canceled. What information is accidentally lost?Show answerHide answer
Question 3 of 10
devices(device_id, owner_id, owner_name) has owner_id → owner_name. How should it be split to store one owner name per owner and retain device ownership?Show answerHide answer
owner_id, and each device must keep that identifier to retain its owner assignment. Joining on it recovers the original rows. Keeping only owner_name in devices can confuse different owners who share a name.Question 4 of 10
Show answerHide answer
warehouse_code → address. Reversing the arrow would require an address to identify exactly one warehouse, which the shared-address rule explicitly allows to be false.Question 5 of 10
editor → language?Show answerHide answer
Question 6 of 10
Show answerHide answer
Question 7 of 10
Show answerHide answer
Question 8 of 10
Show answerHide answer
Question 9 of 10
(asset_id, room_name) and (room_id, room_name). Two rooms can share a name. Which statement describes the design?Show answerHide answer
Question 10 of 10
unit_price_at_sale, while the product catalog stores current_price. The sale value must remain unchanged after catalog updates. How should these two values be understood?Show answerHide answer
Set 2: Use closures and test the first three normal forms10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
loan_items(loan_id, item_id, due_date, condition_code) has only key (loan_id, item_id), with loan_id → due_date and the pair → condition_code. Which fact must move to reach 2NF?Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
tickets(ticket_id, venue_id, venue_name) has ticket_id → venue_id and venue_id → venue_name. What split reaches 3NF and retains each ticket's venue?Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
(R8, red), (R8, blue), and (R9, blue) for (batch_id, label). What does grouping by batch_id with HAVING COUNT(DISTINCT label) > 1 return?Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
(A, C, D). Why does that part fail BCNF?Show answerHide answer
Save this lesson to see this answer.
Set 3: Prove joins and compare decomposition choices10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
(P, Q, S) and (Q, R) lossless, and why?Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Set 4: Evaluate copies, refreshes, and consistency10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
articles.reaction_count is a maintained copy of the number of rows in reactions?Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
rating_sum = 144 and rating_count = 36. One existing score changes from 2 to 5, then a score of 4 is deleted. What sum and count should be stored?Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
clips.like_count is non-null. A drift query uses LEFT JOIN likes and compares the stored count with COUNT(*). A clip with no likes and stored count 0 is reported. How should the query be repaired?Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
thread_id. Both counts were correct before the move. How should maintenance keep the source and both counts in step?Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Set 5: Review complete designs and trace hidden dependencies10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
(course_run_id, participant_id) also stores the run's room. A planned run cannot be entered until someone registers. What anomaly is this?Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
contacts(contact_id, contact_name, channel) is keyed by (contact_id, channel). Names depend only on contact_id. Values are atomic. What is the next appropriate repair?Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Stuck on your own question? Homework Help
Key Terms
A
Alternate key
Armstrong's axioms
Atomic value
Attribute closure
Augmentation
B
BCNF decomposition
Boyce–Codd normal form
Business rule
C
Candidate key
Canonical cover
Chase
Composite key
D
Decomposition
Decomposition rule
Deletion anomaly
Denormalization
Dependency preservation
Dependency-set closure
Determinant
{booking_id, seat_id} → fare_paid, booking and seat identifiers together form the determinant.Domain
Drift
E
Extraneous attribute
F
Fifth normal form
First normal form
Foreign key
Fourth normal form
Full dependency
Functional dependency
H
Historical fact
I
Insertion anomaly
L
Lossless join
M
Materialized view
Modification anomaly
N
Non-prime attribute
Nontrivial dependency
Normalization
P
Partial dependency
Primary key
Prime attribute
Projected dependency
Projection
Proper subset
Pseudotransitivity
R
Redundancy
Reflexivity
Repeating group
S
Second normal form
Shared-attribute test
Source of truth
Spurious tuple
Staleness
Stored aggregate
Superkey
Surrogate key
T
Third normal form
Transaction
Transitive dependency
Transitivity
Trigger
Trivial dependency
{order_id, product_id} always determines product_id because that attribute is already present.U
Union rule
V
View
W
Whole-key dependence
Write contention
Z
Zaniolo's test
#
3NF synthesis
About this lesson
Make your own Study Materials
Turn your notes, slides and documents into Study Guides, Practice Questions, Flashcards and 6 more tools.