hw2ans

hw2ans - CS174a - HW2 - Answers 1. Cascade / Delete all...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CS174a - HW2 - Answers 1. Cascade / Delete all Restrict / Disallow Set null Set to a default 2. Consider the following example. It is natural to require that the did field of Works should be a foreign key, and refer to Dept. CREATE TABLE Works ( eid INTEGER NOT NULL , did INTEGER NOT NULL , pcttime INTEGER, PRIMARY KEY (eid, did), UNIQUE (eid), FOREIGN KEY (did) REFERENCES Dept ) When a user attempts to delete a Dept tuple, There are four options: Also delete all Works tuples that refer to it. Disallow the deletion of the Dept tuple if some Works tuple refers to it. For every Works tuple that refers to it, set the did field to the did of some (existing) default department. For every Works tuple that refers to it, set the did field to null. CREATE TABLE Emp ( eid INTEGER, ename CHAR(10), age INTEGER, salary REAL, PRIMARY KEY (eid) ) CREATE TABLE Works ( eid INTEGER, did INTEGER, pcttime INTEGER, PRIMARY KEY (eid, did), FOREIGN KEY (did) REFERENCES Dept, FOREIGN KEY (eid) REFERENCES Emp,
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

hw2ans - CS174a - HW2 - Answers 1. Cascade / Delete all...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online