ITPEC FE Morning April 2019 Question 27
In an SQL statement, which of the following is a constraint that is specified with FOREIGN KEY and REFERENCES?
Explanation
Referential constraint — FOREIGN KEY with REFERENCES ties a column to the key of another table.
A declaration such as FOREIGN KEY (DNO) REFERENCES DEPT (DNO) says that every non-null DNO in this table must exist as a DNO in DEPT. The DBMS then rejects an insert or update that names a department that does not exist, and a delete of a department that rows still refer to, unless a rule such as ON DELETE CASCADE says otherwise. This keeps referential integrity between the two tables.
Answer (d)
Why not others:
- •(a) Assertion — a general condition over the database, declared with
CREATE ASSERTION, not with FOREIGN KEY - •(b) Check constraint — a condition on the values of a row within one table, such as
CHECK (Salary > 0) - •(c) Key constraint —
PRIMARY KEYorUNIQUE, which makes values unique within one table
Key rule: Uniqueness within a table is a key constraint, a condition on values is a check constraint, and a link between tables is a referential constraint.
Databases · AI-written, may contain errors
This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.