0% found this document useful (0 votes)
195 views3 pages

Handout - 1

The document contains SQL statements that define tables and insert data to model an employee database including tables for employees, departments, department locations, projects, which employees work on which projects, and employee dependents. Employees have attributes like name, SSN, birthdate, salary, department, and manager. Departments have attributes like name, number, manager, and location. Projects have attributes like name, number, location, and department. Other tables define which employees work on projects, employee dependents, and the relationships between these tables.

Uploaded by

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

Handout - 1

The document contains SQL statements that define tables and insert data to model an employee database including tables for employees, departments, department locations, projects, which employees work on which projects, and employee dependents. Employees have attributes like name, SSN, birthdate, salary, department, and manager. Departments have attributes like name, number, manager, and location. Projects have attributes like name, number, location, and department. Other tables define which employees work on projects, employee dependents, and the relationships between these tables.

Uploaded by

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

CREATE TABLE EMPLOYEE (

Fname varchar(255) NOT NULL,


Minit varchar(255) NOT NULL,
Lname varchar(255) NOT NULL,
Ssn int NOT NULL,
Bdate date,
Address varchar(255),
Sex varchar(255),
Salary int NOT NULL,
Super_ssn varchar(255),
Dno int,
PRIMARY KEY (Ssn)
);

INSERT INTO EMPLOYEE (Fname,Minit,Lname,Ssn,Bdate,Address,Sex,Salary,Super_ssn,Dno)

