Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

--Q1

--a. Create EMPLOYEE table with the most appropriate/economic field/column constraints & types.
All fields are mandatory except Note field.

CREATE TABLE EMPLOYEE(

EmpNo int primary key,

EmpName VARCHAR(255) NOT NULL,

BirthDay DATE NOT NULL,

DeptNo INT NOT NULL,

MgrNo INT NOT NULL,

StartDate DATE NOT NULL,

Salary MONEY NOT NULL,

Level INT CHECK (Level BETWEEN 1 AND 7) NOT NULL,

Status INT CHECK (Status IN (0, 1, 2)) NOT NULL,

Note TEXT,

--b. Create SKILL table with the most appropriate/economic field/column constraints & types, all
fields are mandatory except Note field.

CREATE TABLE SKILL (

SkillNo INT IDENTITY(1,1) PRIMARY KEY,

SkillName VARCHAR(255) NOT NULL,

Note TEXT,

);

--c Create DEPARTMENT table with the most appropriate/economic field/column constraints &
types, all fields are mandatory except Note field.

CREATE TABLE DEPARTMENT (


DeptNo INT IDENTITY(1,1) PRIMARY KEY,

DeptName VARCHAR(255) NOT NULL,

Note TEXT

);

--d Create EMP_SKILL table with the most appropriate/economic field/column constraints & types,
all fields are mandatory except Description field.

CREATE TABLE EMP_SKILL (

SkillNo INT,

EmpNo INT,

SkillLevel INT CHECK (SkillLevel BETWEEN 1 AND 3) NOT NULL,

RegDate DATE NOT NULL,

Description TEXT,

PRIMARY KEY (SkillNo, EmpNo),

FOREIGN KEY (SkillNo) REFERENCES SKILL(SkillNo),

FOREIGN KEY (EmpNo) REFERENCES EMPLOYEE(EmpNo)

);

You might also like