chapter

    Er Model, Keys and Integrity Constraints Short Notes for Gate Da

    Er Model, Keys and Integrity Constraints short notes for GATE DA: 2 study cards covering concepts, formulas, shortcuts and exam traps, plus solved practice qu

    Er Model Keys and Integrity Constraints short notes

    Summary: Mapping Rules Cheat Sheet

    Summary: Mapping Rules Cheat Sheet

    Entity / Relationship Type Mapping Rule
    Strong EntityRelation with same name. PK becomes PK.
    Weak EntityRelation. Owner PK becomes FK. Owner PK + Discriminator = PK.
    1:N RelationshipOwner PK becomes FK in the N-side relation.
    M:N RelationshipNew relation. PK is union of both entity PKs.
    1:1 RelationshipOne PK becomes FK in the other relation. Place in the totally participating side.
    Multivalued AttrNew relation. Entity PK + Attribute. PK is both.
    n-ary RelationshipNew relation. PK is union of all participating entity PKs.

    Quick Recall: Keys, NULLs, and FKs

    Final Cheat Sheet

    NULL Logic

    • NULL = NULL is Unknown (not True).
    • Use IS NULL to check for NULLs.

    Key Constraints

    • Primary Key: Must be UNIQUE and NOT NULL.
    • Unique Key: Must be UNIQUE. Allows NULLs (multiple NULLs permitted in standard relational model).

    Referential Integrity (Foreign Keys)

    • FK value must exist in Parent PK OR be NULL.
    • Safe Operations (Never Violate): Insert Parent, Delete Child, Update non-keys.
    • Risky Operations (Can Violate): Insert Child (if FK invalid), Delete Parent (if referenced).

    Try a question

    Answer it here to see how it works. Nothing is recorded until you sign in.

    Question 1
    Level 1: Warm-up

    Consider a parent table P and a child table C with a foreign key referencing P. Which of the following statements correctly describes an operation that will NEVER violate the referential integrity constraint?

    Question 2
    Level 1: Warm-up
    Consider two relations with primary key , and with foreign key referencing in . Which of the following operations is IMPOSSIBLE to violate any integrity constraint?
    Question 3
    Level 1: Warm-up
    Consider a parent table with primary key , and a child table with foreign key referencing . Which of the following states is IMPOSSIBLE in a valid database satisfying referential integrity?
    Question 4
    Level 1: Warm-up
    Consider a parent table and a child table with a foreign key referencing . Which of the following scenarios is IMPOSSIBLE in a database strictly enforcing referential integrity?
    Question 5
    Level 1: Warm-up

    In a relational database with properly enforced integrity constraints, consider the following scenarios:

    • Scenario A: A child table has a tuple with a NULL value in the foreign key column
    • Scenario B: A parent table has a tuple deleted while a child table references it (without CASCADE)
    • Scenario C: A child table has a tuple with a foreign key value that matches a parent's primary key
    • Scenario D: A child table has a tuple with a foreign key value that does not match any parent's primary key and is not NULL

    Which of these scenarios is IMPOSSIBLE in a database with proper referential integrity?

    Question 6
    Level 1: Warm-up

    Consider a parent table with primary key containing tuples with values . A child table has a foreign key referencing and currently contains tuples: .

    Evaluate the following six operations:

    1. Insert into
    2. Delete from
    3. Insert into
    4. Delete from
    5. Update : change from $10$ to $50$
    6. Update : change from $30$ to $60$

    How many of these operations will violate referential integrity constraints?

    Question 7
    Level 1: Warm-up

    In the standard ER-to-relational mapping rules, some relationships require the creation of a brand new relation, while others do not. If an ER model contains exactly one 1:N relationship and exactly one M:N relationship, what is the minimum number of new relations that must be created specifically for these relationships?

    Question 8
    Level 1: Warm-up

    An ER model contains a 1:N relationship with 2 descriptive attributes and an M:N relationship with 1 descriptive attribute. What is the minimum number of new relations created specifically to accommodate these relationships and their descriptive attributes?

    Question 9
    Level 1: Warm-up

    A child table has a composite foreign key consisting of 3 columns referencing a parent table's primary key. What is the minimum number of columns in this foreign key that must be NULL to satisfy the referential integrity constraint if the relationship is not applicable for a specific tuple?

    Question 10
    Level 1: Warm-up
    Match the following operations with their ability to violate referential integrity constraints: List I (Operation):
    A. Insert a tuple into the parent table
    B. Delete a tuple from the child table
    C. Delete a tuple from the parent table
    D. Insert a tuple into the child table List II (Constraint Violation):
    1. May violate referential integrity
    2. Cannot violate referential integrity Options:
    Free preview ends here

    Login to view the complete short notes

    Creating an account is free. You get the rest of this chapter, step-by-step solutions, and a study plan built around the topics you are actually weak at.

    Explore complete test series, official past papers, and chapter-wise study tools.

    Why MastersUp

    Personalised first. High quality throughout.

    Most platforms hand everyone the same content. Here the content moves with your performance, topic by topic.

    Built around you, not around a syllabus PDF

    Every answer you give moves your topic-level intelligence rate. The next question, the next revision card and tomorrow's plan all change with it.

    Revision that hits your weak spots

    We only revise topics you have actually attempted and are still below the safe bar on — never the same chapter on repeat.

    Questions calibrated to the real exam

    Each question carries a measured toughness. You are served a rung above your current level, so practice keeps stretching you.

    Notes written for recall, not for volume

    Full lesson cards for first study, curated short-note cards for the last mile — with derivations, traps and exam patterns marked.

    One place for everything

    Notes, chapter practice, previous-year questions, test series and full-length papers — all feeding one picture of your preparation.

    Honest progress

    No vanity streaks. Progress here means chapters mastered and accuracy that held up on harder questions.

    Unlock the whole course

    Full notes and short notes, the complete question bank with worked solutions, mock tests, full-length papers, and an adaptive plan that rebuilds itself as you improve.

    Er Model, Keys and Integrity Constraints Short Notes for GATE DA

    Er Model, Keys and Integrity Constraints short notes for GATE DA: 2 study cards covering concepts, formulas, shortcuts and exam traps, plus solved practice questions.

    Summary: Mapping Rules Cheat Sheet

    Summary: Mapping Rules Cheat Sheet

    Entity / Relationship Type Mapping Rule
    Strong EntityRelation with same name. PK becomes PK.
    Weak EntityRelation. Owner PK becomes FK. Owner PK + Discriminator = PK.
    1:N RelationshipOwner PK becomes FK in the N-side relation.
    M:N RelationshipNew relation. PK is union of both entity PKs.
    1:1 RelationshipOne PK becomes FK in the other relation. Place in the totally participating side.
    Multivalued AttrNew relation. Entity PK + Attribute. PK is both.
    n-ary RelationshipNew relation. PK is union of all participating entity PKs.

    Quick Recall: Keys, NULLs, and FKs

    Final Cheat Sheet

    NULL Logic

    • NULL = NULL is Unknown (not True).
    • Use IS NULL to check for NULLs.

    Key Constraints

    • Primary Key: Must be UNIQUE and NOT NULL.
    • Unique Key: Must be UNIQUE. Allows NULLs (multiple NULLs permitted in standard relational model).

    Referential Integrity (Foreign Keys)

    • FK value must exist in Parent PK OR be NULL.
    • Safe Operations (Never Violate): Insert Parent, Delete Child, Update non-keys.
    • Risky Operations (Can Violate): Insert Child (if FK invalid), Delete Parent (if referenced).

    Er Model, Keys and Integrity Constraints: Solved Questions with Step-by-Step Explanations (10 Problems)

    Question 1 · Database Management and Warehousing MCQ

    Consider a parent table P and a child table C with a foreign key referencing P. Which of the following statements correctly describes an operation that will NEVER violate the referential integrity constraint?

    1. A.

      Deleting a tuple from P that is referenced by C.

    2. B.

      Inserting a tuple into C with a foreign key value not present in P.

    3. C.

      Inserting a tuple into P with a primary key value not referenced by C.

    4. D.

      Updating the primary key of a tuple in P that is referenced by C.

    Correct Answer:

    C

    Step-by-Step Solution

    Key idea: Referential integrity restricts the child table on insert/update and the parent table on delete/update. It does not restrict inserting into the parent.

    Step 1: Analyze the operations based on the violation checklist.

    Step 2: Deleting from P (referenced) -> Violates (orphans child).

    Step 3: Inserting into C (invalid FK) -> Violates (points to non-existent parent).

    Step 4: Inserting into P -> Safe. Adding a new parent does not break any existing child links.

    Step 5: Updating PK in P (referenced) -> Violates (orphans child).

    Answer: Inserting a tuple into P with a primary key value not referenced by C.

    Question 2 · Database Management and Warehousing MCQ
    Consider two relations with primary key , and with foreign key referencing in . Which of the following operations is IMPOSSIBLE to violate any integrity constraint?
    1. A.

      Inserting a tuple into with (not present in )

    2. B.

      Updating a non-key attribute in

    3. C.

      Deleting a tuple from that is referenced by

    4. D.

      Updating the primary key in to a value not referenced by

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: This is a boundary case question asking which operation can never violate constraints, recognizable because it asks for an operation that is "impossible" to violate constraints.

    The key is to identify operations that don't affect any constraint conditions. Updating a non-key attribute doesn't change any primary key or foreign key values, so it cannot violate any integrity constraint.

    Step 1: Analyze each option.

    A. Insert into S with E = 999 (not in R):

    • Foreign key E must match a value in R.A or be NULL
    • 999 is not in R.A and is not NULL
    • VIOLATES referential integrity

    B. Update non-key attribute B in R:

    • Modifying B doesn't change the primary key A
    • Doesn't affect any foreign key references
    • CANNOT violate any constraint

    C. Delete tuple from R referenced by S:

    • If S has tuples with E matching the deleted A value, they become orphaned
    • VIOLATES referential integrity

    D. Update PK A in R to value not referenced by S:

    • Even if the new value is not referenced, the old value might be
    • If any S tuple references the old A value, it becomes orphaned
    • MAY violate referential integrity

    Step 2: Identify the operation that cannot violate: Option B

    Answer: Updating a non-key attribute B in R (Option B)

    Question 3 · Database Management and Warehousing MCQ
    Consider a parent table with primary key , and a child table with foreign key referencing . Which of the following states is IMPOSSIBLE in a valid database satisfying referential integrity?
    1. A.

      is NULL and the corresponding tuple in has no matching tuple in

    2. B.

      has a value that exactly matches a value in

    3. C.

      has a non-NULL value that does not match any value in

    4. D.

      A tuple in is deleted without affecting any tuples in

    Correct Answer:

    C

    Step-by-Step Solution

    Key idea: This is a boundary case question asking for an impossible state, recognizable because it tests the absolute limits of referential integrity rules.

    Step 1: Recall the core rule of referential integrity. A foreign key must either exactly match a candidate key in the parent table OR be entirely NULL.

    Step 2: Evaluate each option against this rule.

    • Option A: is NULL. The rule explicitly allows NULL foreign keys, regardless of whether a matching parent exists. This is POSSIBLE.
    • Option B: matches . This is the standard valid state. This is POSSIBLE.
    • Option C: is non-NULL and does not match any . This directly violates the core rule. A non-NULL foreign key MUST match a parent. This is IMPOSSIBLE in a valid database.
    • Option D: Deleting a tuple in . This is a safe operation and does not affect . This is POSSIBLE.

    Answer: has a non-NULL value that does not match any value in (Option C)

    Question 4 · Database Management and Warehousing MCQ
    Consider a parent table and a child table with a foreign key referencing . Which of the following scenarios is IMPOSSIBLE in a database strictly enforcing referential integrity?
    1. A.

      The child table contains a tuple with a NULL foreign key, and the parent table is completely empty.

    2. B.

      The parent table contains a tuple, and the child table contains multiple tuples referencing it.

    3. C.

      The child table contains a tuple with a non-NULL foreign key, but the parent table is completely empty.

    4. D.

      A tuple is deleted from the child table, leaving the parent table unchanged.

    Correct Answer:

    C

    Step-by-Step Solution

    Key idea: This is a boundary case question asking for an impossible state, recognizable because it tests the absolute limits of referential integrity rules.

    Step 1: Recall the core rule of referential integrity. A foreign key must either exactly match a candidate key in the parent table OR be entirely NULL.

    Step 2: Evaluate each option against this rule.

    • Option A: Child has NULL FK, parent is empty. The rule explicitly allows NULL foreign keys, regardless of whether a matching parent exists. This is POSSIBLE.
    • Option B: Parent has a tuple, child has multiple referencing it. This is the standard valid state for a one-to-many relationship. This is POSSIBLE.
    • Option C: Child has non-NULL FK, parent is empty. A non-NULL foreign key MUST match a parent primary key. If the parent is empty, no match exists. This directly violates the core rule. This is IMPOSSIBLE.
    • Option D: Tuple deleted from child, parent unchanged. Deleting a child is a safe operation and does not affect the parent. This is POSSIBLE.

    Answer: The child table contains a tuple with a non-NULL foreign key, but the parent table is completely empty. (Option C)

    Question 5 · Database Management and Warehousing MSQ

    In a relational database with properly enforced integrity constraints, consider the following scenarios:

    • Scenario A: A child table has a tuple with a NULL value in the foreign key column
    • Scenario B: A parent table has a tuple deleted while a child table references it (without CASCADE)
    • Scenario C: A child table has a tuple with a foreign key value that matches a parent's primary key
    • Scenario D: A child table has a tuple with a foreign key value that does not match any parent's primary key and is not NULL

    Which of these scenarios is IMPOSSIBLE in a database with proper referential integrity?

    1. A.

      Scenario A

    2. B.

      Scenario B

    3. C.

      Scenario C

    4. D.

      Scenario D

    Correct Answer:

    ["B","D"]

    Step-by-Step Solution

    Key idea: This is a comparison question testing which scenarios violate referential integrity and are therefore impossible.

    Step 1: Recall the referential integrity rule. A foreign key value must either match a candidate key value in the parent table or be NULL.

    Step 2: Evaluate each scenario:

    Scenario A: Child tuple with NULL FK

    • NULL FK is allowed (indicates optional relationship)
    • This scenario is POSSIBLE ✓

    Scenario B: Parent tuple deleted while referenced by child (no CASCADE)

    • This would create an orphaned child tuple
    • Violates referential integrity
    • This scenario is IMPOSSIBLE ✗

    Scenario C: Child tuple with FK matching parent PK

    • This satisfies referential integrity
    • This scenario is POSSIBLE ✓

    Scenario D: Child tuple with invalid FK (not matching parent PK and not NULL)

    • This violates referential integrity
    • The FK must match a parent PK or be NULL
    • This scenario is IMPOSSIBLE ✗

    Step 3: Identify impossible scenarios:

    • Scenario B: Impossible (would violate referential integrity)
    • Scenario D: Impossible (violates referential integrity)

    Answer: B, D (Scenarios B and D are impossible)

    Question 6 · Database Management and Warehousing NAT

    Consider a parent table with primary key containing tuples with values . A child table has a foreign key referencing and currently contains tuples: .

    Evaluate the following six operations:

    1. Insert into
    2. Delete from
    3. Insert into
    4. Delete from
    5. Update : change from $10$ to $50$
    6. Update : change from $30$ to $60$

    How many of these operations will violate referential integrity constraints?

    Correct Answer:

    4.00

    Step-by-Step Solution

    Key idea: This is a constraint violation counting question requiring systematic evaluation of each operation against referential integrity rules.

    Step 1: Recall referential integrity rules:

    • Child table: Cannot INSERT/UPDATE if FK is not NULL and doesn't exist in Parent PK
    • Parent table: Cannot DELETE/UPDATE PK if referenced by Child

    Step 2: Evaluate each operation:

    Operation 1: Insert (40, 'd') into C

    • FK = 40, which is not in P's PK {10, 20, 30}
    • VIOLATION ✗

    Operation 2: Delete (20, 200) from P

    • P has PK = 20, which is referenced by C (tuple (20, 'b'))
    • VIOLATION ✗

    Operation 3: Insert (40, 400) into P

    • Adding new PK to parent doesn't affect existing child tuples
    • NO VIOLATION ✓

    Operation 4: Delete (10, 'a') from C

    • Removing child tuple doesn't affect parent
    • NO VIOLATION ✓

    Operation 5: Update C: change FK from 10 to 50

    • New FK = 50, which is not in P's PK {10, 20, 30}
    • VIOLATION ✗

    Operation 6: Update P: change PK from 30 to 60

    • P has PK = 30, which is referenced by C (tuple (30, 'c'))
    • VIOLATION ✗

    Step 3: Count violations: Operations 1, 2, 5, 6 violate → 4 violations

    Answer: 4.00

    Question 7 · Database Management and Warehousing MCQ

    In the standard ER-to-relational mapping rules, some relationships require the creation of a brand new relation, while others do not. If an ER model contains exactly one 1:N relationship and exactly one M:N relationship, what is the minimum number of new relations that must be created specifically for these relationships?

    1. A.

      0

    2. B.

      1

    3. C.

      2

    4. D.

      3

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: Only M:N relationships require a new relation; 1:N relationships merge into the N-side.

    Step 1: Check the 1:N relationship. The rule is to add the 1-side PK as a FK in the N-side relation. No new relation is created.

    Step 2: Check the M:N relationship. The rule is to create a brand new relation with a composite PK. This requires 1 new relation.

    Step 3: Add the new relations: 0 (from 1:N) + 1 (from M:N) = 1 new relation.

    Answer: 1

    Question 8 · Database Management and Warehousing MCQ

    An ER model contains a 1:N relationship with 2 descriptive attributes and an M:N relationship with 1 descriptive attribute. What is the minimum number of new relations created specifically to accommodate these relationships and their descriptive attributes?

    1. A.

      0

    2. B.

      1

    3. C.

      2

    4. D.

      3

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: 1:N relationships do not create new relations, while M:N relationships always create exactly one new relation.

    Step 1: Analyze the 1:N relationship. The rule states that no new relation is created; descriptive attributes are added to the 'N' side relation. (0 new relations)

    Step 2: Analyze the M:N relationship. The rule states that a brand new relation is created, which will include the descriptive attributes. (1 new relation)

    Step 3: Sum the new relations: 0 + 1 = 1.

    Answer: 1

    Question 9 · Database Management and Warehousing MCQ

    A child table has a composite foreign key consisting of 3 columns referencing a parent table's primary key. What is the minimum number of columns in this foreign key that must be NULL to satisfy the referential integrity constraint if the relationship is not applicable for a specific tuple?

    1. A.

      0

    2. B.

      1

    3. C.

      2

    4. D.

      3

    Correct Answer:

    D

    Step-by-Step Solution

    Key idea: Standard exam logic for composite foreign keys assumes an all-or-nothing rule for NULLs.

    Step 1: Recall the rule for composite foreign keys when a relationship is not applicable.

    Step 2: The standard relational rule states that if the FK consists of multiple columns, the entire combination must either match a parent candidate key, or all columns in the FK must be NULL.

    Step 3: Since the FK has 3 columns, all 3 must be NULL to satisfy the constraint without matching a parent.

    Answer: 3

    Question 10 · Database Management and Warehousing MCQ
    Match the following operations with their ability to violate referential integrity constraints: List I (Operation):
    A. Insert a tuple into the parent table
    B. Delete a tuple from the child table
    C. Delete a tuple from the parent table
    D. Insert a tuple into the child table List II (Constraint Violation):
    1. May violate referential integrity
    2. Cannot violate referential integrity Options:
    1. A.

      A-1, B-2, C-1, D-2

    2. B.

      A-2, B-1, C-2, D-1

    3. C.

      A-2, B-2, C-1, D-1

    4. D.

      A-1, B-1, C-2, D-2

    Correct Answer:

    C

    Step-by-Step Solution

    Key idea: This is a matching question about operation asymmetry in referential integrity, recognizable because it asks you to match operations with their violation potential.

    The key insight is that referential integrity constraints restrict operations asymmetrically: the child table is restricted when inserting/updating foreign keys, and the parent table is restricted when deleting/updating primary keys.

    Step 1: Analyze each operation.

    A. Insert into parent table:

    • Adding a new parent tuple doesn't affect existing child foreign keys
    • No child is pointing to this new parent yet
    • Cannot violate → 2

    B. Delete from child table:

    • Removing a child tuple removes a reference, not creates an invalid one
    • No orphaned references are created
    • Cannot violate → 2

    C. Delete from parent table:

    • If a child tuple references this parent, deleting the parent orphans the child
    • May violate if the parent is referenced
    • May violate → 1

    D. Insert into child table:

    • If the foreign key value doesn't exist in the parent, it violates the constraint
    • May violate if FK is invalid
    • May violate → 1

    Step 2: Match: A-2, B-2, C-1, D-1

    Answer: Option C

    More short notes in this unit