IAE Academy

GATE DA

Normal forms

Integrity constraints, functional dependencies and normal forms

Integrity constraints keep a relation's data valid, and functional dependencies (FDs) are the rules that drive schema design: you use them to find keys, test normal forms and decompose a schema without losing information or constraints. Each task, whether computing an attribute closure, listing candidate keys, naming the highest normal form or checking a decomposition for lossless join and dependency preservation, follows a fixed method that these notes set out step by step.

6 previous-year questions · 6 solved · 6 practice questions

Integrity constraints

An integrity constraint is a rule that every legal database state must satisfy. The DBMS checks it on insert, delete and update, and rejects (or repairs) any operation that would break it. Convention in these notes: SQL keywords are in capitals and NULL follows three-valued logic (TRUE, FALSE, UNKNOWN).

Constraint

What it requires

Typical SQL

Domain

Every attribute value is drawn from its declared domain (type, range, NOT NULL, CHECK)

INT, NOT NULL, CHECK (marks BETWEEN 0 AND 100)

Key (uniqueness)

No two tuples agree on all attributes of a candidate key. In standard SQL, UNIQUE does not forbid NULLs; PRIMARY KEY does. A table has at most one PRIMARY KEY but may have several UNIQUE constraints

UNIQUE, PRIMARY KEY

Entity integrity

No attribute of the primary key is NULL

PRIMARY KEY implies NOT NULL

Referential integrity

Each foreign-key value with no NULL in it matches the referenced candidate key of some tuple in the parent relation

FOREIGN KEY ... REFERENCES ...

A CHECK constraint rejects a row only when its condition evaluates to FALSE; UNKNOWN passes. So CHECK (marks BETWEEN 0 AND 100) accepts a row whose marks is NULL, unless the column is also declared NOT NULL.

A foreign key may itself be NULL (unless declared NOT NULL), and a NULL foreign key is not checked against the parent. Under SQL's default matching rule (MATCH SIMPLE), a composite foreign key with NULL in any of its columns is not checked either. The referenced attributes must be declared PRIMARY KEY or UNIQUE in the parent. A foreign key may reference its own table.

Referential actions when a referenced parent row is deleted or its key is updated

  1. NO ACTION (the default when no action is declared) and RESTRICT: the delete or update is rejected if any child row references the parent row. RESTRICT checks immediately; NO ACTION checks at the end of the statement (or at commit, if the constraint is deferred).

  2. ON DELETE CASCADE: the referencing child rows are deleted as well (and their own referencing rows, recursively). ON UPDATE CASCADE: the foreign key in each referencing child row is changed to the parent's new key value; no row is deleted.

  3. SET NULL: the foreign key in each referencing child row is set to NULL (the column must allow NULL).

  4. SET DEFAULT: the foreign key in each referencing child row is set to its default value, which must match some parent row or be NULL, otherwise the action fails.

Example of the declaration (Dept must already exist with primary key did):

CREATE TABLE Emp (
  eid INT PRIMARY KEY,
  ename VARCHAR(30) NOT NULL,
  did INT,
  FOREIGN KEY (did) REFERENCES Dept(did)
    ON DELETE CASCADE
);

EXAM TIP

Four operations can violate referential integrity: INSERT into the child, UPDATE of the foreign key in the child, DELETE from the parent, and UPDATE of the referenced key in the parent. INSERT into the parent and DELETE from the child cannot, except in a table that references itself, where the same table is both parent and child.

Functional dependencies and Armstrong's axioms

A functional dependency on a relation (with ) holds if whenever two tuples agree on they also agree on . It is a property of the meaning of the data (all legal instances), not of one instance. An instance can only refute an FD, never prove it. is trivial when . , the closure of , is the set of all FDs implied by .

ARMSTRONG'S AXIOMS (SOUND AND COMPLETE)

Sound: they derive only FDs implied by F. Complete: they derive every FD in the closure F^+.

DERIVED RULES

All follow from the three axioms. Decomposition applies to the right side only; does not give .

ATTRIBUTE CLOSURE

Algorithm: start with result = X; repeatedly, for any FD in F with result, add ; stop when nothing is added.

