Skip to content
GATEiit

GATE CSE · Databases

Integrity constraints and normal forms

Integrity constraints, functional dependencies, attribute closure and keys, and the normal forms 1NF, 2NF, 3NF and BCNF with lossless and dependency-preserving decomposition, as GATE tests them.

Before you start

Concept notes

1. Integrity constraints

An integrity constraint is a rule every legal database state must satisfy. The DBMS rejects (or repairs) any insert, update or delete that breaks it.

  • Domain constraint: each value comes from the attribute's domain (type, range, CHECK, NOT NULL).
  • Key constraint: no two tuples agree on a candidate key (UNIQUE, PRIMARY KEY).
  • Entity integrity: no attribute of the primary key may be NULL.
  • Referential integrity: a foreign key value in the referencing relation must either be NULL or match a primary key value in the referenced relation.
  • Functional dependencies are also constraints; they drive normalisation.

Which operations can break referential integrity?

Operation Referencing (child) table Referenced (parent) table
Insert Can violate Safe
Delete Safe Can violate
Update of key/FK Can violate Can violate

On a violating delete in the parent, SQL lets you choose: RESTRICT/NO ACTION (reject), CASCADE (delete matching child rows too, which can chain further), SET NULL or SET DEFAULT. A self-referencing foreign key with ON DELETE CASCADE deletes a whole subtree, a common GATE trap.

2. Functional dependencies, closure and keys

A functional dependency (FD) X→Y holds if any two tuples that agree on X also agree on Y. It is trivial if Y⊆X.

Armstrong's axioms (sound and complete): reflexivity (Y⊆X⇒X→Y), augmentation (X→Y⇒XZ→YZ), transitivity. Derived rules: union, decomposition, pseudotransitivity.

Attribute closure X+: start with X; whenever some L→R has L⊆X+, add R; repeat until nothing changes. X→Y follows from F exactly when Y⊆X+.

  • Superkey: X+ contains all attributes.
  • Candidate key: a minimal superkey (no proper subset is a superkey).
  • Prime attribute: belongs to some candidate key.

Finding all candidate keys quickly:

  1. Attributes that never appear on any right side must be in every key. Call this core C.
  2. If C+ is everything, C is the only key.
  3. Otherwise add attributes that appear on right sides, smallest sets first, and keep only minimal superkeys.

If a relation with n attributes has exactly one candidate key of k attributes, it has 2n−k superkeys. With several keys, count by inclusion–exclusion.

3. Minimal cover and equivalence

Two FD sets F and G are equivalent if each implies the other: every FD of G follows from F (check with closures under F) and vice versa.

A minimal (canonical) cover Fc of F is an equivalent set with no redundancy. Build it in three passes:

  1. Split right sides so each FD has one attribute on the right: A→BC becomes A→B, A→C.
  2. Remove extraneous left attributes: in XB→A, drop B if A∈X+ (closure under the current set).
  3. Remove redundant FDs: drop X→A if A is still in X+ computed without that FD.

Do step 2 before step 3; the reverse order can leave redundancy. A minimal cover need not be unique, but every minimal cover is equivalent to F.

Why GATE cares: the 3NF synthesis algorithm starts from a minimal cover, and many questions ask "which set is equivalent to F" or "which FD is redundant". In each case the tool is the same: attribute closure.

4. The normal forms 1NF to BCNF

Normal forms limit redundancy and update anomalies (insert, delete, modify). Check them against all FDs that hold, which for a single relation means the given F is enough.

Form Condition
1NF Every attribute value is atomic (no sets or repeating groups)
2NF 1NF and no partial dependency: no non-prime attribute depends on a proper subset of a candidate key
3NF For every nontrivial X→A: X is a superkey or A is prime
BCNF For every nontrivial X→A: X is a superkey

Each form implies the previous one: BCNF ⊂ 3NF ⊂ 2NF ⊂ 1NF.

Quick facts:

  • A relation whose candidate keys are all single attributes is automatically in 2NF.
  • If every attribute is prime, the relation is in 3NF.
  • Every relation with two attributes is in BCNF.
  • 3NF but not BCNF needs an FD X→A where X is not a superkey but A is prime, e.g. overlapping candidate keys.
  • 4NF goes beyond FDs: for every nontrivial multivalued dependency X↠Y, X is a superkey.

