Assume the following three are true. (1) These two tables already exist in a dat
ID: 3735942 • Letter: A
Question
Assume the following three are true.
(1) These two tables already exist in a database with data shown above.
(2) EmpID and Dname are the primary key of Employee and Department, respectively.
(3) These two tables are not related, that is, there is no foreign key constraint defined. Because lacking of foreign key constraint, an employee like E012 can have a dept value 'HR', which does not exist in Department. If the constraint is defined, every Dept value in Employee must refer to one of Dname values in Department.
If we want to keep all data without modifying or removing them out of these two tables, but we no longer allow the Dept value of an employee to refer to a non-existing Dname value of Department, we need to add a foreign key constraint in one of these two tables to implement their relationship.
Write an ALTER TABLE statements to implement the above foreign key constraint. Pay attention to (1) determine the right table to contain the constraint, and (2) choose either 'WITH CHECK' or ' WITH NOCHECK' to include in the statement. Selection of this option is critical because of the underscored requirement described in the paragraph above.
Employee Department EmpID Dept Gender E003 E012 HR F E354 Dname Office R&D; Sales ales F K-71 M-22Explanation / Answer
ALTER TABLE Employee WITH NOCHECK
ADD FOREIGN KEY (Dept) REFERENCES Department(Dname);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.