What data is in the employee table after the statement?

You have two tables:
CREATE TABLE department (
Department_ID int unsigned NOT NULL auto_increment PRIMARY KEY,
Department _Name varchar(12) NOT NULL
) ENGINE=InnoDB
CREATE TABLE employee (
Employee_Number int unsigned NOT NULL PRIMARY KEY,
Employee_Name varchar(10) NOT NULL,
Department_ID int unsigned DEFAULT NULL,
FOREIGN KEY (Department ID) REFERENCES Department (Department_ID)
ON UPDATE SET NULL ON DELETE CASCADE
) ENGINE= InnoDB
The tables have the data:
Department

You execute the statement:
REPLACE INTO department (Department_ID, Department_Name) VALUES (1, ‘Admin’);
What data is in the employee table after the statement?

You have two tables:
CREATE TABLE department (
Department_ID int unsigned NOT NULL auto_increment PRIMARY KEY,
Department _Name varchar(12) NOT NULL
) ENGINE=InnoDB
CREATE TABLE employee (
Employee_Number int unsigned NOT NULL PRIMARY KEY,
Employee_Name varchar(10) NOT NULL,
Department_ID int unsigned DEFAULT NULL,
FOREIGN KEY (Department ID) REFERENCES Department (Department_ID)
ON UPDATE SET NULL ON DELETE CASCADE
) ENGINE= InnoDB
The tables have the data:
Department

You execute the statement:
REPLACE INTO department (Department_ID, Department_Name) VALUES (1, ‘Admin’);
What data is in the employee table after the statement?

A.
Option A

B.
Option B

C.
Option C

D.
Option D



Leave a Reply 4

Your email address will not be published. Required fields are marked *


Vince

Vince

C. Option C

Jay

Jay

C

Another tricky one, the difference between INSERT and REPLACE is that REPLACE deletes the old row and inserts the new one in its place which makes the cascade delete take action and delete whats connected to it. Don’t be fooled by the Cascade null update, which takes no part in the REPLACE.

My Output:

Employee_Number, Employee_Name, Department_ID
‘3’, ‘Anna’, ‘2’