Question:

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?

Show Hint

Think about which side of the reference, the referenced primary key or the referencing foreign key, each operation changes.
Updated On: Jul 22, 2026
  • Inserting records into relation r
  • Deleting records from relation s
  • Deleting records from relation r
  • Inserting records into relation s
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is A, B

Solution and Explanation

Step 1: Recall what the foreign key constraint requires.
E is a foreign key in S that references A, the primary key of R. This means every value of E that appears in relation s must also appear as a value of A in relation r. The constraint is checked on the value stored in S, against the values available in R.

Step 2: Check option (A), inserting into r.
Inserting a new record into r only adds new possible values of A. It does not remove or change any value of A that existing rows in s might be referencing, so it can never break the constraint. This operation is always safe.

Step 3: Check option (B), deleting from s.
Deleting a record from s only removes a row, it does not add a new E value that would need to match an A value in r. Since removing rows from the referencing relation cannot create a broken reference, this operation is always safe.

Step 4: Check option (C), deleting from r.
If a deleted row from r had an A value that some row in s references through E, that reference would now point to nothing, breaking the constraint. So this operation can violate the constraint, depending on the data. It is not always safe.

Step 5: Check option (D), inserting into s.
A new row inserted into s might have an E value that does not exist as any A value in r. That would break the constraint immediately. So this operation can also violate the constraint. It is not always safe.

Final Answer:
Only inserting into r (A) and deleting from s (B) can never violate the foreign key constraint. \[ \boxed{\text{(A) and (B)}} \]
Was this answer helpful?
0
0

Top GATE DA Data Science and Artificial Intelligence Questions

View More Questions

Top GATE DA Database Management Systems Questions

View More Questions