Question:
•Create a Referential Integrity constraint between the valid_phone_numbers table and the L_employees table. (T?
alvina b
2013-08-14 17:41:05 UTC
•Create a Referential Integrity constraint between the valid_phone_numbers table and the L_employees table. (This validates the phone_number value whenever a new row is added to the L_employees table.)
•Add one more value to this table: 4707.
•Create a new table, valid_phone_numbers, containing the phone numbers for all the employees. (Get this list of valid values from the phone_number column of the L_employees table.)
Three answers:
Todd
2013-08-14 21:01:00 UTC
The ALTER TABLE command can differ between RDBMSs, but this works in most...



-- first one

ALTER TABLE L_employees

ADD FOREIGN KEY (phone_number)

REFERENCES valid_phone_numbers (phone_number);

-- also

ALTER TABLE Orders

ADD CONSTRAINT fk_valid_phone

FOREIGN KEY (phone_number)

REFERENCES valid_phone_numbers (phone_number);



-- second one

INSERT INTO valid_phone_numbers (phone_number) VALUES (4707);



-- last one, if valid_phone_numbers already exists, prefix a DROP TABLE command

SELECT DISTINCT phone_number INTO valid_phone_numbers FROM L_employees;

-- add a primary key if you want

ALTER TABLE valid_phone_numbers ADD PRIMARY KEY (phone_number);
2017-01-20 13:09:28 UTC
1
2014-12-11 00:25:39 UTC
difficult factor. try searching on to google. just that might help!


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...