Database Normalization

Learn why a single wide table causes update, insertion and deletion anomalies, and how to fix them. Write the rules in your data as functional dependencies, find every candidate key with attribute closure, and normalize tables step by step to first, second and third normal form and to Boyce–Codd normal form. Check that each split loses no information and keeps every rule enforceable, and decide when deliberately adding redundancy back for speed is worth its costs.

IntermediateLesson 4 of 8 in Database Design and Advanced SQL Course

What you will learn

  1. 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 anomalies
      Read 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 joins
      Decompose 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.
  2. 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 rules
      Define 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 closure
      Use 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 attributes
      Distinguish superkeys, candidate keys and primary keys, find every candidate key systematically with closure, and classify attributes as prime or non-prime.
  3. 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 form
      Recognize 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 form
      Test a table for partial dependencies on its candidate keys and decompose it into second normal form.
    • Remove transitive dependencies to reach third normal form
      Test a table for third normal form with both the transitive-dependency definition and the superkey test, and decompose it into third normal form.
  4. 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 form
      Apply the BCNF test, explain how BCNF differs from 3NF, and use the BCNF decomposition algorithm step by step.
    • Prove that a decomposition is lossless
      Explain 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 3NF
      Test whether a decomposition preserves every dependency, synthesize a 3NF design from a canonical cover, and decide between BCNF and 3NF when they conflict.
  5. 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 denormalization
      Describe 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 documented
      Follow a measured process for denormalizing, keep the copies synchronized with transactions, triggers or refreshes, and detect and repair drift.

Database Normalization study guide

5 chapters

1

Recognize 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
ChangeWhat goes wrongAnomaly
Ana moves from Lyon to ParisUpdating one line leaves the other line saying LyonModification
Add P4, "Monitor arm", priced 89.00There is no order to supply the required order keyInsertion
Delete order 1002Ben's only stored name and city disappear tooDeletion

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.

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:

TablePrimary keyOther columns
customerscustomer_idcustomer_name, customer_city
ordersorder_idorder_date, customer_id
productsproduct_idproduct_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.
2

Reason 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
TypeMeaningOrder-line example
TrivialThe right side is contained in the left{order_id, product_id} → product_id
FullNo proper subset of the determinant determines the dependent attribute{order_id, product_id} → quantity
PartialA proper subset already determines the dependent attributeThe line key determines product_name through product_id alone
TransitiveA rule follows through an intermediate determinantorder_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:

AxiomValid stepMeaning
ReflexivityIf Y is contained in X, then X → YA set determines its own parts
AugmentationX → Y gives XZ → YZAdd the same attributes to both sides
TransitivityX → Y and Y → Z give X → ZFollow 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.

  1. Start with the attributes in X.
  2. Find an FD whose entire left side is present, and add its right side.
  3. 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:

  1. A and D occur on no right side, so both are mandatory.
  2. {A, D}⁺ adds B, C, and E, reaching all columns.
  3. {A, D} is therefore the only candidate key.
  4. 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.
3

Normalize 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:

employeesemployee_skills
emp_idemp_nameemp_idskill
E1AnaE1SQL
E2BenE1Python
E2SQL

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_id reaches order_date, customer_id, customer_name, and customer_city.
  • product_id reaches product_name and list_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.
4

Reach 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:

  1. A relation containing those attributes, including X.
  2. 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:

  1. Join AB. The shared A determines AB, so the combined attributes are ABD.
  2. Join BC. Shared B determines BC, giving ABCD.
  3. 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
  1. Find a canonical cover.
  2. For each distinct determinant, make a table containing it and its cover right side.
  3. If no table contains a candidate key of the original relation, add a table consisting of one candidate key.
  4. 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.
5

Decide 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
TechniqueRead benefitNew write responsibility
Copy customer city into ordersRegional reports avoid a customer joinA move updates every current-city copy
Store an order total or comment countReads avoid aggregationEach relevant source change adjusts the total
Merge one-to-one tablesReads fetch both groups of columns togetherWrites share a wider table
Store a summary tableReports read precomputed groupsRefresh 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
MethodHow it worksMain responsibility
Application transactionSource and copy change togetherEvery writing path must use it
TriggerDatabase code reacts to source changesHandle inserts, deletes, and relevant updates
Scheduled refreshRecompute at known intervalsReaders must accept the permitted delay
Materialized viewStore a query result managed by the databaseKnow 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

5 Walkthroughs

1

Repair a lab-loan table

