Skip to content
Official PYQ · 2014

GATE CS 2014 Set 1 Q22 — Tuple Calculus and SQL

Explain with AI

Given the following statements: 

S1: A foreign key declaration can always be replaced by an equivalent check  assertion in SQL. 

S2: Given the table R(a,b,c)R(a,b,c) where aa and bb together form the primary key, the following is a valid table definition. 

CREATE TABLE S ( 
     a INTEGER, 
     d INTEGER, 
     e INTEGER, 
     PRIMARY KEY (d), 
     FOREIGN KEY (a) references R)

Which one of the following statements is CORRECT?

Choose one option
View worked solution

Answer: D

To determine the correctness of the statements, let's analyze them one by one:

Statement S1: FALSE

  • Referential Actions: A foreign key constraint does not just prevent invalid data entry; it also defines active referential behaviors such as ON DELETE CASCADE, ON UPDATE CASCADE, or ON DELETE SET NULL. A CHECK constraint or general assertion cannot perform these cascading updates or deletes.
  • Triggering Events: A CHECK constraint on a table is only evaluated when rows in that specific table are inserted or updated. It is not triggered when rows in the referenced table are deleted or modified. Therefore, it cannot maintain referential integrity when the referenced table changes.

Statement S2: FALSE

  • In relational databases, a foreign key must reference either the primary key or a unique key of the referenced table.
  • For table R(a,b,c)R(a, b, c), the primary key is the composite key (a,b)(a, b). Column aa alone is neither a primary key nor a unique key of RR.
  • The table definition for SS attempts to declare FOREIGN KEY (a) references R. Since aa is only a part of the primary key of RR, this is invalid in SQL.

Since both statements S1 and S2 are FALSE, the correct option is D.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Tuple Calculus and SQL questions