UPI Study › Courses › Database Programming › Free lessons › Lesson 2.1 Free with a free account
Making Data Clean: Normalization Rules in SQL
Database Programming · Chapter 2: Normalization and Data IntegritySection 2.1 · lesson 8 of 768 min · free with a free account
Free preview
Create a free account to keep watching
It takes a minute and costs nothing. Your free account unlocks all of Chapter 1 and 3 more lessons of Database Programming.
Lesson complete
Earn the 3 college credits for Database Programming
Enrolling adds a quiz after each lesson, the graded work and the official transcript. Recommended for credit by NCCRS.
Next lesson: Understanding Normal Forms: Types and Worked Examples →← Installing Your Database Environment — MySQL and SQL Server Express Setup GuideNext lesson: Understanding Normal Forms: Types and Worked Examples →
A free account plays all of Chapter 1 and 3 more lessons of Database Programming. Create a free account →
In this lesson
Spot redundancy and anomalies, then split tables by functional dependencies.
- Identify redundancy and the update, insertion, and deletion anomalies it causes
- Explain functional dependencies and test them with counterexamples
- Decompose a mixed table while keeping identifiers as links
- Check that a decomposition is lossless by reconstructing the original facts
Free study notes
Get this lesson's notes by email
The key points and 4 practice questions with answers, in your inbox. One email, free.
One email. Unsubscribe in one click.
Transcript
Everything said in the video, section by section (996 words). Read along, or search it.
Opening Problem
Two Cities for One Customer
Maya Rao owns Lantern Books, our fictional campus bookstore. Asha moves, but two order records now disagree about her city. One says Pune. Another says Mumbai. Which should the shipping team trust, and why did one move require several edits? These are invented teaching records. The problem is their design: customer details have been copied beside orders. Normalization asks where each fact belongs, so the next change has one clear place to happen.
Redundancy
Customer Details Copied Beside Orders
Consider a flattened report from our shop. Order five thousand one belongs to customer one, Asha, in Pune. Order five thousand four also belongs to Asha. Her city is repeated, even though it describes the customer. That unnecessary duplication is redundancy. Repeated descriptive text consumes storage, and one real change now requires coordinated edits. Repeating an identifier is different: customer one appears on several orders because the relationships themselves are different facts.
Update Anomaly
One Move, Several Edits
An update anomaly occurs when one change must be repeated, and a missed copy leaves contradictory data. Asha moves to Mumbai. Changing the city on just one order leaves two answers for the same current address. A careful person might repair every row today. The design still demands that same care from every future program. Keeping current city in one customer record removes this particular synchronization problem. Correct rules and transactions still matter.
Insertion Anomaly
A Book Awaiting Its First Sale
An insertion anomaly blocks a fact because an unrelated fact has not happened. Imagine a new book awaiting its first sale. If every row requires an order, where can the shop record that book? Inventing an order would create false business data. A separate products table can hold the book before any customer buys it. A customer can likewise register without ordering. The goal is independent existence for independent subjects, rather than forcing every new fact into an order record.
Deletion Anomaly
Canceling an Order Erases Ben
A deletion anomaly destroys one fact while intentionally removing another. Ben has only one order in our disposable example. If his details exist only beside that order, deleting the canceled order also erases the customer record. Separate customers from orders, and canceling the order leaves Ben available for a future purchase. Deliberate retention and privacy policies need their own rules. They decide what the shop should intentionally keep or remove.
Functional Dependency
Customer Identifier Determines Current City
A functional dependency says that knowing one set of values fixes another, across every legal state of the data. Customer identifier determines current city, if our business rule gives each customer one current city. The identifier is the determinant. We read the relationship as customer identifier determines city. Two customers can share a city, so reversing that relationship fails. The rule concerns meaning, not spelling. Customer names are unsafe determinants when different people can share a name.
Testing Dependencies
Counterexamples Disprove a Dependency
A primary key identifies a row uniquely. Order identifier therefore determines the customer and date recorded for that order. Customer identifier does not determine order identifier: Asha can place several different orders. Product identifier determines current catalog price under our stated shop rule. It does not determine quantity on every order. A counterexample disproves a dependency. Matching sample rows cannot prove it; ask whether a future legal row could differ.
Naming the Fact
Catalog Price Versus Price Charged
A catalog price describes today's offer. A price charged describes one completed sale, and those are different facts. Changing the catalog must not rewrite an old invoice. Historical sale price therefore belongs with the sale information. Normalization removes unnecessary copies of the same fact. It does not forbid repeated values or require erasing legitimate history. Before splitting anything, name the fact precisely. Current price and charged price lead to different dependency rules.
Decomposition
Separate Homes for Customers and Products
Decomposition means splitting a relation into smaller relations. Start with customer facts in customers, identified by customer identifier. Product facts belong in products, including the current catalog price. This gives each product one independent home. Orders keep the date and customer identifier. They link to customer facts, instead of copying the city. Order items connect orders to products and hold quantity. One product appears once per order, so the identifier pair identifies each line.
Lossless Joins
Keeping Identifiers as Links
Keep customer identifier in orders as a link. Without that column, separating customer details would also lose who placed each order. Keep both identifiers in order items, so every line can still find its order and product. A join combines matching rows. A lossless split lets those joins reconstruct exactly the original legal facts, without omissions or invented combinations. More tables alone do not prove a better design. The dependencies and the preserved connections justify the split.
Quick Check
The Vanishing Publisher Phone Number
Amina Diallo, the shop's database administrator, reviews a new design for publisher contacts. Publisher phone is stored only beside each product. The last product from one publisher is removed, and its contact number disappears. Which failure occurred: an insertion anomaly, an update anomaly, or a deletion anomaly? Pause, and decide. Deletion anomaly is the answer. Removing a product also removed the only stored fact about its publisher. An update anomaly would need conflicting edits. An insertion anomaly would prevent adding a publisher before a product exists. Give publishers their own table, and retain publisher identifier in products. Now a publisher can survive the removal of its last product.
Workflow
Facts, Dependencies, Split, Then Test
Find the facts and write the dependencies first. Ask the people using the data which rules must remain true. Split by those rules, then link the resulting tables using identifiers. Normal forms provide staged tests for these choices. Check the reconstruction, then repeat the insertion, update, and deletion scenarios. Make sure each repair preserves intended relationships. Joins add work when reading. Measure real performance before deliberately duplicating facts, and document how any copies stay synchronized.
Key Takeaways
One Clear Home for Each Fact
Redundancy means unnecessary repeated facts. Normalization reduces the storage and maintenance costs that come with those copies. Insertion, update, and deletion anomalies reveal different ways a mixed table can fail during ordinary work. Functional dependencies express business rules. A sample can expose a broken rule, but it cannot establish the rule for tomorrow. A useful decomposition preserves the links and passes the lossless reconstruction test. Maya can change Asha's current city in one customer record.
About Database Programming at UPI Study
Database Programming (Computer Science 381) is a self-paced online course of 76 video lessons in 12 chapters, from database applications, SQL setup, schema planning and normalization to keys and constraints, data types, filtering and sorting, joins, subqueries, views, indexes, ROLLUP and PIVOT, regular expressions and database security. It carries a NCCRS credit recommendation for 3 semester credits.
Every lesson transcript is free on pages like this one, and the videos are free with a free UPI Study account. Enrolling adds a practice quiz after each lesson, the graded work and final exam that earn the credit, lifetime access, and an official transcript on completion. UPI Study has helped over 130,000 students with college credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Enroll now → Course details Download the syllabus All Computer Science courses Every credit course with PRO →
Why take it here
Why students take Database Programming with UPI Study
Where the credit goes
Universities that work with NCCRS
Database Programming carries a NCCRS credit recommendation. These universities work with NCCRS; some are UPI Study's signed partners. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Thomas Edison State UniversitySigned partner
University of the PeopleSigned partner
Charter Oak State CollegeSigned partner
Strayer UniversitySigned partner
Columbia Southern UniversitySigned partner
Indiana TechSigned partner
Penn StateWorks with NCCRS
Southern New Hampshire UniversityWorks with NCCRS
SUNYWorks with NCCRS
+many more cooperating universitiesFind my college →Find my college → Not listed? Ask Athena in the corner of this page, or book a 15-minute call.
FAQ
Questions students ask us
About Making Data Clean: Normalization Rules in SQL
What is normalization in database design?
What are update, insertion, and deletion anomalies?
What is a functional dependency in a database?
Does normalization mean a value should never be repeated?
About the Database Programming course
How many college credits is Database Programming?
How much does Database Programming cost and what is included?
Which universities accept UPI Study credits?
How long does Database Programming take?
How are the exams done?
How do my credits reach my college?
Ready for the full course? Earn 3 credits in Database Programming.
76 video lessons, a quiz after each one, and the graded work that earns the credit. Recommended for credit by NCCRS.
Updated
3 credits · NCCRSEnroll →