MEMBERSHIP TEST AND SUPERKEY TEST

Use the closure algorithm for both. A candidate key is a minimal superkey: removing any attribute breaks .

Two FD sets and are equivalent () if every FD of follows from and every FD of follows from . Check by computing closures of the left sides: covers if for every in , computed using .

Finding candidate keys and minimal covers

Procedure to find all candidate keys

  1. Split right sides into single attributes and discard trivial FDs. List the attributes that never appear on the right side of any remaining FD. They are in every candidate key (call this set the core).

  2. Attributes that appear on right sides but never on a left side are in no candidate key.

  3. Compute the closure of the core. If it equals , the core is the only candidate key.

  4. Otherwise add the remaining attributes (those on both sides) to the core, one at a time, then in pairs, and so on, checking closures. Keep only minimal sets that determine (do not extend a set that is already a key).

  5. Prime attributes are those occurring in at least one candidate key; the rest are non-prime.

EXAM TIP

If is a candidate key and holds with , then is a superkey. It need not be minimal: remove attributes from it while its closure stays to reach a candidate key, which may be new. This is a quick way to find further keys once one is known.

COUNTING SUPERKEYS

A superkey is any set containing at least one candidate key. For more keys, extend by inclusion and exclusion over unions of keys. Example: keys AB, BC, BD in R(A,B,C,D) give .

MAXIMUM NUMBER OF CANDIDATE KEYS

No candidate key contains another, and this bound is reached (for example, when every set of attributes is a key).

Minimal (canonical) cover of F

  1. Split every right side into single attributes using decomposition.

  2. Remove extraneous attributes from left sides: in , is extraneous if computed with the full current set.

  3. Remove redundant FDs: delete if computed from the remaining FDs.

  4. Optionally merge FDs with the same left side by the union rule (the canonical-cover form).

A minimal cover is not unique, and two minimal covers of the same F can even have different numbers of FDs. For example, has the minimal covers (three FDs) and (four FDs). Always do step 2 before step 3: removing an extraneous attribute can make another FD redundant, which step 3 would then miss.

WORKED EXAMPLE

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

Solution
  1. A and B never appear on a right side, so both are in every key. .

  2. So AB is a key. It is the only one, because every key must contain AB, and any proper superset of AB is not minimal.

  3. Prime attributes: A, B. Non-prime: C, D, E.

  4. 2NF test: and , so no proper subset of AB determines a non-prime attribute. The relation is in 2NF.

  5. 3NF test: has C not a superkey and D non-prime. So the relation is not in 3NF.

Answer: Only key AB; prime = {A, B}; the relation is in 2NF but not 3NF.

WORKED EXAMPLE

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

Solution
  1. Split right sides: A→B, A→C, B→C, A→B, AB→C. Remove the duplicate A→B.

  2. Left side AB in AB→C: since , attribute A is extraneous, giving B→C, which already exists. Drop it.

  3. Redundancy: A→C can be derived from A→B and B→C (using the others, ), so remove it.

  4. Remaining set: A→B and B→C. Neither is redundant: removing A→B leaves , removing B→C leaves .

Answer: A minimal cover is {A → B, B → C}, with two FDs.

Normal forms

Normal forms limit the FDs a relation may have, to reduce the redundancy and update anomalies that FDs cause. BCNF removes all FD-caused redundancy; 3NF may keep some in exchange for always allowing a dependency-preserving decomposition. Every BCNF relation is in 3NF, every 3NF relation is in 2NF, and every 2NF relation is in 1NF. The tests below assume the relation is already in 1NF.

Normal form

Condition

Violation looks like

1NF

All attribute values are atomic (no repeating groups or sets in a cell)

A cell holding a list of phone numbers

2NF

1NF, and no non-prime attribute is functionally dependent on a proper subset of any candidate key

A proper subset of a key determines a non-prime attribute

3NF

For every non-trivial : X is a superkey, or A is prime

Non-prime attribute determined by a non-superkey (transitive dependency)

BCNF

For every non-trivial : X is a superkey

Any determinant that is not a superkey

3NF AND BCNF CONDITIONS