10 steps
Follow repeated lab and instrument facts through changes, a table split, and reconstruction.
  1. 1
    IntroductionOne 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.

  2. 2
    ExampleLocate 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.

  3. 3
    ExplanationChange 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_id can change every current copy, but the next writer can still miss one. The schema continues to represent one lab fact in several places.

  4. 4
    ChallengeWhich 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.

  5. 5
    ConnectionA 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.

  6. 6
    ExampleSeparate the four kinds of fact

    Use labs(lab_id, lab_name), loan_headers(loan_id, lab_id), instruments(instrument_id, instrument_name), and loan_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.

  7. 7
    ExampleMove 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, DISTINCT retains both pairs. Resolve the intended current name before loading the keyed table; removing duplicate rows cannot resolve conflicting values.

  8. 8
    ExplanationReconstruct through identifiers

    A loan line joins its header on loan_id, its instrument on instrument_id, and its lab through the header's lab_id. Those links recover the original loan, lab, instrument, and quantity combinations.

    Joining on lab_name instead would be unsafe if two labs share a name. A readable label does not necessarily identify the entity that owns the fact.

  9. 9
    ChallengeCheck 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 labs changes. I8's name remains in instruments after its last loan line is deleted. The lab identifier still links existing headers to the renamed lab.

  10. 10
    RecapUse 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.

2

Find all keys from a small FD set

14 steps
Derive dependencies, compute closures, and find overlapping candidate keys without relying on sample uniqueness.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionBuild a key from rules
  2. 2
    ExplanationRead the combined determinant
  3. 3
    ChallengeReject an unsupported shortcut
  4. 4
    ExplanationUse the three axioms
  5. 5
    ExampleDerive HK → M
  6. 6
    ExampleStart with H alone
  7. 7
    ExampleAdd K to the starting set
  8. 8
    ChallengeCompute a different closure
  9. 9
    ExplanationFind the mandatory attribute
  10. 10
    ExampleCheck minimality and completeness
  11. 11
    Key InsightClassify prime attributes
  12. 12
    ChallengeDoes an extra column make another key?
  13. 13
    ChallengeConnect the key to the dependency
  14. 14
    RecapCarry the complete key picture forward
3

Normalize workshop registrations

14 steps
Turn a participant list into rows, remove partial dependencies, and separate room facts through 3NF.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionStart with a workshop roster
  2. 2
    ExampleReplace the participant list
  3. 3
    TipAvoid fixed participant slots
  4. 4
    ChallengeDoes flattening finish normalization?
  5. 5
    ExplanationWrite the rules behind the rows
  6. 6
    ExampleMove facts fixed by one key part
  7. 7
    ChallengePlace a registration result
  8. 8
    Key InsightRecognize the limit of 2NF
  9. 9
    ExplanationApply the precise 3NF test
  10. 10
    ExampleGive the room fact one home
  11. 11
    ChallengeTest another unique identifier
  12. 12
    ConnectionRemember the prime exception
  13. 13
    ChallengeCheck the whole repaired design
  14. 14
    RecapTrace each fact to its determinant
4

Compare two decompositions of one schema

20 steps
Test BCNF, prove losslessness, and use synthesis to preserve a dependency the first split separates.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionCheck three different promises
  2. 2
    ExampleEstablish the candidate keys
  3. 3
    ExplanationFind the first BCNF violation
  4. 4
    ExampleSplit on the closure of P
  5. 5
    ExampleSplit the second violation
  6. 6
    ChallengeWhy must a projected rule be kept?
  7. 7
    ExplanationProve a two-table split
  8. 8
    ExampleExtend the proof to the next split
  9. 9
    ChallengeA shared value is not enough
  10. 10
    ExplanationSeparate preservation from losslessness
  11. 11
    ExampleTry to recover QS → T locally
  12. 12
    ChallengeLocate the enforcement cost
  13. 13
    ExplanationPrepare a canonical cover
  14. 14
    ExampleMake relations from the cover
  15. 15
    ExampleAdd a surviving original key
  16. 16
    ExampleProve the synthesized join
  17. 17
    ConnectionUnderstand the general 3NF choice
  18. 18
    ChallengeChoose the design for local enforcement
  19. 19
    TipRecognize the next normal forms
  20. 20
    RecapRecord the separate verdicts
5

Maintain a saved reaction count

12 steps
Compare measured reads with write costs, then follow insertions, removals, refreshes, and drift repair.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionMake the performance decision concrete
  2. 2
    ExampleEstimate the read benefit
  3. 3
    ExplanationInclude the write workload
  4. 4
    ChallengeDoes a busy page justify the copy?
  5. 5
    ExampleKeep the source and copy together
  6. 6
    ChallengeA deletion is also a source change
  7. 7
    ExplanationChoose freshness explicitly
  8. 8
    ExampleFind an incorrect counter
  9. 9
    TipCoordinate a rebuild
  10. 10
    ConnectionRetain inputs for derived averages
  11. 11
    ChallengeSpecify a complete maintenance plan
  12. 12
    RecapKeep the copy justified and repairable

Database Normalization practice questions

50 Practice Questions in 5 sets

Set 1: Find anomalies and write dependable rules10 Practice Questions

Question 1 of 10

A repair log repeats each machine's model on every repair row. A model correction is applied to one of six rows for machine M42. What anomaly can result?
  1. A deletion anomaly that removes the machine.
  2. A key anomaly that duplicates the repair number.
  3. An insertion anomaly that prevents new repairs.
  4. A modification anomaly with conflicting models.
Show answerHide answer
Answer: D
The correction changes one machine fact that is stored in six places, so the remaining rows can disagree with it. That is a modification anomaly. An insertion anomaly would prevent recording a fact independently; this problem arises while changing an existing fact.

