Integrity Constraints · Database Management and Warehousing
2 questions · asked in 2 of 3 years (2024–2026)
MSQ 21-mark 1 · 2-mark 1
2024Questions per year2026
Questions 1–2 of 2
Consider two relations and defined on the relational schemas and , respectively. is the primary key of and is a foreign key of referencing in .
Which of the following operations will violate the foreign key constraint?
Which of the following operations will violate the foreign key constraint?
One or more options are correct.
Answer: (A), (B)
The foreign key rule says this: each value of in must match a value of that already exists in .
- Insert into : this only adds new valid primary-key values to . The references already in stay valid. No new invalid reference can appear this way. Never violates.
- Delete from : this only removes rows from the referencing side. It cannot create a dangling reference; it can only lower their number. Never violates.
- Delete from : this may remove an value that a row in still refers to through . That leaves a dangling foreign key. Can violate.
- Insert into : the value of the new row may not match any value that exists in . Can violate.
Answer: Inserting into r and deleting from s will NEVER violate the constraint.
- Insert into : this only adds new valid primary-key values to . The references already in stay valid. No new invalid reference can appear this way. Never violates.
- Delete from : this only removes rows from the referencing side. It cannot create a dangling reference; it can only lower their number. Never violates.
- Delete from : this may remove an value that a row in still refers to through . That leaves a dangling foreign key. Can violate.
- Insert into : the value of the new row may not match any value that exists in . Can violate.
Answer: Inserting into r and deleting from s will NEVER violate the constraint.
Consider the following two relations, named and , in a database:
Which of the following statements is/are correct?
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?
One or more options are correct.
Answer: (B), (C)
,
"aadhaar is a candidate key in Customer" is false. In Customer it is only a foreign key. The schema does not make it unique there. Only is the primary key.
"phone can be NULL in Customer" is true. For there is no NOT NULL or key constraint.
"aadhaar is a candidate key in Person" is true. It is declared as the primary key of Person, and every primary key is a candidate key by definition.
"aadhaar can be NULL in Person" is false. A primary key can never be NULL under the standard SQL constraint.
Answer: phone can be NULL in Customer; and aadhaar is a candidate key in Person.
"aadhaar is a candidate key in Customer" is false. In Customer it is only a foreign key. The schema does not make it unique there. Only is the primary key.
"phone can be NULL in Customer" is true. For there is no NOT NULL or key constraint.
"aadhaar is a candidate key in Person" is true. It is declared as the primary key of Person, and every primary key is a candidate key by definition.
"aadhaar can be NULL in Person" is false. A primary key can never be NULL under the standard SQL constraint.
Answer: phone can be NULL in Customer; and aadhaar is a candidate key in Person.
Keep practising