Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
42 views

Adbms - Lab Sheet 1

The document describes a database schema for an office management system with tables like Employee, Department, Project, etc. It provides sample data and tasks to retrieve data using subqueries and joins.

Uploaded by

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

Adbms - Lab Sheet 1

The document describes a database schema for an office management system with tables like Employee, Department, Project, etc. It provides sample data and tasks to retrieve data using subqueries and joins.

Uploaded by

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

26/11/2020 - ADBMS

ADBMS
Lab sheet 1

Part 1
1) Create a Database in SQL Server to save details about office activities.
DB: OfficeDB

2) Use OfficeDB and Create following table structures in SQL Server by adding suitable data
types, field sizes and Constraints.
(Identify the relevant constraints and give constraint names. Ex: primary key, foreign key
etc.)

3) Input data to the tables as below.

Employee

Fname Lname Emp_i DOB Salar Gender address Dep_no Designation


d y
Maria Smith 10011 1972-02-03 2000 F 231, Los 1 Manager
0 Angeles,
California
Soobin Choi 10012 1963-05-09 5000 M 112, San 2 Executive
0 Diego,
California
kai James 10024 1995-01-18 3000 M 143, 2 Manager
0 Oakland,
California
John Wang 10013 1991-06-21 1000 M 085, castle, 3 Cashier
0 Texas
Lisa Ash 10032 1991-08-09 1050 F 022, 3 Cashier
0 Houston,
Texas
Jennie Kim 10045 1980-11-13 4000 F 311, Texas 3 Manager
0 city, Texas

Department

Dep_name Dnumber Manager_id Manager_start_date


HQ 1 10011 2020-01-14
Admin 2 10024 2020-03-15
26/11/2020 - ADBMS

Production 3 10045 2020-03-24

Dept_location

Dnumber Dlocation
1 Texas
2 LA
3 Oakland
3 Texas

Project

Pr_name Pr_no Pr_location Dep_no


Pro_A 1 Beverly Hills 1
Pro_B 2 Houston 1
Pro_C 3 Los Angeles 1
Pro_D 15 San Francisco 2
Pro_E 10 Los Angeles 3
Pro_F 9 Houston 3

Works_on

Empid Pnumber hours

10011 1 32.5
10010 3 40.0
10032 2 10.0
10045 10 10.0
10099 10 NULL
10011 15 8.5

Dependent

Emp_id Dependent_name DOB Relationship

10012 Rose 1997-08-08 Daughter


10012 Billie 1995-07-02 Son
10013 Selena 1990-03-04 Spouse
10011 Jimin 1991-11-14 Son

Supervisor

SupervisorID Supervisorname Employeeid


7 Jeremy 10013
26/11/2020 - ADBMS

8 Anne 10032

Part 2
Using Sub queries find the outputs for the followings,

a) Display employee ID, first name and last name of all the employees who work in the
same department where employee who has the ID “10045” is working.

b) Display Emp id, first name and department no of all the employees who work in
departments located at ‘’Texas”.
c) Retrieve the names of the employees who do not have Dependents.

d) The departments that has two employees or more than two employees, display the
department number and number of the employees in that department who has a
salary more than 10,500.

e) Get the names of the employees who has more than one dependent.

Part 3

Using Suitable Joins find the outputs for the followings,

a) Retrieve the number of Employees in the ‘’Production’’ department.

b) Display the employee name, employee ID, dependent name and relationship of the
dependent with the employee, in one result set.

c) Combine and display the details from the tables Employee and dependent, but there
should not be any duplicate rows.

d) Display the Department name, Project location, Project name and Employee ID of
the Employees who works on projects all as one result set and sort the table
according to the Descending order of the Project location.
26/11/2020 - ADBMS

e) Display all the details of the Employee table and all the details of the Works_on
table together in one result set.

f) Display Employee name and the Designation of the employees who has a
supervisor along with the supervisor’s Details. (Every employee may not have a
supervisor).

You might also like