Adbms - Lab Sheet 1
Adbms - Lab Sheet 1
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.)
Employee
Department
Dept_location
Dnumber Dlocation
1 Texas
2 LA
3 Oakland
3 Texas
Project
Works_on
10011 1 32.5
10010 3 40.0
10032 2 10.0
10045 10 10.0
10099 10 NULL
10011 15 8.5
Dependent
Supervisor
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
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).