Question 2 of 10

A table stores (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?
  1. The identities of other suppliers.
  2. The supplier's identity and name.
  3. The unique constraint on shipment IDs.
  4. The count of shipments in transit.
Show answerHide answer
Answer: B
The deleted row was the only stored home for S18's supplier facts, so canceling a shipment also removes those facts. This is a deletion anomaly. The unique shipment constraint belongs to the schema and survives deletion of a row.

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?
  1. devices(device_id, owner_name) and owners(owner_id, owner_name).
  2. devices(device_id, owner_id) and owners(owner_id, owner_name).
  3. devices(device_id, owner_id) and owners(device_id, owner_name).
  4. devices(device_id) and owners(owner_id, owner_name); join all rows.
Show answerHide answer
Answer: B
Owner details belong in a table keyed by 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

Each warehouse code has exactly one address, and several warehouses may share an address. What dependency expresses the guaranteed rule?
  1. address → warehouse_code.
  2. warehouse_code → every shipment_id.
  3. warehouse_code → address.
  4. {warehouse_code, address} → shipment_id.
Show answerHide answer
Answer: C
Agreement on a warehouse code guarantees agreement on its address, giving 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

Current rows pair each editor with a different language. The business allows several editors per language and several languages per editor. What can be concluded about editor → language?
  1. The current pairing does not establish the dependency.
  2. The dependency is guaranteed until an editor is deleted.
  3. The language column must be a candidate key for future rows.
  4. The dependency holds because every current editor is distinct.
Show answerHide answer
Answer: A
A functional dependency must hold for every valid state. The business permits one editor to appear with different languages, so the sample pairing cannot establish the rule. Distinct editor values make the present data consistent with the dependency without making it a design guarantee.

Question 6 of 10

A training table has a cell containing "First aid, Welding". Staff need to validate and search individual certifications. What structure gives each certification its own value?
  1. workers(worker_id, certifications_text) with a different separator.
  2. workers(worker_id, certification_count) with the list length stored.
  3. worker_certifications(worker_id, certification) with one row per pair.
  4. workers(worker_id, certification1, certification2) with two fixed slots.
Show answerHide answer
Answer: C
One row per worker-certification pair gives each certification an independent value that can be searched and constrained. Numbered columns retain a fixed maximum and force searches across multiple slots. Changing the text separator leaves the original collection hidden in a single cell.

Question 7 of 10

For R(P, Q, R, S) with P → Q and Q → R, what is P⁺?
  1. {P, Q, R}.
  2. {Q, R}.
  3. {P, Q}.
  4. {P, Q, R, S}.
Show answerHide answer
Answer: A
Start with P, add Q using P → Q, and then add R using Q → R. No rule adds S, so the closure is {P, Q, R}. Stopping at {P, Q} misses the second dependency, which becomes usable after Q has been added.

Question 8 of 10

R(J, K, L, M) has J → K and KL → M. What is its only candidate key?
  1. {J, L}.
  2. {J, K}.
  3. {K, L}.
  4. {J, L, M}.
Show answerHide answer
Answer: A
J and L never occur on a right side, so every key needs both. Together they add K and then M, reaching the whole relation. {J, L, M} is a superkey but not a candidate key because M can be removed; {K, L} cannot derive J.

Question 9 of 10

R(asset_id, room_id, room_name) has only asset_id → room_id and room_id → room_name. It is split into (asset_id, room_name) and (room_id, room_name). Two rooms can share a name. Which statement describes the design?
  1. It is lossless but loses room_id → room_name from the second part.
  2. It is lossless because asset_id remains a key of the first part.
  3. It can create false asset-room pairs and loses asset_id → room_id.
  4. It preserves every dependency because each column appears in a part.
Show answerHide answer
Answer: C
The shared room name determines neither part, so the split can match an asset to several room IDs. Local rules retain asset-to-name and room-ID-to-name, but cannot derive asset-to-room-ID. A key in one part does not prove losslessness unless it is the shared attribute set.

Question 10 of 10

An invoice line records 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?
  1. They form one redundant fact with a deletable historical copy.
  2. They violate 1NF by giving one product two prices.
  3. They are synchronized copies that must change together.
  4. They record different facts with different time meanings.
Show answerHide answer
Answer: D
The sale price describes a particular transaction; the catalog price describes the product now. Keeping both preserves two different facts. Synchronizing the sale value to later catalog updates would destroy the transaction history, not repair a denormalized copy.
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

Which rule justifies deriving X → Z from X → Y and Y → Z?
  1. Augmentation.
  2. Transitivity.
  3. Decomposition.
  4. Reflexivity.
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

R(H, J, K, L, M) has H → J, J → K, and KL → M. What is {H, L}⁺?
  1. {H, J, K, L}.
  2. {J, K, L, M}.
  3. {H, J, K, L, M}.
  4. {H, J, L, M}.
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

R(U, V, W, Z) has U → V, V → U, and UW → Z. What are all candidate keys and the non-prime attributes?
  1. Keys UW and VZ; only W is non-prime.
  2. Keys UVW and VWZ; every attribute is prime.
  3. Only UW is a key; V and Z are non-prime.
  4. Keys UW and VW; only Z is non-prime.
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?
  1. The condition, to loans(loan_id, condition_code).
  2. The due date, to loans(loan_id, due_date).
  3. The due date, to items(item_id, due_date).
  4. The condition, to items(item_id, condition_code).
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

A relation is in 1NF and every candidate key consists of one attribute. Which next normal form does it meet without removing composite-key partial dependencies?
  1. Fifth normal form.
  2. Third normal form.
  3. Boyce–Codd normal form.
  4. Second normal form.
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?
  1. tickets(ticket_id, venue_id) and venues(ticket_id, venue_name).
  2. tickets(ticket_id, venue_name) and venues(venue_id, venue_name).
  3. tickets(ticket_id, venue_id, venue_name) with a generated primary key.
  4. tickets(ticket_id, venue_id) and venues(venue_id, venue_name).
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

R(A, B, C) has AB → C and C → B. What is its highest normal form among 1NF, 2NF, 3NF, and BCNF?
  1. 3NF.
  2. BCNF.
  3. 2NF.
  4. 1NF.
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A non-null table has rows (R8, red), (R8, blue), and (R9, blue) for (batch_id, label). What does grouping by batch_id with HAVING COUNT(DISTINCT label) > 1 return?
  1. No batch identifiers.
  2. Only R9.
  3. Only R8.
  4. Both R8 and R9.
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

R(A, B, C, D) has AB → CD and C → B, with candidate keys AB and AC. Which dependency causes a 2NF violation?
  1. C → B, because C is part of candidate key AC.
  2. None: no non-prime attribute depends on a proper key subset.
  3. AB → D, because AB contains more than one attribute.
  4. AC → D, because AC is not the chosen primary key.
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

R(A, B, C, D) has A → B and B → C. A proposed part is (A, C, D). Why does that part fail BCNF?
  1. It inherits A → C, and A cannot determine D.
  2. It has key AD, and every composite key violates BCNF.
  3. It inherits C → A, and C cannot determine D.
  4. It inherits B → C, even though B is absent.
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

What does a spurious tuple represent after joining projections?
  1. An original row that the join has permanently removed.
  2. A new combination that was absent from the original relation.
  3. A duplicate column name caused by an explicit SQL join.
  4. A row that necessarily violates a key in one projected table.
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

R(P, Q, R, S) has Q → R and P → QS. Is the split (P, Q, S) and (Q, R) lossless, and why?
  1. No; Q does not determine the original relation.
  2. No; the original candidate key P appears in only one part.
  3. Yes; shared Q determines every attribute of QR.
  4. Yes; shared Q determines every attribute of PQS.
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

R(K, L, M, N) has K → L, L → M, and KN → all attributes. Using K⁺ for the first BCNF split, what two schemas result?
  1. (K, L) and (L, M, N).
  2. (K, M) and (K, L, N).
  3. (K, L, M) and (M, N).
  4. (K, L, M) and (K, N).
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

R(A, B, C) has A → B and B → C. Its parts are AB and BC. Is A → C preserved?
  1. Yes; the local rules imply it by transitivity.
  2. No; A and C never appear in the same part.
  3. No; only directly stored dependencies can be preserved.
  4. Yes; a shared column makes every dependency preserved.
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

R(A, B, C, D, E) has A → B, B → C, and CD → E. It is split into AB, BC, and ADE. Which original FD is not preserved?
  1. AD → E.
  2. A → B.
  3. B → C.
  4. CD → E.
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

Simplify F = {J → KL, K → L, J → K, JK → L} into a canonical cover. What remains after redundant information is removed and common left sides are combined?
  1. {J → L, K → L}.
  2. {K → J, J → L}.
  3. {J → K, K → L}.
  4. {J → K, L → K}.
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

R(A, B, C) has only A → B. Its parts are AB and BC. What pair of valid original rows demonstrates that the split can be lossy?
  1. (a1, b1, c1) and (a2, b1, c2).
  2. (a1, b1, c1) and (a2, b2, c2).
  3. (a1, b1, c1) and (a1, b1, c2).
  4. (a1, b1, c1) and (a1, b2, c2).
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

R(H, J, K, L) has H → J and JK → L, already a canonical cover. What 3NF synthesis result includes the table needed for losslessness?
  1. HJ, JKL, and HL.
  2. HJ, JKL, and HK.
  3. HJ, KL, and HK.
  4. HJ and JKL only.
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

R(A, B, C, D) has A → B, B → C, and CD → A. Which BCNF split follows from the violating determinant B?
  1. AB and BCD; B determines all of AB.
  2. ABC and BD; B determines all of ABC.
  3. BC and ABD; B determines the shared closure part.
  4. BC and ACD; C determines the shared closure part.
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

A lossless BCNF decomposition separates a required business FD so local constraints no longer imply it. What choice keeps all FDs enforceable within individual tables?
  1. Use a lossless, dependency-preserving 3NF synthesis.
  2. Remove the FD because the tables already satisfy BCNF.
  3. Declare one foreign key and assume it enforces every lost FD.
  4. Add generated primary keys without changing the table layout.
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

Which data should be authoritative when articles.reaction_count is a maintained copy of the number of rows in reactions?
  1. The last edited count.
  2. The larger count.
  3. The displayed count.
  4. The reaction rows.
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

A team measures an aggregation at 900 ms against a 200 ms target. An index reduces it to 80 ms under the same workload. What should it do about its proposed stored total?
  1. Merge the source tables because a successful index proves joins are costly.
  2. Keep the normalized calculation because it now meets the target.
  3. Store the total because a prior slow measurement fixes the design choice.
  4. Store the total because any aggregation exceeds the intended target.
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

A PostgreSQL materialized view is refreshed at 06:00. Source rows change at 06:05, and no further refresh runs before a 06:10 query. Which source state does its stored result reflect?
  1. The state read live at the 06:10 query.
  2. The state refreshed by the 06:05 writes.
  3. The state captured by the 06:00 refresh.
  4. The state after all commits through 06:10.
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

A live dashboard reads a stored vote count 400 times per second. A popular entry receives 250 votes per second, each updating that same counter row. Read latency falls, but write latency rises. What explains the result and should guide the decision?
  1. It adds independent writes; compare write volume, not lock waits.
  2. It serializes counter updates; judge the change by read latency alone.
  3. It creates a hotspot; move the counter update outside the source transaction.
  4. The shared counter can serialize writes; compare both latency targets.
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

A stored average is based on 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?
  1. Sum 143; count 35.
  2. Sum 143; count 36.
  3. Sum 147; count 35.
  4. Sum 145; count 35.
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

A summary may be at most 10 minutes old. It refreshes every hour, and updates occur throughout the day. What must change to meet that freshness rule?
  1. The source should be deleted after each hourly summary refresh.
  2. The summary should keep its hourly refresh and change its primary key.
  3. The query should read the summary twice without changing refresh timing.
  4. The refresh or maintenance plan must limit staleness to 10 minutes.
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?
  1. Keep the left join and compare with COUNT(clips.clip_id).
  2. Keep the left join and compare with COUNT(likes.like_id).
  3. Keep the left join and compare with COUNT(DISTINCT clips.clip_id).
  4. Use an inner join and continue comparing with COUNT(*).
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A comment moves from thread T1 to T2. Insert and delete triggers maintain thread counts, but no trigger handles updates to thread_id. Both counts were correct before the move. How should maintenance keep the source and both counts in step?
  1. Decrement T1 and increment T2 in separate transactions after moving the comment.
  2. Increment T2 only because the comment still exists after the update.
  3. Decrement T1 and increment T2 in the transaction that moves the comment.
  4. Decrement T1 only because the update removes the old thread assignment.
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

A directory copies each member's current city into every reservation. Cities change often; the report runs twice daily and already meets its target. What combination best describes the proposal?
  1. It repeats member_id → city and adds move-related writes without a measured need.
  2. It preserves 3NF because current city becomes a fact about each reservation.
  3. It removes member_id → city by declaring reservation_id as the primary key.
  4. It records historical cities and therefore needs no synchronization on moves.
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

A repair job counts 12 source events. A writer then commits a thirteenth event and a counter increment to 13 in one transaction. The repair finally writes its earlier result of 12. What failed?
  1. The repair trusted source rows; only the stored counter defines the count.
  2. The repair was not coordinated with concurrent source and copy updates.
  3. The writer grouped its insert and increment instead of separating them.
  4. The repair's earlier count needed DISTINCT to include the later event.
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

A table keyed by (course_run_id, participant_id) also stores the run's room. A planned run cannot be entered until someone registers. What anomaly is this?
  1. A spurious-tuple anomaly.
  2. An insertion anomaly.
  3. A deletion anomaly.
  4. A modification anomaly.
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

A flattened relation 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?
  1. Choose contact_name as primary key without changing the rows.
  2. Add channel1 and channel2 columns to each contact row.
  3. Separate contact names from contact-channel assignments.
  4. Keep the design because atomic values guarantee BCNF.
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

R(A, B, C, D, E) has A → B, B → A, CD → E, and E → C. What are all candidate keys?
  1. Only ACD and BCD, not ADE.
  2. ACD, ADE, BCD, and BDE.
  3. Only AD and BD as keys.
  4. Only ACDE and BCDE.
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

R(A, B, C, D) has AB → C, C → B, and A → D. What are its candidate keys and highest normal form?
  1. Keys AB and AC; 3NF only.
  2. Key AB alone; 2NF only.
  3. Keys AB and AC; 1NF only.
  4. Keys AB and AC; BCNF.
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

R(A, B, C, D) has A → B, B → C, and AC → D. A designer keeps AB, BC, and AD. Which conclusion is correct?
  1. The design is lossless and preserves all three original FDs.
  2. The design is lossy and loses A → B because A occurs in two parts.
  3. The design is lossless but loses AC → D because no table contains ACD.
  4. The design preserves the FDs but is lossy because no table contains ABCD.
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

R(A, B, C, D) has A → B and BC → D. After the closure-based split on A, what is the highest normal form of each part?
  1. AB fails BCNF; ACD is BCNF.
  2. AB is BCNF; A → D breaks ACD.
  3. AB and ACD are both in BCNF.
  4. AB is BCNF; key AC breaks ACD.
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

R(A, B, C, D) has A → B and BC → D. For parts AB and ACD, which original rule is lost, despite the split being lossless?
  1. BC → D; local closures from BC cannot add A or D.
  2. A → B; a determinant must appear in every part.
  3. Both rules; any two-table BCNF split loses all FDs.
  4. Neither rule; reversing local AC → D yields A.
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A cover for R(P, Q, R, S, T) is P → Q, Q → P, and RS → T. Which 3NF synthesis result retains all needed cover relations and adds a candidate-key table?
  1. PQ and RST only.
  2. PQ, RS, and PRS.
  3. PQ, RST, and PT.
  4. PQ, RST, and PRS.
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

A page shows 12 collections with an average of 75 entries each. About how many entry rows does a live count process, compared with how many stored count values a denormalized read fetches?
  1. 900 entry rows versus 12 count values.
  2. 900 entry rows versus 75 count values.
  3. 87 entry rows versus 12 count values.
  4. 75 entry rows versus 900 count values.
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

A report must show completed-day totals at 07:00. Raw facts remain authoritative. An overnight summary finishes at 06:40 and meets the reporting window; midday raw updates need not appear until the next day. Which maintenance plan fits?
  1. Update every summary row on each raw write, because summaries must always be live.
  2. Treat the summary as authoritative and delete raw facts immediately after refresh.
  3. Refresh whenever someone opens the report, without retaining a day cutoff.
  4. Refresh from raw facts before 07:00, with a documented day cutoff and rebuild.
Show answerHide answer

Save this lesson to see this answer.

Stuck on your own question? Homework Help

Key Terms

66 Key Terms, each with its definition

A

Alternate key
An alternate key is a candidate key not chosen as primary, represented by unique, non-null columns when implemented in SQL.
A required unique email can identify a customer even when customer ID is the table's primary key.
Armstrong's axioms
Armstrong's axioms are sound and complete rules—reflexivity, augmentation, and transitivity—for deriving functional dependencies.
A designer can justify an implied key-to-city rule by following dependencies through the customer ID.
Atomic value
An atomic value is one value treated as indivisible for the domain and operations of the design, instead of a managed collection of values.
A full name can be treated as one value when the application uses it only as a complete name.
Attribute closure
An attribute closure X⁺ is the set of all attributes determined by X under a specified FD set, found by repeated rule application.
If A⁺ reaches B and C but never D, A is not a superkey of a relation that also contains D.
Augmentation
Augmentation adds the same attribute set to both sides of an FD, preserving the implication when extra agreement is supplied.
From A → B, augmentation with D gives AD → BD, carrying the added attribute on both sides.

B

BCNF decomposition
A BCNF decomposition repeatedly splits a relation on a non-superkey determinant until every resulting relation passes the BCNF test.
Splitting ABC on B → C produces BC and AB, with B identifying the closure part BC.
Boyce–Codd normal form
Boyce–Codd normal form (BCNF) requires the determinant of every nontrivial FD to be a superkey, removing 3NF's prime-right-side exception.
Instructor → course fails BCNF in a student-instructor-course table when an instructor cannot determine which student is enrolled.
Business rule
A business rule states what the data is allowed to mean or contain, providing the basis for dependencies beyond the current sample.
A rule that each instructor teaches one course establishes instructor-to-course dependence for future rows.

C

Candidate key
A candidate key is a minimal superkey: it determines the whole relation, and removing any of its attributes destroys that ability.
If both order ID and product ID are needed to identify a line, their pair is a candidate key.
Canonical cover
A canonical cover is an equivalent FD set with redundant rules and extraneous attributes removed, combining dependencies with common left sides.
A → BC, B → C, and duplicate rules can simplify to A → B and B → C without losing implications.
Chase
The chase is a general tableau-based procedure for testing dependency-related properties, including losslessness of a multi-table decomposition.
A complex split can require a chase when a convenient sequence of shared-key join proofs is unavailable.
Composite key
A composite key is a candidate key containing two or more attributes that together identify a row, with each attribute needed.
Student and course identifiers together identify an enrollment when neither can identify it alone.

D

Decomposition
A decomposition replaces a relation with smaller relations whose attributes together cover the original, while retaining needed connections.
An order-line relation can become customers, orders, products, and lines connected by identifiers.
Decomposition rule
The decomposition rule separates a multi-attribute right side into smaller right sides while keeping the original determinant intact.
A → BC gives A → B and A → C; the rule does not permit splitting a composite left side.
Deletion anomaly
A deletion anomaly occurs when removing an intended fact also removes the only stored record of another fact that should survive.
Deleting a customer's last order can erase the customer's details when both share the same table.
Denormalization
Denormalization deliberately stores redundant facts or derived results in a normalized design to improve measured reads at a maintenance cost.
A page can read a stored reaction count directly instead of counting all reaction rows on every visit.
Dependency preservation
Dependency preservation means the FDs enforceable within separate parts together imply all original FDs, avoiding joined-table rule checks.
AB and BC preserve A → C indirectly when they retain A → B and B → C as local rules.
Dependency-set closure
The dependency-set closure F⁺ is the complete set of FDs implied by F, including dependencies absent from the original list.
A → C belongs to F⁺ when F lists A → B and B → C, even if it does not explicitly list A → C.
Determinant
A determinant is the attribute set on the left side of a functional dependency; its values fix the values on the right side.
In {booking_id, seat_id} → fare_paid, booking and seat identifiers together form the determinant.
Domain
A domain is the set of permitted values for an attribute, with the meaning and operations that make those values usable in a design.
A skill attribute can draw one value from a domain of valid skills, allowing a separate row for each skill.
Drift
Drift is disagreement between a stored derived value and its authoritative source, often caused by a missed or incorrect maintenance update.
A post count of eight disagrees with seven real comments after a deletion fails to adjust the counter.

E

Extraneous attribute
An extraneous attribute can be removed from a dependency without changing the implications of the FD set in which that dependency appears.
A is extraneous on the left of AB → C when the same FD set already contains B → C.

F

Fifth normal form
Fifth normal form (5NF) concerns join dependencies, addressing further cases where a relation can be reconstructed from smaller projections.
A design may need join-dependency analysis after its functional dependencies have already been normalized.
First normal form
First normal form (1NF) represents each attribute as one atomic domain value, without lists or nested tables, and distinguishes rows by keys.
An employee-skill table uses separate rows for SQL and Python instead of placing both in one cell.
Foreign key
A foreign key is an attribute set whose non-null values must match a referenced key, maintaining valid links between related rows.
The customer identifier in an order references an existing customer, keeping the order linked to its owner.
Fourth normal form
Fourth normal form (4NF) addresses redundancy governed by multivalued dependencies, beyond the functional-dependency conditions of BCNF.
Independent employee skills and languages can create repeated combinations even after a table meets BCNF.
Full dependency
A full dependency requires its entire determinant: no proper subset of the left-side attributes determines the dependent attributes.
A quantity for an order-product pair is fully dependent when neither order nor product alone fixes it.
Functional dependency
A functional dependency X → Y requires any two rows agreeing on every attribute of X to agree on every attribute of Y as well.
If each location code has one manager, two rows with that code must show the same manager.

H

Historical fact
A historical fact records a value belonging to a past event, with a different meaning from a live copy that follows current source changes.
The price paid for an order line remains unchanged when a product's current list price changes later.

I

Insertion anomaly
An insertion anomaly occurs when a table cannot record an independent fact without supplying another, unrelated fact for the row.
A product cannot be entered in an order-line table until some order supplies the required order ID.

L

Lossless join
A lossless join reconstructs exactly the original relation from its projections for every valid data set under the governing dependencies.
Orders joined with customers on customer ID recover the original customer details without false matches.

M

Materialized view
A materialized view stores a query result for later reads; when that result changes depends on the database's refresh mechanism.
A PostgreSQL report reads its last refreshed result until REFRESH MATERIALIZED VIEW is run again.
Modification anomaly
A modification anomaly occurs when changing one fact requires several row updates and incomplete updates can leave conflicting copies.
Changing a supplier's address on only one delivery row leaves another delivery with the old address.

N

Non-prime attribute
A non-prime attribute belongs to no candidate key and is subject to the partial- and transitive-dependency restrictions in 2NF and 3NF.
In a line table whose only key is order-product, quantity is non-prime even though the key determines it.
Nontrivial dependency
A nontrivial dependency determines at least one right-side attribute outside its determinant, expressing a rule beyond reflexivity.
A → B is nontrivial when A and B are different attributes, so a BCNF test must examine A's closure.
Normalization
Normalization is restructuring relations according to their dependencies to reduce repeated facts and the anomalies they cause.
Moving product names from order lines into a product table makes each name change affect one row.

P

Partial dependency
A partial dependency holds when a proper subset of a determinant already determines the dependent attribute, leaving part unnecessary.
Product name depends partially on an order-line key because product ID alone determines the name.
Primary key
A primary key is the candidate key chosen as the main identifier for rows, with uniqueness and non-null values enforced in SQL.
A customer table may choose customer ID as primary key while a required unique email remains another key.
Prime attribute
A prime attribute belongs to at least one candidate key, including keys not selected as the primary identifier of the relation.
Course is prime when student-course is a candidate key, even if student-instructor is chosen as primary.
Projected dependency
A projected dependency is an FD implied by the original rules whose attributes all lie in a selected smaller relation.
A → C still holds in the projection ACD when the original rules give A → B and B → C.
Projection
A projection is a relation formed by selecting specified attributes of another relation and removing duplicate resulting rows.
SELECT DISTINCT customer_id, customer_city projects those two columns without repeated identical pairs.
Proper subset
A proper subset contains some or none of another set's attributes while omitting at least one; key-subset tests find partial dependencies.
The set containing only product ID is a proper subset of the key containing order ID and product ID.
Pseudotransitivity
Pseudotransitivity derives WX → Z from X → Y and WY → Z, carrying an additional determinant through an implied dependency chain.
A → B combined with BC → D yields AC → D because A can supply B while C remains available.

R

Redundancy
Redundancy is repeated storage of the same fact about the same thing, which allows copies to disagree when changes miss a row.
A customer's current city repeats as the same fact when every order line stores that customer's city.
Reflexivity
Reflexivity states that an attribute set determines each of its subsets, giving dependencies that require no additional data rule.
AB → A follows by reflexivity because agreeing on A and B already includes agreement on A.
Repeating group
A repeating group stores multiple occurrences of the same kind of fact in numbered columns or another repeated structure within a row.
Columns phone1, phone2, and phone3 impose a limit that a related one-phone-per-row table avoids.

S

Second normal form
Second normal form (2NF) requires 1NF and prohibits a non-prime attribute from depending on a proper subset of any candidate key.
An enrollment table moves student names out because student ID alone fixes them within a composite key.
Shared-attribute test
The shared-attribute test proves a two-part split lossless when the intersection determines every attribute of at least one part.
Parts AB and BC pass when B → C holds, because their shared B is a superkey of BC.
Source of truth
A source of truth is the authoritative stored fact or data set used to derive, check, and rebuild other copies of the same information.
Comment rows supply the authoritative count when the number stored in the post row has drifted.
Spurious tuple
A spurious tuple is a joined row absent from the original relation, created when a decomposition loses information about valid combinations.
Joining on a shared nonunique department name can falsely assign an employee to another department ID.
Staleness
Staleness is the delay between a source change and the copy reflecting it, which must fit the freshness requirement of its readers.
An hourly sales summary may omit recent sales for almost an hour after the previous refresh.
Stored aggregate
A stored aggregate is a saved result such as a count, sum, or total derived from source rows and maintained when relevant source data changes.
A saved invoice total must be adjusted or rebuilt after a line is added, edited, or removed.
Superkey
A superkey is an attribute set that determines every attribute of a relation; it may contain attributes unnecessary for identification.
An order-product pair plus quantity is a superkey even when the pair alone already identifies the line.
Surrogate key
A surrogate key is an added identifier without business meaning; it identifies rows without removing their other functional dependencies.
Adding line_id still leaves product ID determining the product name wherever the design stores it.

T

Third normal form
Third normal form (3NF) requires each nontrivial single-right-side FD to have a superkey determinant or a prime dependent attribute.
Customer details move out of orders because customer ID is not an order key and those details are non-prime.
Transaction
A transaction groups changes into one unit so source and derived-copy updates can commit together or be rolled back together.
Inserting a comment and incrementing its post count in one transaction prevents a half-completed change.
Transitive dependency
A transitive dependency connects attributes through an intermediate determinant, as a key fixes a department that fixes its details.
An employee identifier reaches department floor through department ID, so the floor is a department fact.
Transitivity
Transitivity derives X → Z from X → Y and Y → Z, connecting two determinations through their shared intermediate attribute set.
Order ID determines customer ID, which determines city, so order ID also determines customer city.
Trigger
A trigger is database code run in response to a specified data event, such as an insert, delete, or update of source rows.
A comment-delete trigger can decrement the post counter without relying on every application writer.
Trivial dependency
A trivial dependency has a right side contained within its left side, so it holds regardless of the particular business rules.
The pair {order_id, product_id} always determines product_id because that attribute is already present.

U

Union rule
The union rule combines dependencies with a common determinant into one dependency whose right side contains all their dependent attributes.
From A → B and A → C, the union rule gives A → BC without adding a new business assumption.

V

View
A view is a named query that presents data from underlying tables without requiring a separate stored copy of the query result.
After customer and product facts move to separate tables, a view can still expose one wide order report that combines them.

W

Whole-key dependence
Whole-key dependence means a dependent attribute needs every attribute in a composite determinant, so no smaller subset determines it.
An enrollment grade needs student and course together; student ID alone does not fix a grade across courses.
Write contention
Write contention occurs when concurrent transactions compete to change the same data, making some wait while another holds a needed lock.
Many comments on one popular post can queue when every insert also updates that post's counter row.

Z

Zaniolo's test
Zaniolo's test checks 3NF by accepting a nontrivial X → A when X is a superkey or A belongs to at least one candidate key.
Instructor → course passes the test when course is prime, even though instructor cannot determine student.

#

3NF synthesis
3NF synthesis builds tables from a canonical cover, adds a candidate-key table if needed, and removes contained tables while preserving FDs.
AB, BC, and CDE need an added AD key table under A → B, B → C, and CD → E.

About this lesson

By StudeliReport a mistake

Make your own Study Materials

Turn your notes, slides and documents into Study Guides, Practice Questions, Flashcards and 6 more tools.

Get Started