
56 PUZZLE 14 TELEPHONE
PUZZLE
14 TELEPHONE
Suppose you are trying to set up an office telephone directory with your
new database publishing system, and you have the following tables:
CREATE TABLE Personnel
(emp_id INTEGER PRIMARY KEY,
first_name CHAR(20) NOT NULL,
last_name CHAR(20) NOT NULL);
CREATE TABLE Phones
(emp_id INTEGER NOT NULL,
phone_type CHAR(3) NOT NULL
CHECK (phone_type IN ('hom', 'fax')),
phone_nbr CHAR(12) NOT NULL,
PRIMARY KEY (emp_id, phone_type),
FOREIGN KEY emp_id REFERENCES Personnel(emp_id));
The codes 'hom' and 'fax' indicate whether the number is the
employee’s home phone number or a fax number. You want to print ...