VALUES('John','B','Smith',123456789,to_date('1965-01-09','YYYY-MM-DD'),'731
Fondren,Houston,TX','M',30000,'333445555',5);

INSERT INTO EMPLOYEE (Fname,Minit,Lname,Ssn,Bdate,Address,Sex,Salary,Super_ssn,Dno)

VALUES('Franklin','T','Wong',333445555,to_date('1955-12-08','YYYY-MM-DD'),'638
Voss,Houston,TX','M',40000,'888665555',5);

INSERT INTO EMPLOYEE (Fname,Minit,Lname,Ssn,Bdate,Address,Sex,Salary,Super_ssn,Dno)

VALUES('Alicia','J','Zelaya',999887777,to_date('1968-01-19','YYYY-MM-DD'),'3321
Castle,Spring,TX','F',25000,'987654321',4);

INSERT INTO EMPLOYEE (Fname,Minit,Lname,Ssn,Bdate,Address,Sex,Salary,Super_ssn,Dno)

VALUES('Jennifer','S','Wallace',987654321,to_date('1941-06-20','YYYY-MM-DD'),'291
Berry,Bellaire,TX','F',43000,'888665555',4);

INSERT INTO EMPLOYEE (Fname,Minit,Lname,Ssn,Bdate,Address,Sex,Salary,Super_ssn,Dno)

VALUES('Ramesh','K','Narayan',666884444,to_date('1962-09-15','YYYY-MM-DD'),'975
Fire Oak Humble,TX','M',38000,'333445555',5);

INSERT INTO EMPLOYEE (Fname,Minit,Lname,Ssn,Bdate,Address,Sex,Salary,Super_ssn,Dno)

VALUES('Joyce','A','English',453453453,to_date('1972-07-31','YYYY-MM-DD'),'5631
Rice,Houston,TX','F',25000,'333445555',5);

INSERT INTO EMPLOYEE (Fname,Minit,Lname,Ssn,Bdate,Address,Sex,Salary,Super_ssn,Dno)

VALUES('Ahmad','V','Jabbar',987987987,to_date('1969-03-29','YYYY-MM-DD'),'980
Dallas,Houston,TX','M',25000,'987654321',4);

INSERT INTO EMPLOYEE (Fname,Minit,Lname,Ssn,Bdate,Address,Sex,Salary,Super_ssn,Dno)

VALUES('James','E','Borg',888665555,to_date('1937-11-10','YYYY-MM-DD'),'450
Stone,Houston,TX','M',55000,'NULL',1);

CREATE TABLE DEPARTMENT (


Dname varchar(255) NOT NULL,
Dnumber int,
Mgr_ssn int,
Mgr_start_date date,
PRIMARY KEY (Dnumber),
FOREIGN KEY (Mgr_ssn) REFERENCES EMPLOYEE(Ssn)
);

INSERT INTO DEPARTMENT (Dname,Dnumber,Mgr_ssn,Mgr_start_date)


VALUES('Research',5,333445555,to_date('1988-05-22','YYYY-MM-DD'));
VALUES('Administration',4,987654321,to_date('1995-01-01','YYYY-MM-DD'));
VALUES('Headquarters',1,888665555,to_date('1981-06-19','YYYY-MM-DD'));

CREATE TABLE DEPT_LOCATIONS(


Dnumber int NOT NULL,
Dlocation varchar(255) NOT NULL PRIMARY KEY,
FOREIGN KEY (Dnumber) REFERENCES DEPARTMENT(Dnumber)
);

INSERT INTO DEPT_LOCATIONS (Dnumber,Dlocation)


VALUES(1,'Houston');
VALUES(4,'Stafford');
VALUES(5,'Bellaire');
VALUES(5,'Sugarland');
VALUES(5,'Houston');

CREATE TABLE PROJECT(


Pname varchar(255),
Pnumber int NOT NULL,
Plocation varchar(255),
Dnum int,
PRIMARY KEY (Pnumber),
FOREIGN KEY (Dnum) REFERENCES DEPARTMENT(Dnumber)
);

INSERT INTO PROJECT (Pname,Pnumber,Plocation,Dnum)


VALUES('ProductX',1,'Bellaire',5);
VALUES('ProductY',2,'Sugarland',5);
VALUES('ProductZ',3,'Houston',5);
VALUES('Computerization',10,'Stafford',4);
VALUES('Reorganization',20,'Houston',1);
VALUES('Newbenefits',30,'Stafford',4);

CREATE TABLE WORKS_ON (


Essn int NOT NULL,
Pno int,
Hours varchar(255),
FOREIGN KEY (Pno) REFERENCES PROJECT(Pnumber)
);

INSERT INTO WORKS_ON (Essn,Pno,Hours)


VALUES(123456789,1,'32.5');
VALUES(123456789,2,'7.5');
VALUES(666884444,3,'40.0');
VALUES(453453453,1,'20.0');
VALUES(453453453,2,'20.0');
VALUES(333445555,2,'10.0');
VALUES(333445555,3,'10.0');
VALUES(333445555,10,'10.0');
VALUES(333445555,20,'10.0');
VALUES(999887777,30,'30.0');
VALUES(999887777,10,'10.0');
VALUES(987987987,10,'35.0');
VALUES(987987987,30,'5.0');
VALUES(987654321,30,'20.0');
VALUES(987654321,20,'15.0');
VALUES(888665555,20,'NULL');

CREATE TABLE DEPENDENT (


Essn int NOT NULL,
Dependent_name varchar(255) NOT NULL,
Sex varchar(10),
Bdate date,
Relationship varchar(255),
PRIMARY KEY (Dependent_name),
FOREIGN KEY (Essn) REFERENCES EMPLOYEE(Ssn)
);

INSERT INTO DEPENDENT (Essn,Dependent_name,Sex,Bdate,Relationship)


VALUES(333445555,'Alice','F',to_date('1986-04-05','YYYY-MM-DD'),'Daughter');
VALUES(333445555,'Theodore','M',to_date('1983-10-25','YYYY-MM-DD'),'Son');
VALUES(333445555,'Joy','F',to_date('1958-05-03','YYYY-MM-DD'),'Spouse');
VALUES(987654321,'Abner','M',to_date('1942-02-28','YYYY-MM-DD'),'Spouse');
VALUES(123456789,'Michael','M',to_date('1942-02-28','YYYY-MM-DD'),'Son');
VALUES(123456789,'Alice','F',to_date('1988-12-30','YYYY-MM-DD'),'Daughter');
VALUES(123456789,'Elizabeth','F',to_date('1967-05-05','YYYY-MM-DD'),'Spouse');

You might also like