If the following SQL statements are executed:
CREATE TABLE make (makeid SMALLINT NOT NULL PRIMARY KEY,
make VARCHAR(25));
CREATE TABLE model (modelid SMALLINT,
model VARCHAR(25),
makeid SMALLINT,
CONSTRAINT const1 FOREIGN KEY (makeid)
REFERENCES make(makeid) ON DELETE RESTRICT);
And each table created is populated as follows:
MAKE
MAKEID MAKE
—— ——–
1 Ford
2 Chevrolet
3 Toyota
MODEL
MODELID MODEL MAKEID
——- ——- ——–
1 Mustang 1
2 Escort 1
3 Malibu 2
4 Camry 3
If the following SQL statement is executed:
DELETE FROM make WHERE makeid = 1
What is the total number of rows that will be deleted?
A.
0
B.
1
C.
2
D.
3
A
REFERENCES make(makeid) ON DELETE RESTRICT);
0
0
The delete rule of a referential constraint applies only when a row of the parent table is deleted. More precisely, the rule applies only when a row of the parent table is the object of a delete or propagated delete operation (defined below), and that row has dependents in the dependent table of the referential constraint. Consider an example where P is the parent table, D is the dependent table, and p is a parent row that is the object of a delete or propagated delete operation. The delete rule works as follows:
With RESTRICT or NO ACTION, an error occurs and no rows are deleted.
0
0