Understanding Normal Forms: Types and Worked Examples

UPI Study › Courses › Database Programming › Free lessons › Lesson 2.2 Free with a free account

Understanding Normal Forms: Types and Worked Examples

Database Programming · Chapter 2: Normalization and Data IntegritySection 2.2 · lesson 9 of 7611 min · free with a free account

← Making Data Clean: Normalization Rules in SQLNext lesson: Breaking Down First Normal Form (1NF) with Examples →

A free account plays all of Chapter 1 and 3 more lessons of Database Programming. Create a free account →

Earn 3 college credits for Database ProgrammingRecommended for credit by NCCRS · Computer Science 381 · self-paced · one payment, lifetime access

In this lesson

From first normal form to fifth, with keys and worked examples.

  • Define superkeys, candidate keys, prime attributes, and determinants
  • Remove partial dependencies to reach second normal form
  • Explain how Boyce-Codd normal form tightens third normal form
  • Recognize multivalued and join dependencies addressed by fourth and fifth normal forms

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 (1,252 words). Read along, or search it.

Opening Problem

A Workshop Title Copied Everywhere

Leo Park develops Lantern Books' software. He also maintains a fictional staff workshop register, separate from our shop database. The workshop title repeats on every registration. A rename changes some copies, but the register still shows the old title elsewhere. Normal forms give Leo tests for this design, and a way to repair it without guessing how many tables look tidy.

The Ladder

From First Normal Form to Fifth

An unnormalized sheet may contain lists. First normal form, or first N F, removes repeating groups and uses individual domain values. Second normal form adds a dependency test: non-prime attributes must need every part of every candidate key. Third normal form permits a nontrivial dependency when its determinant is a superkey, or its dependent attribute is prime. Boyce-Codd normal form removes that prime-attribute exception. Fourth and fifth forms address multivalued and join dependencies, beyond ordinary functional dependencies.

Key Vocabulary

Superkeys, Candidate Keys, and Prime Attributes

A superkey identifies a whole row. A candidate key is a minimal superkey: remove any column, and uniqueness is no longer guaranteed. A composite key needs multiple columns together. Choosing one candidate makes it the primary key; the other candidates remain possible identifiers. A prime attribute belongs to at least one candidate key. A non-prime attribute belongs to none, regardless of the chosen primary key. A determinant is the left side of a functional dependency. Knowing its value fixes the dependent value in every legal database state.

Worked Example

The Workshop Registration Register

Our register stores learner, course, learner name, course title, and grade. Every cell has one value, so it passes first normal form. Learner one registers for both Database Design and Query Basics. Database Design also has learner two, so neither identifier alone is unique. The learner and course pair is the candidate key. Grade describes that specific learner taking that specific course. Learner name repeats per registration, and course title repeats per learner. Those repeated descriptions create update, insertion, and deletion anomalies.

Second Normal Form

Partial Versus Full Dependencies

Learner identifier alone determines learner name. Course identifier alone determines course title, even before we know the other half of a registration. Those are partial dependencies, because a proper subset of the composite candidate key already determines a non-prime attribute. The complete pair determines grade, and neither half suffices under our workshop rules. That is a full dependency. Second normal form requires first normal form, plus no such partial dependency on any candidate key. Inspect every candidate, not just the primary.

Repair

Learners, Courses, and Registrations

Move learner identifier and learner name into Learners. The identifier becomes the new relation’s key, so the name is stored once. Move course identifier and title into Courses. A new course now exists before its first registration. Keep the learner and course pair, plus grade, in Registrations. Its key still connects the learner to the course. A title rename changes one course row. Removing a registration preserves both participants, and matching their keys reconstructs the original register.

Quick Check

Where Should the Tool Label Move

A separate equipment system records reservation identifier, tool identifier, tool label, and reserved hours. Its only candidate key is the reservation and tool pair. A tool identifier fixes its label; reserved hours require the pair. Where should tool label move? Choose a tool catalog, a reservation header, or an hours log. Pause, and decide. The tool catalog is the answer. Tool identifier determines tool label, independently of which reservation uses the tool. A reservation header would repeat a tool's label across reservations, or fail when one reservation includes several tools. Keep the pair and hours together. The new catalog removes a partial dependency while preserving every reservation's tool link.

