Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MySQL Assume the following three are true. (1) These two tables already exist in a database with data shown above. (2) EmpID and Dname are

MySQL

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.

Use 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.

image text in transcribed

Employee Department EmpID Dept Gender Dname Office R&D K-71 Sales M-22 Sales F E012 HR E354

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

More Books

Students also viewed these Databases questions

Question

Are all managers change agents?

Answered: 1 week ago