To find the highest normal form: find all keys, mark prime attributes, then test each FD against BCNF, then 3NF, then 2NF.

Normal forms as nested sets1NF: atomic values2NF: no partial dependency3NF: X superkey or A primeBCNF: every determinant a superkeyEach inner set is stricter
Every BCNF relation is in 3NF, every 3NF relation is in 2NF, and so on outward.

5. Decomposition: lossless join and dependency preservation

Normalising splits R into R1,R2,…. Two properties matter.

Lossless join: joining the pieces gives back exactly R, no spurious tuples. For two pieces the test is R1∩R2→R1orR1∩R2→R2 that is, the common attributes form a superkey of at least one piece. If the pieces share no attribute, the join is a cross product and is lossy. For three or more pieces, use the chase (tableau) test or merge two lossless pieces at a time.

Dependency preservation: let Fi be the FDs of F+ that use only attributes of Ri. The decomposition preserves dependencies if (F1∪F2∪… )+=F+. Practical test: for each X→Y in F, compute X+ using only the projected FDs and check Y is reached.

Goal Lossless? Dependency preserving?
3NF synthesis Always Always
BCNF decomposition Always Not always

So BCNF can force you to lose a dependency, while 3NF never does. That is the standard reason a designer may settle for 3NF.

Formulas to remember

Superkey testClosure of X under F contains every attribute
X+=R
FD implication
F⊨X→Y  ⟺  Y⊆X+
BCNF condition
X→A nontrivial⇒X is a superkey
3NF condition
X→A nontrivial⇒X superkey or A prime
Binary lossless-join test
(R1∩R2)→R1   or   (R1∩R2)→R2
Superkeys with one candidate keyn attributes, single candidate key of k attributes
2 n−k

Common mistakes

  • Checking 2NF against only one candidate key: a partial dependency on any candidate key breaks 2NF.
  • Calling an attribute non-prime because it is not in the primary key; prime means it appears in some candidate key.
  • Removing redundant FDs before removing extraneous left-side attributes when building a minimal cover.
  • Assuming BCNF decomposition preserves every dependency; only lossless join is guaranteed.
  • Declaring a decomposition lossless just because the pieces share an attribute; the shared attributes must be a superkey of one piece.
  • Forgetting that ON DELETE CASCADE chains through a self-referencing foreign key.

Worked examples

Try each step yourself, then reveal the working.

Example 1: Candidate keys and highest normal form

numerical

R(A,B,C,D,E,F) with F={AB→C, C→D, D→A, BE→F}. Find all candidate keys and the highest normal form of R.

  1. Step 1: Which attributes never appear on a right side?

    Try it on paper first.

Example 2: BCNF decomposition that loses a dependency

numerical

R(A,B,C,D) with F={AB→C, C→A, C→D}. Decompose into BCNF and check whether the decomposition is lossless and dependency preserving.

  1. Step 1: Find the candidate keys.

    Try it on paper first.

Example 3: Finding a minimal cover

numerical

Find a minimal cover of F={A→BC, B→C, AB→D, D→C}.

  1. Step 1: Split right sides.

    Try it on paper first.

Example 4: Which operations can break referential integrity?

conceptual

Dept(dno, dname) is referenced by Emp(eid, name, dno) through the foreign key Emp.dno. Which of these can violate referential integrity: inserting into Emp, inserting into Dept, deleting from Emp, deleting from Dept?

  1. Step 1: Think about the child table Emp.

    Try it on paper first.

Previous year questions

19 official GATE CSE questions on this topic, newest first.

Practise these 19 PYQs →

Topic test

10 questions: up to 4 official PYQs and original practice questions, with GATE marking (MCQ wrong answers lose marks). Score 60% or more to pass. A new set is drawn each time.

Mark as mastered

Loading your progress…

My revision notes

Notes written by the GATEiit team against the official GATE CSE syllabus; being checked by a reviewer. Updated 2026-11-21. Spotted a mistake? Use Report an issue on any question, or contact us.