For the relation R on which F is given, it is enough to test the FDs of F after splitting right sides into single attributes. For a part of a decomposition, test the FDs of that lie inside (the projection), not just those of F.

Procedure to find the highest normal form

  1. Find all candidate keys and the set of prime attributes.

  2. BCNF: if every non-trivial FD in F (right sides split) has a superkey on the left, the relation is in BCNF. Stop.

  3. 3NF: if every such FD has a superkey on the left or a prime attribute on the right, the relation is in 3NF. Stop.

  4. 2NF: for every candidate key K and every attribute B in K, compute . If any of these closures contains a non-prime attribute, the relation is not in 2NF (only 1NF). Otherwise it is in 2NF. Checking only the FDs listed in F is not enough for 2NF, because a partial dependency may only be derived.

  5. Shortcuts: if every attribute is prime, the relation is at least in 3NF. A relation with two attributes is always in BCNF, and so is a relation with no non-trivial FDs.

EXAM TIP

If every candidate key is a single attribute (and no FD has an empty left side, that is, no attribute is constant), the relation is in 2NF, since a key has no proper non-empty subset. A relation that is in 3NF but not in BCNF must have two composite candidate keys that overlap: the violating FD has A prime, so A lies in a composite key K, and contains a second composite key that shares attributes with K.

Beyond BCNF, 4NF deals with multivalued dependencies, a kind of redundancy that FDs cannot express. The FD-based forms above stop at BCNF.

Lossless-join and dependency-preserving decomposition

Decomposing into with removes anomalies but must not lose information or constraints. Convention: decomposition uses projection, , and joins are natural joins under set semantics. The join of the projections always contains every original tuple, ; a lossy decomposition adds spurious tuples rather than losing tuples.

LOSSLESS-JOIN TEST FOR A BINARY DECOMPOSITION

Conditions: and F is the only set of constraints. The common attributes must be a superkey of at least one of the two parts. For more than two parts, use the tableau (chase) test.

Tableau (chase) test for lossless join

  1. Build a table with one row per and one column per attribute. Put the symbol if attribute is in , else .

  2. Repeatedly apply each FD of F: if two rows agree on X, make their Y symbols equal (use the symbol if either is an ; if both are symbols, use either one consistently).

  3. Stop when no change occurs. The decomposition is lossless iff some row becomes all symbols.

DEPENDENCY PRESERVATION

Practical test for each in F: set , and repeat for every , with closures computed using F, until Z stops growing. The FD is preserved if .

BCNF decomposition algorithm

  1. If some part is not in BCNF, pick a non-trivial FD that holds on (from , with ) where X is not a superkey of .

  2. Replace by and . The two parts share X, and X determines the first part, so this step is lossless.

  3. Repeat until every part is in BCNF.

3NF synthesis algorithm

  1. Compute a minimal cover of F and merge FDs with the same left side.

  2. For each FD in , create a relation with attributes .

  3. If no created relation contains a candidate key of R, add one relation whose attributes are a candidate key.

  4. Optionally drop any relation whose attributes are a subset of another's.

Method

Lossless join

Dependency preserving

Result

BCNF decomposition (split on a violating FD)

Always

Not always

Every part is in BCNF

3NF synthesis (from a minimal cover, add a key if none present)

Always

Always

Every part is in 3NF

A lossless, dependency-preserving BCNF decomposition does not always exist. With R(A,B,C) and F = {AB → C, C → B}, the keys are AB and AC, so R is in 3NF, but C → B violates BCNF. Any BCNF decomposition separates A, B and C so that AB → C no longer lies inside one part.

EXAM TIP

Lossless and dependency-preserving are independent properties. A decomposition can have one without the other. For example, with F = {A→B, B→C, C→D} on R(A,B,C,D), the parts {AB, ACD} are lossless (A determines AB) but lose B→C, because B and C never appear together and no part's projected FDs give it.

PREVIOUS-YEAR QUESTIONS

6 questions from the DA papers

Try each question first, then open the answer. We placed each question under a topic ourselves; the exam paper does not label topics.

See these papers in full: GATE DA 2026 · GATE DA 2025 · GATE DA 2024

GATE 2026 DA Q.17

