0% found this document useful (0 votes)
14 views2 pages

Create Table Department

The document outlines the SQL commands to create five tables: DEPARTMENT, EMPLOYEE, DLOCATION, PROJECT, and WORKS_ON, each with specified columns and data types. It establishes primary keys and foreign key relationships between the tables to ensure data integrity. Additionally, it includes an alteration to the DEPARTMENT table to add a manager's SSN as a foreign key referencing the EMPLOYEE table.

Uploaded by

Putta Swamy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

Create Table Department

The document outlines the SQL commands to create five tables: DEPARTMENT, EMPLOYEE, DLOCATION, PROJECT, and WORKS_ON, each with specified columns and data types. It establishes primary keys and foreign key relationships between the tables to ensure data integrity. Additionally, it includes an alteration to the DEPARTMENT table to add a manager's SSN as a foreign key referencing the EMPLOYEE table.

Uploaded by

Putta Swamy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

CREATE TABLE DEPARTMENT

(DNO int(20) PRIMARY KEY,

DNAME VARCHAR(20),

MGR_START_DATE DATE);

CREATE TABLE EMPLOYEE

(SSN int(20) PRIMARY KEY,

NAME VARCHAR(20),

ADDRESS VARCHAR(20),

SEX CHAR(1),

SALARY int(20),

DNO int(20),

FOREIGN KEY (DNO) REFERENCES DEPARTMENT (DNO));

CREATE TABLE DLOCATION

(DLOC VARCHAR(20),

DNO int(20),

FOREIGN KEY (DNO) REFERENCES DEPARTMENT(DNO),

PRIMARY KEY (DNO, DLOC));

CREATE TABLE PROJECT

(PNO int(10) PRIMARY KEY,

PNAME VARCHAR(20),

PLOCATION VARCHAR(20),

DNO int(20),

FOREIGN KEY (DNO) REFERENCES DEPARTMENT(DNO));


CREATE TABLE WORKS_ON

(HOURS int(10),

SSN int(20),

PNO int(20),

FOREIGN KEY (SSN) REFERENCES EMPLOYEE(SSN),

FOREIGN KEY (PNO) REFERENCES PROJECT(PNO),

PRIMARY KEY (SSN, PNO));

ALTER TABLE DEPARTMENT ADD MGR_SSN INT(10)

ALTER TABLE DEPARTMENT ADD FOREIGN KEY (MGR_SSN) REFERENCES EMPLOYEE(SSN);

You might also like