Question
What is the refactoring pattern used for following? I am using a MySQL database. The tables are as follows. Employee(EmpId, Name, Phone, Address) Department(DID, EmpId,
What is the refactoring pattern used for following? I am using a MySQL database. The tables are as follows.
Employee(EmpId, Name, Phone, Address)
Department(DID, EmpId, DName)
Primary keys are EmpId in Employee. DID in Department.
Foreign keys are EmpId in Department.
1. What refactor pattern should be used to remove a primary key(EmpId) and introduce a new primary key(Name and Phone)?
2. What refactor pattern should be used to drop the foreign key in Department(EmpId) and how to add the new columns(Name and Phone) as foreign keys in the department table.?
Can I drop the column(EmpId) directly in Department table or I need to first drop the foreign key constraint on EmpId and then drop that column?
3. What refactor pattern and how to add new foreign constraints(Name, Phone) in Department table?
And lastly is any data migration required during these changes?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started