GATE 2026 · DAQ.17 · 1 mark · MCQ

Let R(A,B,C,D,E) be a relational schema with functional dependency set F={A→BC, CD→E, E→A}.

Which of the following statements is correct?

  1. (A)

    AD, ED and CD are the only candidate keys of R.

  2. (B)

    AD and ED are the only candidate keys of R.

  3. (C)

    A, E and CD are the only candidate keys of R.

  4. (D)

    A and CD are the only candidate keys of R.

Answer and solution
See the question in the paper
GATE 2026 DA Q.17: answer and solution

GATE 2026 DA Q.26

GATE 2026 · DAQ.26 · 1 mark · MSQ

Consider two relations r and s defined on the relational schemas R(A,B) and S(E,C), respectively. A is the primary key of R and E is a foreign key of S referencing A in R.

Which of the following operations will NEVER violate the foreign key constraint?

  1. (A)

    Inserting records into relation r

  2. (B)

    Deleting records from relation s

  3. (C)

    Deleting records from relation r

  4. (D)

    Inserting records into relation s

Answer and solution
See the question in the paper
GATE 2026 DA Q.26: answer and solution

GATE 2025 DA Q.56

GATE 2025 · DAQ.56 · 2 marks · MSQ

Consider the following two relations, named Customer and Person, in a database:

Person (
    aadhaar CHAR(12) PRIMARY KEY,
    name VARCHAR(32));
Customer (
    name VARCHAR(32),
    email VARCHAR(32) PRIMARY KEY,
    phone CHAR(10),
    aadhaar CHAR(12),
    FOREIGN KEY (aadhaar) REFERENCES Person(aadhaar));

Which of the following statements is/are correct?

  1. (A)

    aadhaar is a candidate key in the Customer relation

  2. (B)

    phone can be NULL in the Customer relation

  3. (C)

    aadhaar is a candidate key in the Person relation

  4. (D)

    aadhaar can be NULL in the Person relation

Answer and solution
See the question in the paper
GATE 2025 DA Q.56: answer and solution

GATE 2025 DA Q.57

GATE 2025 · DAQ.57 · 2 marks · MSQ

Consider a database relation R with attributes ABCDEFG, and having the following functional dependencies:

A → BCEF E → DG BC → A

Which of the following statements is/are correct?

  1. (A)

    A is the only candidate key of R

  2. (B)

    A, BC are the candidate keys of R

  3. (C)

    A, BC, E are the candidate keys of R

  4. (D)

    Relation R is not in Boyce-Codd Normal Form (BCNF)

Answer and solution
See the question in the paper
GATE 2025 DA Q.57: answer and solution

PRACTICE

6 questions to test yourself

PRACTICE 12 marks · NAT

Consider the relation R(A, B, C, D, E) with the functional dependencies F = {A → B, B → C, CD → E, E → A}. How many candidate keys does R have?

Answer and solution

Answer:

  1. D never appears on a right side, so D is in every candidate key.

  2. : A gives B, B gives C, then CD gives E, so all five attributes. AD is a key.

  3. : B gives C, CD gives E, E gives A. All attributes, so BD is a key.

  4. : CD gives E, E gives A, A gives B. All attributes, so CD is a key.

  5. : E gives A, A gives B, B gives C. All attributes, so ED is a key.

  6. D alone has closure D, so each of these two-attribute sets is minimal. Any other key would need D plus an attribute from {A,B,C,E}, and would then contain one of the four keys already listed, so it would not be minimal.

  7. Number of candidate keys = 4.

PRACTICE 21 mark · MCQ

A relation T(P, Q, R, S) has the functional dependencies F = {PQ → R, R → S, S → P}. What is the highest normal form that T satisfies?

  1. (A)

    1NF but not 2NF

  2. (B)

    2NF but not 3NF

  3. (C)

    3NF but not BCNF

  4. (D)

    BCNF

Answer and solution

Answer: (C)

  1. Q never appears on a right side, so Q is in every candidate key, and .

  2. . : R gives S, S gives P, so PQRS. : S gives P, PQ gives R, so PQRS. Keys: PQ, QR, QS.

  3. Prime attributes: P, Q, R, S, which is every attribute. So T is in 3NF.

  4. BCNF: has R not a superkey (, which lacks Q). So T is not in BCNF.

