Algorithm Search⌘K

Definitionadvanced

Fifth normal form (5NF)

Also called 5NF, project-join normal form.

A schema in which every nontrivial join dependency is implied by the candidate keys, so no lossless split into projections removes redundancy.

Fifth normal form, or project-join normal form, is the normal form of Fagin (1979) for schemas with join dependencies. It asks that every join dependency that holds follows from the candidate keys alone, so a split into projections is lossless only for a reason that also makes it useless. The normalization page places 5NF at the top of the chain of normal forms, and the BCNF page treats the FD case. This page gives the exact definition, a test of a JD against the keys, the proof that 5NF implies 4NF, and one schema for each gap in the chain from 1NF to 5NF.

Definition

Let UU be a finite set of attributes and DD a finite set of FDs and JDs over UU, where an MVD X↠YX \twoheadrightarrow Y counts as the JD ⋈[XY,X(U−XY)]\bowtie[XY, X(U - XY)]. We use set semantics. Let K1,…,KpK_1, \ldots, K_p be the candidate keys of (U,D)(U, D), and let Keys(D)={K1→U,…,Kp→U}\mathrm{Keys}(D) = \{K_1 \to U, \ldots, K_p \to U\}, the key dependencies.

Definition (Fagin 1979; Date's form). (U,D)(U, D) is in fifth normal form if every JD that DD implies is implied by Keys(D)\mathrm{Keys}(D).

Fagin asked the same of the FDs that DD implies. This adds nothing: the proof below that 5NF implies 4NF shows that each nontrivial implied FD then has a superkey on its left side, and so follows from a key dependency.

Testing a JD against the keys. Let σ=⋈[X1,…,Xk]\sigma = \bowtie[X_1, \ldots, X_k]. Repeat: if two components XiX_i and XjX_j have Kl⊆Xi∩XjK_l \subseteq X_i \cap X_j for some key KlK_l, replace them by Xi∪XjX_i \cup X_j. Then Keys(D)⊨σ\mathrm{Keys}(D) \models \sigma if and only if this ends with a component equal to UU.

Proof. Run the chase of the tableau for σ\sigma with the FDs Kl→UK_l \to U: row ii has 00 on XiX_i and the symbol ii elsewhere. We claim that at each time the rows fall into classes, where all rows of a class are equal, have 00 on the union CC of their components and a symbol of their own elsewhere. This holds at the start. Two rows of different classes CC and C′C' agree exactly on C∩C′C \cap C', where both hold 00. So Kl→UK_l \to U applies to them exactly when Kl⊆C∩C′K_l \subseteq C \cap C', and then it makes all their symbols equal, which merges the two classes into one class with union C∪C′C \cup C'. So the chase performs exactly the merges of the test. It ends with an all-00 row exactly when some class has C=UC = U, and by the chase theorem this is exactly when Keys(D)⊨σ\mathrm{Keys}(D) \models \sigma. □\square

The test is polynomial once the keys are known. Finding all keys can take exponential time, since there can be exponentially many.

It is enough to check DD. If each FD of DD has a superkey on its left side and each JD of DD passes the test above, then (U,D)(U, D) is in 5NF. Proof. Keys(D)\mathrm{Keys}(D) implies each member of DD: an FD X→YX \to Y with X⊇KlX \supseteq K_l follows from Kl→UK_l \to U. Also DD implies Keys(D)\mathrm{Keys}(D). So the two sets imply the same JDs. □\square Superkeys under DD must be found with an implication test for FDs and JDs, such as the chase.

5NF implies 4NF. Let (U,D)(U, D) be in 5NF and let D⊨X↠YD \models X \twoheadrightarrow Y be nontrivial, with Z=U−XYZ = U - XY. This MVD is the JD ⋈[XY,XZ]\bowtie[XY, XZ], so Keys(D)\mathrm{Keys}(D) implies it. Keys(D)\mathrm{Keys}(D) holds FDs only, so by Fagin's theorem and the binary test of the lossless join page, Keys(D)⊨X→Y\mathrm{Keys}(D) \models X \to Y or Keys(D)⊨X→Z\mathrm{Keys}(D) \models X \to Z. Both are nontrivial FDs. Every FD of Keys(D)\mathrm{Keys}(D) has a key on its left side, so (U,Keys(D))(U, \mathrm{Keys}(D)) is in BCNF, and the left side XX of a nontrivial FD that it implies is a superkey. So (U,D)(U, D) is in 4NF. □\square

A sufficient condition (Date and Fagin 1992). If (U,D)(U, D) is in 3NF and every candidate key has a single attribute, then it is in 5NF.

Examples and non-examples

The strict chain. Each normal form implies the one before it, 5NF⇒4NF⇒BCNF⇒3NF⇒2NF⇒1NF\text{5NF} \Rightarrow \text{4NF} \Rightarrow \text{BCNF} \Rightarrow \text{3NF} \Rightarrow \text{2NF} \Rightarrow \text{1NF}, and each step is strict:

in not in schema dependencies the violation
1NF 2NF Grade(S,C,G,N)\mathrm{Grade}(S, C, G, N) SC→GSC \to G, S→NS \to N NN depends on the part SS of the key SCSC
2NF 3NF Emp(E,D,N)\mathrm{Emp}(E, D, N) E→DE \to D, D→ND \to N DD is not a superkey and NN is not prime
3NF BCNF Addr(C,S,Z)\mathrm{Addr}(C, S, Z) CS→ZCS \to Z, Z→CZ \to C ZZ is not a superkey, but CC is prime
BCNF 4NF CTB(C,T,B)\mathrm{CTB}(C, T, B) C↠TC \twoheadrightarrow T CC is not a superkey
4NF 5NF SPJ(S,P,J)\mathrm{SPJ}(S, P, J) ⋈[SP,PJ,JS]\bowtie[SP, PJ, JS] the JD does not follow from the key SPJSPJ

The pages of 2NF, 3NF and 4NF explain the first four rows. For the last one: the JD implies no FD, because the chase with JDs never makes two symbols equal, so the only key is SPJSPJ. The JD implies no nontrivial MVD either, as the join dependency page shows with the chase, so SPJ\mathrm{SPJ} is in 4NF. In the test against the key SPJSPJ, no two components contain the key in their intersection, so no merge happens, no component becomes UU, and the JD is not implied by the keys. The 5NF split is into SPSP, PJPJ and JSJS, and each part, with two attributes and no dependency, is in 5NF.

  • A JD that the key implies. Emp(E,N,S,D)\mathrm{Emp}(E, N, S, D) with employee, name, salary and department, and F={E→NSD}F = \{E \to NSD\}. The JD ⋈[EN,ES,ED]\bowtie[EN, ES, ED] holds, and the test merges ENEN and ESES on the key EE, then ENSENS and EDED, which gives UU. So the JD follows from the key. The schema is in 5NF, and indeed by Date and Fagin, since it is in 3NF with a single-attribute key. Splitting it into three parts would be lossless but would remove no redundancy.
  • No dependencies. With D=∅D = \emptyset, the only key is UU, every implied JD is trivial, and the schema is in 5NF.
  • Join dependency. The JD page defines join dependencies, their trivial cases and their relation to MVDs.
  • 4NF and BCNF. 4NF is 5NF restricted to JDs with two components, and BCNF is the case of FDs. With FDs only, BCNF, 4NF and 5NF agree, because every JD that FDs imply is then implied by the keys.
  • Implication of JDs. Deciding whether DD implies a JD uses the chase. With JDs in DD the chase can be expensive, which makes 5NF hard to test in general. The test against the keys above is the easy part.
  • Lossless decompositions. The split of a schema that violates 5NF uses the components of the violating JD, and it is lossless because the JD holds. The tableau test checks lossless joins under FDs.

References

  1. Ronald Fagin, Normal forms and relational database operators, Proceedings of the 1979 ACM SIGMOD International Conference on Management of Data, 153 to 160 (1979), project-join normal form, defined by the implication of all dependencies by the key dependencies
  2. C. J. Date and Ronald Fagin, Simple conditions for guaranteeing higher normal forms in relational databases, ACM Transactions on Database Systems 17(3), 465 to 476 (1992), a 3NF schema in which every key has one attribute is in project-join normal form
  3. David Maier, Alberto O. Mendelzon and Yehoshua Sagiv, Testing implications of data dependencies, ACM Transactions on Database Systems 4(4), 455 to 469 (1979), the chase for functional and join dependencies, used here for the test of a JD against the keys
  4. Serge Abiteboul, Richard Hull and Victor Vianu, Foundations of Databases, Addison-Wesley (1995), Chapter 11 (design and dependencies), normal forms for join dependencies

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/PD85QQ/text.yaml