Consider the following two relations, named Customer and Person, in a database:
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?
Answer
(B), (C)
Explanation
Only the declared constraints restrict the columns.
- A fails: the primary key of
Customerisemail, andaadhaarthere is only a foreign key with no UNIQUE constraint. Several customer rows (say, one person with two email addresses) can share the sameaadhaar, so it is not a candidate key. - B holds:
phonehas no NOT NULL or key constraint, so it may be NULL. - C holds:
aadhaaris the primary key ofPerson, and a primary key is always a candidate key. - D fails: a primary key column can never be NULL.
Answer: B, C