0% found this document useful (0 votes)
28 views

Data

The document contains SQL statements that create tables to store data for a company database including tables for departments, employees, projects, and works on assignments. The tables are related through foreign keys and primary keys to link data between the tables such as employees belonging to departments and working on projects.

Uploaded by

Deepu
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Data

The document contains SQL statements that create tables to store data for a company database including tables for departments, employees, projects, and works on assignments. The tables are related through foreign keys and primary keys to link data between the tables such as employees belonging to departments and working on projects.

Uploaded by

Deepu
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

CREATE TABLE DEPARTMENT

(DNO VARCHAR2(20) PRIMARY KEY,


DNAME VARCHAR2(20),
MGRSTART DATE);

CREATE TABLE EMPLOYEE


(SSN VARCHAR2(20) PRIMARY KEY,
ENAME VARCHAR2(20),
LNAME VARCHAR2(20),
ADDRESS VARCHAR2(20),
SEX CHAR(1),
SALARY INTEGER,
SUPERSSN REFERENCES EMPLOYEE(SSN),
DNO REFERENCES DEPARTMENT(DNO));

ALTER TABLE DEPARTMENT


ADD MGRSSN REFERENCES EMPLOYEE(SSN);

CREATE TABLE PROJECT


(PNO INTEGER PRIMARY KEY,
PNAME VARCHAR2(20),
PLOCATION VARCHAR2(20),
DNO REFERENCES DEPARTMENT(DNO));

CREATE TABLE WORKS_ON


(HOURS NUMBER(2),
SSN REFERENCES EMPLOYEE(SSN),
PNO REFERENCES PROJECT(PNO),
PRIMARY KEY(SSN,PNO));

INSERT INTO EMPLOYEE(SSN,FNAME,LNAME,ADDRESS,SEX,SALARY) VALUES(

INSERT INTO DEPARTMENT VALUES(

INSERT INTO DLOCATION VALUES(


INSERT INTO PROJECT VALUES(
INSERT INTO WORKS_ON VALUES(

CREATE TABLE DLOCATION


(DLOC VARCHAR(20),
DNO REFERENCES DEPARTMENT(DNO),
PRIMARY KEY(DNO,DLOC));

You might also like