Given the following statements:
S1: A foreign key declaration can always be replaced by an equivalent check assertion in SQL.
S2: Given the table where and 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?
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, orON DELETE SET NULL. ACHECKconstraint or general assertion cannot perform these cascading updates or deletes. - Triggering Events: A
CHECKconstraint 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 , the primary key is the composite key . Column alone is neither a primary key nor a unique key of .
- The table definition for attempts to declare
FOREIGN KEY (a) references R. Since is only a part of the primary key of , 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.
