Question: CREATE TABLE STUDENT_UNITCODE ( StudentId VARCHAR(7) NOT NULL, UnitCode VARCHAR(7) NOT NULL, UnitName VARCHAR(100), PRIMARY KEY (StudentId,UnitCode) ); INSERT INTO STUDENT_UNITCODE VALUES ('0023765','UG45783','Advance Database'), ('0023765','UG45832','Network

 CREATE TABLE STUDENT_UNITCODE ( StudentId VARCHAR(7) NOT NULL, UnitCode VARCHAR(7) NOT

CREATE TABLE STUDENT_UNITCODE

( StudentId VARCHAR(7) NOT NULL,

UnitCode VARCHAR(7) NOT NULL,

UnitName VARCHAR(100),

PRIMARY KEY (StudentId,UnitCode) );

INSERT INTO STUDENT_UNITCODE

VALUES ('0023765','UG45783','Advance Database'),

('0023765','UG45832','Network Systems'),

('0023765','UG45734','Multi-User Operating System'),

('0035643','UG45832','Network Systems'),

('0035643','UG45951','Project'),

('0061234','UG45783','Advance Database');

CREATE TABLE UNIT (

UnitCode VARCHAR(10) PRIMARY KEY,

UnitName VARCHAR(50) NOT NULL );

INSERT INTO UNIT (UnitCode, UnitName)

SELECT DISTINCT UnitCode, UnitName

FROM STUDENT_UNITCODE;

FOREIGN KEY REFERENCES Unit(UnitCode);

ALTER TABLE STUDENT_UNITCODE DROP column UnitName;

My Question: FOREIGN KEY has syntax error, I need to check the correct syntax.

Original Student_UnitCode Relations: New Relations: Student_UnitCode table and Unit table database refactoring Consider the following database relations, compare the original table and new tables, identify the steps to change the original table to the new tables: 1. name the refactoring pattern(s) you use for every step. Multiple patterns may apply. 2. list every step in the order of changing from the original table structure into new table structure. 3. schema update and data migration mechanics: include the operations in words and SQL scripts needed to achieve the desired objective for each step 4. Execute your SQL scripts in a database platform and show the result

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!