Third Normal Form

Transitive Chains Through Department

If all candidate keys are single-column, there is no proper nonempty key subset to test. The usual partial-dependency problem cannot occur. That does not settle third normal form. A staff identifier might determine department identifier, which determines department name. Move department name to Departments, and retain department identifier in Staff. In this simple design, that removes the transitive dependency. The formal third-form rule still allows a prime attribute on the right. That exception explains why Boyce-Codd can require another split.

Boyce-Codd Form

When a Tutor Determines the Subject

Consider a separate tutoring register with learner, subject, and tutor. Each learner has one tutor per subject; each tutor teaches exactly one subject. Learner plus subject identifies a row. Learner plus tutor also identifies a row, so both pairs are candidate keys. Tutor determines subject, but tutor alone cannot identify a whole row: several learners can use that tutor. Subject is prime, so this dependency passes third normal form. Boyce-Codd rejects it because its determinant is not a superkey. Create TutorSubject, keyed by tutor, and LearnerTutor, keyed by the learner and tutor pair. Their matching tutor values reconstruct the tutoring rows. A tutor's subject now has one home. Renaming that subject no longer means editing every learner row. But one learner could now link to two tutors who teach the same subject. Neither table's key alone blocks that combination. The original one-tutor-per-subject dependency needs a check across the relations. Lossless reconstruction and dependency preservation are different promises.

Fourth Normal Form

Independent Subjects and Languages

Suppose a tutor teaches three subjects and speaks two languages. Every subject-language combination is allowed, because those skills are independent. A combined relation needs six rows: three times two. Adding one language requires another row for every subject. Split it into TutorSubject and TutorLanguage. Now the same independent facts need five rows: three plus two. This is a multivalued dependency. Fourth normal form requires a superkey determinant for each nontrivial multivalued dependency; split only when independence is real.

Fifth Normal Form

Join Dependencies and Spurious Rows

Fifth normal form concerns join dependencies: when projections can reconstruct a relation. Its nontrivial join dependencies must follow from candidate keys. Imagine tutor-subject, subject-campus, and tutor-campus pairs. Joining them can produce a tutor-subject-campus triple whenever all three pairs match. That is valid only if the business rule guarantees every such triple. A tutor might teach a subject only at one campus. If the pairwise tables invent another campus assignment, that result is a spurious row. Never assume matching pairs guarantee an authorized triple.

Quick Check

Rejoining Teacher, Subject, and Campus Pairs

A fresh scheduling system stores three assignments: X teaches Design at North; X teaches Queries at South; Y teaches Design at South. It keeps only teacher-subject, teacher-campus, and subject-campus pairs, then rejoins them. Consider X teaching Design at South. Does that candidate match all three pairs, even though it was never assigned? Pause, and decide. Present is the answer. X-Design exists, X-South exists, and Design-South exists, but the original triple did not. This demonstrates a spurious combination. The missing-pair option fails because each needed pair came from a different legitimate assignment. A one-campus limit was never part of the business rules. Keep the original triples unless a valid join dependency justifies decomposing them.

Denormalization

Measured Copies for Faster Reads

Denormalization deliberately repeats facts, often in a report or summary table. It can reduce reading work, while introducing maintenance work. First measure the slow query. Check indexes and query design before blaming joins; duplication is not an automatic speed improvement. If a nightly dashboard needs a summary, keep normalized records authoritative. Define who refreshes the copy, and how readers recognize its age. Copied values consume storage and can drift. A historical charged price is different: it records a sale fact, rather than a stale current catalog price.

Key Takeaways

Dependencies, Not Visual Tidiness

