0% found this document useful (0 votes)
26 views7 pages

VL2023240506367 Ast03

The document contains the schema and sample data for tables in an employee database including the Employee, Department, Project, Dept_Locations, Works_On, and Dependent tables. It describes the attributes, data types, constraints, and sample data for each table. It also provides tasks involving subqueries, views, logical tables, and joins to query and relate data across the tables in the database.

Uploaded by

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

VL2023240506367 Ast03

The document contains the schema and sample data for tables in an employee database including the Employee, Department, Project, Dept_Locations, Works_On, and Dependent tables. It describes the attributes, data types, constraints, and sample data for each table. It also provides tasks involving subqueries, views, logical tables, and joins to query and relate data across the tables in the database.

Uploaded by

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

School of Computing Science and Engineering

B.Tech
Database Systems Lab

Lab assignment -3

Consider the following schema:


Table Name: Employee
Attribute Data Type
First Name VARCHAR(15)
Mid Name CHAR(2)
Last Name VARCHAR(15)
SSN Number CHAR(9)
Birthday DATE
Address VARCHAR(50)
Sex CHAR(1)
Salary NUMBER (7)
Supervisor SSN CHAR(9)
Department Number NUMBER (5)

Table Name: Department

Attribute Data Type


Department Name Varchar(15)
Department Number Number(5)
ManagerSSN CHAR(9)
ManageStartDate DATE

Table Name: Project

Attribute Data Type


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

Data For Department table

DName DepNo MgrSSN MgrStartDate


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

Data For Project

PName PNumber Plocation DepNo


ProjectA 3388 Houston 1
ProjectB 1945 Salt Lake City 3
ProjectC 6688 Houston 5
ProjectD 2423 Bellaire 4
ProjectE 7745 Sugarland 5
ProjectF 1566 Salt Lake City 3
ProjectG 1234 New York 2
ProjectH 3467 Stafford 4
ProjectI 4345 Chicago 1
ProjectJ 2212 San Francisco 2
The constraints used.

Table Name: Employee

Attribute Data Type Constraint


First Name Varchar (15) Not Null
Mid Name Char(2)
Last Name Varchar (15) Not Null
SSN Number Char (9) Primary Key
Birthday Date
Address Varchar (50)
Sex Char(1) Sex In (M,F,m,f)
Salary Number (7) Default 800
Supervisor SSN Char (9) Foreign Key Employee (SSN)
on delete set null
Department number Number(5) Foreign key to department
number of department table on
delete cascade

Table Name : Department

Attribute Data type Constraint


Department Name Varchar(15) Not Null
Department number INT(5) Primary key
Manager SSN Char (9) Foreign key-Employee (SSN)
on delete set null
Manage start date Date

Table Name : Dept_locations

Attribute Data type Constraint


Department Number Number(5) Department (dep no) onDelete
Cascade
Department Location Varchar (15)

Table Name: Project

Attribute Data type Constraint


Project Name Varchar2(15) Not Null
Project number Number(5) Primary key
Project Location Varchar2(50)
Department Number Number(5) Foreign Key –Department (dep
no ) on delete set null
Table Name: Works_On
The combination of Employee SSN and Project Number must be a Primary Key

Attribute Data type Constraint


Employee SSN Char (9) Foreign Key
Employee (SSN) on delete cascade
Project number INT(5) Foreign Key project ( Pnumber ) on
delete cascade
Hours Decimal (3,1) Not null

Name: Dependent
The combination of Employee SSN and Dependent Name must be a Primary Key.

Attribute Datatype Constraint


Employee Char (9) Foreign Key- Employee (SSN) on Delete
Cascade
Dependent Name Varchar(15)
Sex Char(1) Check Sex in (M,F,m,f)
Birthday Date
Relationship Varchar(8)

Data for table - Dept_Locations

Dep No D Location
1 Houston
1 Chicago
2 New York
2 San Francisco
3 Salt Lake City
4 Stafford
4 Bellaire
5 Sugarland
5 Houston
Data for Table - 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

Data for Table - 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 Alice F 31-Dec-78 Daughter
123456789 Elizabeth F 05-may-57 Spouse
PART-A (Sub Queries and View)
Aim: to understand the concept of Sub queries and logical tables in oracle

1. Find the employee who is getting highest salary in the department research
2. Find the employees who earn the same salary as the minimum salary for each
Department
3. Find the employee whose salary is greater than average salary of department 2
4. List out all the department names with their individual employees strength
5. Find out the department name having highest employee strength
6. List out all the departments and average salary drawn by their employees
7. Find maximum average salary for each department.
8. Create a view to display the employee details who is working in IT department.
9. Create a logical table to store employee details who is getting salary more than 10000.
10. Create a table to store the employees details based on the department no
PART-B (Joins)
Aim: To understand how to relate and access data from multiple tables.

1. Retrieve the names of all employees in department 5 who work more than 10 hours
per week on ProductX project.
2. List the names of all employees who have a dependent with the same first name as
themselves.
3. Find the names of all the employees who are directly supervised by ‘Franklin Wong’.
4. Retrieve the names of all who do not work on any project.
5. Find the names and addresses of all employees who work on atleast one project
located in Houston but whose department has no location in Houston.
6. List the names of all managers who have no dependents.
7. List the employee’s names and the department names if they happen to manage a
department.
8. For each project retrieve the project number, project name and the number of
employees who work on that project.
9. For each project, list the project name and the total hours per week (by all employees)
spent on that project.
10. Retrieve the names of the employees who have 2 or more dependents.

You might also like