Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
68 views4 pages

SQL Table Creation & Data Insertion

The document provides the schema and sample data to create 7 tables (employee, department, dept_locations, project, works_on, dependent) and insert data into these tables. The tables store information about employees, departments, projects employees work on, and employee dependents. SQL commands are needed to create the tables and insert the sample data. The results should be copied from the Oracle SQLPlus result window.

Uploaded by

luxurious devil
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)
68 views4 pages

SQL Table Creation & Data Insertion

The document provides the schema and sample data to create 7 tables (employee, department, dept_locations, project, works_on, dependent) and insert data into these tables. The tables store information about employees, departments, projects employees work on, and employee dependents. SQL commands are needed to create the tables and insert the sample data. The results should be copied from the Oracle SQLPlus result window.

Uploaded by

luxurious devil
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/ 4

There are two tasks in this assignment: A) create tables, and B) insert data,.

For each task, you need to


write SQL command and run it in Oracle SQLPlus Worksheet. What you need to submit are:
1. the SQL command;
2. the results copy and paste from Oracle SQLPlus result window.

A. Create Tables

The logical schema is shown as below:

Table Name: employee

Attribute Data Type Primary Foreign Constraint


First Name VARCHAR(15) NOT NULL
Mid Name CHAR
Last Name VARCHAR(15) NOT NULL
SSN Number CHAR(9)  NOT NULL
Birthday DATE
Address VARCHAR(50)

1
Sex CHAR Sex IN ('M',
'F', 'm', 'f')
Salary DECIMAL(10,2) DEFAULT
'800'
Supervisor SSN CHAR(9) employee (SSN)
Department Number INT

Table Name: department

Attribute Data Type Primary Foreign Constraint


Department Name VARCHAR(15) UNIQUE NOT NULL
Department Number INT  NOT NULL
Manager SSN CHAR(9) Employee (SSN) NOT NULL
Manage Start Date DATE

Table Name: dept_locations

Attribute Data Type Primary Foreign Constraint


Department Number INT  Department (DepNo) NOT NULL
Department Location VARCHAR(15)  NOT NULL

Table Name: project

Attribute Data Type Primary Foreign Constraint


Project Name VARCHAR(15) UNIQUE NOT NULL
Project Number INT  NOT NULL
Project Location VARCHAR(15)
Department Number INT Department (DepNo)

Table Name: works_on

Attribute Data Type Primary Foreign Constraint


Employee SSN CHAR(9)  Employee (SSN) NOT NULL
Project Number INT  Project (PNumber) NOT NULL
Hours DECIMAL(3, 1) NOT NULL

Table Name: dependent

Attribute Data Type Primary Foreign Constraint


Employee SSN CHAR(9)  Employee (SSN) NOT NULL
Dependent Name VARCHAR(15)  NOT NULL

2
Sex CHAR Sex IN ('M',
'F', 'm', 'f')
Birthday DATE
Relationship VARCHAR(8)

B. Insert Data
Table Name: Employee

Mini
FName LName SSN BDate Address Sex Salary SuperSSN DepNo
t
Doug E Gilbert 554433221 09-JUN-60 11 S 59 E, Salt Lake City, UT M 80000 NULL 3
Joyce PAN 543216789 07-FEB-78 35 S 18 E, Salt Lake City, UT F 70000 NULL 2
Frankin T Wong 333445555 08-DEC-45 638 Voss, Houston, TX M 40000 554433221 5
Jennifer S Wallace 987654321 20-JUN-31 291 Berry, Bellaire, TX F 43000 554433221 4
John B Smith 123456789 09-JAN-55 731 Fondren, Houston, TX M 30000 333445555 5
Ramesh K Narayan 666884444 15-SEP-52 975 Fire Oak, Humble, TX M 38000 333445555 5
Joyce A English 453453453 31-JUL-62 5631 Rice, Houston, TX F 25000 333445555 5
James E Borg 888665555 10-NOV-27 450 Stone, Houston, TX M 55000 543216789 1
Alicia J Zelaya 999887777 19-JUL-58 3321 Castle, Spring, TX F 25000 987654321 4
Ahmad V Jabbar 987987987 29-MAR-59 980 Dallas, Houston, TX M 25000 987654321 4

Table Name: Department

DName DepNo MgrSSN MgrDate


Manufacture 1 888665555 19-JUN-71
Administration 2 543216789 04-JAL-99
Headquarter 3 554433221 22-SEP-55
Finance 4 987654321 01-JAN-85
Research 5 333445555 22-MAY-78

Table Name: Dept_Locations

DepNo DLocation
1 Houston
1 Chicago
2 New York
2 San Francisco
3 Salt Lake City
4 Stafford
4 Bellaire
5 Sugarland
5 Houston

Table Name: Project

PName PNumber Plocation DepNo


ProjectA 3388 Houston 1

3
ProjectB 1945 Salt Lake City 3
ProjectC 6688 Houston 5
ProjectD 24 Bellaire 4
ProjectE 77 Sugarland 5
ProjectF 1 Salt Lake City 3
ProjectG 12 New York 2
ProjectH 34 Stafford 4
ProjectI 43 Chicago 1
ProjectJ 22 San Francisco 2

Table Name: Works_On

ESSN PNo Hours


123456789 3388 32.5
123456789 1945 7.5
666884444 3388 40.0
453453453 77 20.0
453453453 22 20.0
333445555 77 10.0
333445555 6688 10.0
333445555 43 35.0
333445555 22 28.5
999887777 1 11.5
999887777 12 13.0
543216789 22 17.0
554433221 1945 21.5

Table Name: Dependent

ESSN Dependent_Name Sex BDate Relationship


333445555 Alice F 05-APR-76 Daughter
333445555 Theodore M 25-OCT-73 Son
333445555 Joy F 03-MAY-48 Spouse
987654321 Abner M 29-FEB-32 Spouse
123456789 Michael M 01-JAN-78 Son
123456789 Alice F 31-DEC-78 Daughter
123456789 Elizabeth F 05-MAY-57 Spouse

You might also like