Normal forms test dependencies, not visual tidiness. First normal form is the foundation, and second removes partial dependencies from non-prime attributes. Third normal form handles ordinary transitive chains, with its formal prime-attribute exception. Boyce-Codd requires superkeys for nontrivial functional dependencies. Fourth addresses independent multivalued sets; fifth addresses join dependencies. A decomposition must preserve facts, and its rule-enforcement costs deserve an explicit check. Leo can repair his workshop register by keeping names with learners, titles with courses, and grades with registrations.

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.

Compare: Database Fundamentals vs Database Programming

Why take it here

Why students take Database Programming with UPI Study

Write the SQL behind every appDatabase Programming teaches SQL in MySQL and SQL Server side by side: designing and normalizing tables, keys and constraints, data types, inserting, updating and deleting rows, filtering, grouping, joins, subqueries, views, indexes, transactions, and protecting data from SQL injection. It suits computer science and information technology degrees.
Credit at a fraction of the priceThe same 3 credits can cost $750 or more at a US college. Here it is one payment, self-paced, with lifetime access.
Finish your degree soonerTransfer credits reduce the courses you still owe, so you can graduate earlier or lighten a heavy semester.
Strengthen an applicationA completed college-level course on an official transcript shows admissions and scholarship committees you can do the work.
Study on your own scheduleNo start dates, no deadlines. Watch the lessons, practice, and take the final when you are ready.
130,000+students helped with college creditsACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.

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.

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 Understanding Normal Forms: Types and Worked Examples

What are the normal forms in database design?
The normal forms are a ladder of dependency tests: first, second, third, Boyce-Codd, fourth, and fifth. First normal form requires single domain values and no repeating groups. Second removes partial dependencies of non-prime attributes on a candidate key. Third handles transitive chains, and Boyce-Codd requires the determinant of every nontrivial functional dependency to be a superkey. Fourth and fifth address multivalued and join dependencies.
What is a partial dependency in second normal form?
A partial dependency exists when part of a composite candidate key already determines a non-prime attribute. In a registration table keyed by learner and course, learner_id alone determines learner name, and course_id alone determines course title. Grade needs the full pair, so it is fully dependent. Second normal form requires first normal form and no partial dependency on any candidate key, so names and titles move to their own tables.
What is the difference between 3NF and BCNF?
Boyce-Codd normal form is stricter: every nontrivial functional dependency needs a superkey as its determinant, while third normal form also allows a dependency whose dependent attribute is prime. Suppose each tutor teaches one subject and each learner has one tutor per subject. Tutor determines subject, but tutor alone is not a superkey. Because subject belongs to a candidate key, the table passes 3NF yet fails BCNF.
When should you denormalize a database?
Consider denormalizing after measuring a slow query and checking indexes and query design first. Denormalization deliberately repeats facts, often in a report or summary table, to reduce reading work. The copies cost storage and can drift, so keep the normalized records authoritative, decide who refreshes each copy, and let readers see how current it is. Duplication does not automatically make queries faster.

About the Database Programming course

How many college credits is Database Programming?
Database Programming (Computer Science 381) carries a NCCRS credit recommendation for 3 semester credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
How much does Database Programming cost and what is included?
$250, paid once, with lifetime access: all 76 video lessons, a practice quiz after each, the graded work and final exam, and an official transcript when you finish. Students who want several courses choose UPI Study PRO instead.
Which universities accept UPI Study credits?
UPI Study has signed partner agreements with universities such as Thomas Edison State University, University of the People and Charter Oak State College, and works with universities such as Penn State, SNHU and SUNY. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities. Use "Find my college" on this page to check yours.
How long does Database Programming take?
It is self-paced with no deadlines. The 76 lessons total about 11 hours of video; most students add reading and practice time and finish in a few weeks to a few months, on their own schedule.
How are the exams done?
Quizzes and assignments are online in the course. The final exam is taken online with proctoring; a person on the UPI Study team checks assignments, usually within two days.
How do my credits reach my college?
When the course shows 100% complete, request the official transcript from your dashboard. It is sent to the college you name, and you can send it to more than one. Check your college first with "Find my college" on this page, or ask Athena.

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

Database Programming
3 credits · NCCRS
Enroll →