PRACTICE 32 marks · NAT

R(A, B, C, D) has the functional dependencies F = {AB → C, C → D, D → A}. How many superkeys does R have (counting R itself as a superkey)?

Answer and solution

Answer:

  1. B never appears on a right side, so B is in every superkey.

  2. : AB gives C, C gives D, so ABCD. : C gives D, D gives A, so ABCD. : D gives A, then AB gives C, so ABCD. only.

  3. So AB, BC and BD are keys, and any set containing B plus at least one of A, C, D is a superkey.

  4. The sets are B together with any non-empty subset of {A, C, D}: .

  5. Number of superkeys = 7.

PRACTICE 41 mark · MCQ

Dept(did) has primary key did. Emp(eid, ename, did) has primary key eid and a nullable column did declared as FOREIGN KEY (did) REFERENCES Dept(did) ON DELETE SET NULL. Dept contains the row with did = 10, and exactly 3 Emp rows have did = 10. The statement DELETE FROM Dept WHERE did = 10 is executed. What is the outcome?

  1. (A)

    The delete is rejected and nothing changes

  2. (B)

    The Dept row and the 3 Emp rows are deleted

  3. (C)

    The Dept row is deleted and the 3 Emp rows remain with did set to NULL

  4. (D)

    The Dept row is deleted and the 3 Emp rows keep did = 10

Answer and solution

Answer: (C)

  1. ON DELETE SET NULL repairs referential integrity by setting the foreign key of every referencing child row to NULL.

  2. The parent row is deleted, so A is wrong (that would be NO ACTION or RESTRICT). The child rows are not deleted, so B is wrong (that is CASCADE).

  3. Keeping did = 10 (D) would leave dangling references, which referential integrity forbids.

  4. The Emp rows stay, with did = NULL, and a NULL foreign key is allowed.

PRACTICE 52 marks · MCQ

R(A, B, C, D) has the functional dependencies F = {A → C, C → A, AC → D}. What is the highest normal form that R satisfies?

  1. (A)

    1NF but not 2NF

  2. (B)

    2NF but not 3NF

  3. (C)

    3NF but not BCNF

  4. (D)

    BCNF

Answer and solution

Answer: (A)

  1. B never appears on a right side, so B is in every key, and .

  2. : A gives C, AC gives D, so ABCD. : C gives A, AC gives D, so ABCD. . Keys: AB and BC.

  3. Prime attributes: A, B, C. Non-prime: D.

  4. 2NF: drop B from key AB to get , which contains the non-prime D. So D depends on A, a proper subset of key AB, and R is not in 2NF.

  5. No FD in F has a proper subset of a key as its left side together with D on its right (AC is not a subset of AB or BC), so the violation shows up only through closures. The highest form is 1NF.

PRACTICE 62 marks · MSQ

R(A, B, C, D) has the functional dependencies F = {A → B, B → C, C → D}. Select ALL decompositions that are both lossless-join and dependency-preserving.

  1. (A)

    {AB, BC, CD}

  2. (B)

    {AB, CD}

  3. (C)

    {ABC, CD}

  4. (D)

    {AB, ACD}

Answer and solution

Answer: (A), (C)

  1. A: AB and BC share B, and gives a lossless join; joining the result ABC with CD on C is lossless because . All three FDs sit inside single parts, so they are preserved. Correct.

  2. B: AB and CD share no attribute, so the join is a Cartesian product and is not lossless. Rejected.

  3. C: ABC and CD share C and , so it is lossless. A→B and B→C are in ABC and C→D is in CD, so it is preserved. Correct.

  4. D: AB and ACD share A and , so it is lossless. But for : start with Z = B; the part AB gives , and ACD shares no attribute with Z. Z stays B, so is lost. Not preserving.

OFFICIAL GATE 2027 SYLLABUS WORDING

Copied from the GATE 2027 syllabus; see all 2027 syllabi.

GATE DA

integrity constraints, normal form

Preparing in Kolkata? IAE Academy's course for GATE DA.