Project 2

Read Complete Research Material



Project 2

Task Number 1

CREATE Customer

(

CustomerID AUTOINCREMENT(1,1) NOT NULL,

FirstName varchar(20),

LastName varchar(20) NOT NULL,

CustomerAddress VARCHAR (20) Not Null, CustomerPhone INT Not Null,

GenderID Integer REFERENCES Genders(GenderID),

CONSTRAINT PK_Customer PRIMARY KEY(PersonID)

);

Task Number 2

SQL Query

CREATE TABLE Department (dept_id INT NOT NULL,

dept_name VARCHAR(256), PRIMARY KEY (dept_id)) ENGINE=INNODB;

Inserting Data

INSERT INTO Department VALUES (1, "Sales");

INSERT INTO Employee VALUES (101, "Ethan", 2)

INSERT INTO Employee VALUES (101, "Ethan", 2);

ERROR 1452 (23000): Cannot ADD OR UPDATE a child row: a FOREIGN KEY constraint fails (`test`.`employee`, CONSTRAINT `employee_ibfk_1` FOREIGN KEY (`dept_id`) REFERENCES `department` (`dept_id`) ON DELETE CASCADE)

In the above scenario the referential integrity will ...
Related Ads