0% found this document useful (0 votes)
67 views8 pages

Final Term Lab Manual

Here are the key steps for Lab 12: 1. Choose a database design project to work on. This could be based on a real-world scenario like a library system, inventory system, etc. 2. Design the database schema including the tables, columns, primary keys, foreign keys, data types, etc. Draw an ERD diagram. 3. Write the SQL commands to CREATE the tables and define the constraints. 4. Populate the tables with sample data using INSERT statements. 5. Write queries to SELECT, INSERT, UPDATE, and DELETE data as needed to demonstrate functionality. 6. Test your queries and verify the design is working as intended. Troubleshoot any issues.

Uploaded by

tasnim
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)
67 views8 pages

Final Term Lab Manual

Here are the key steps for Lab 12: 1. Choose a database design project to work on. This could be based on a real-world scenario like a library system, inventory system, etc. 2. Design the database schema including the tables, columns, primary keys, foreign keys, data types, etc. Draw an ERD diagram. 3. Write the SQL commands to CREATE the tables and define the constraints. 4. Populate the tables with sample data using INSERT statements. 5. Write queries to SELECT, INSERT, UPDATE, and DELETE data as needed to demonstrate functionality. 6. Test your queries and verify the design is working as intended. Troubleshoot any issues.

Uploaded by

tasnim
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/ 8

Introduction

to Database
Lab Manual Finalterm

American International
University-Bangladesh
Lab 7 (Sub-query)

Exercise:
1. Display all the employees who are earning more than all the managers.
2. Display all the employees who are earning more than any of the managers.
3. Select employee number, job & salaries of all the Analysts who are earning more than any of
the managers.
4. Select all the employees who work in DALLAS.
5. Select department name & location of all the employees working for CLARK.
6. Select all the departmental information for all the managers
7. Display the first maximum salary.
8. Display the second maximum salary.
9. Display the third maximum salary.
10. Display all the managers & clerks who work in Accounts and Marketing departments.
11. Display all the salesmen who are not located at DALLAS.
12. Get all the employees who work in the same departments as of SCOTT.
13. Select all the employees who are earning same as SMITH.
14. Display all the employees who are getting some commission in marketing department where
the employees have joined only on weekdays.
15. Display all the employees who are getting more than the average salaries of all the
employees.
Lab 8 (Joining: Displaying Data from Multiple Tables)
Exercise:
1.Display all the managers & clerks who work in Accounts and Marketing
departments. 2. Display all the salesmen who are not located at DALLAS.
3. Select department name & location of all the employees working for CLARK.
4. Select all the departmental information for all the managers
5.Select all the employees who work in DALLAS.
6.Delete the records from the DEPT table that don’t have matching records in EMP
7.Display all the departmental information for all the existing employees and if a department
has no employees display it as “No employees”.
8.Get all the matching & non-matching records from both the tables.
9.Get only the non-matching records from DEPT table (matching records shouldn’t be selected).
10. Select all the employees name along with their manager names, and if an employee does
not have a manager, display him as “CEO”.
11. Get all the employees who work in the same departments as of SCOTT
12. Display all the employees who have joined before their managers.
13. List all the employees who are earning more than their managers.
14. Fetch all the employees who are earning same salaries.
15. Select all the employees who are earning same as SMITH.Display employee name , his date
of joining, his manager name & his manager's date of joining.
Lab 9 (View)

Exercise

1. Create a view called EMP_VU based on the employee number, employee name, and department
number from the EMP table. Change the heading for the employee name to EMPLOYEE.

2. Display the contents of the EMP_VU view.


EMPNO EMPLOYEE DEPTNO

7839 KING 10
7698 BLAKE 30
7782 CLARK 10
7566 JONES 20
7654 MARTIN 30
7499 ALLEN 30
7844 TURNER 30
7900 JAMES 30
7521 WARD 30
7902 FORD 20
7369 SMITH 20
7788 SCOTT 20
7876 ADAMS 20
7934 MILLER 10

3. using your view EMP_VU, enter a query to display all employee names and department numbers.

EMPLOYEE DEPTNO

KING 10

BLAKE 30

CLARK 10
JONES 20

MARTIN 30

4. Create a view named DEPT20 that contains the employee number, employee name, and department
number for all employees in department 20. Label the view column EMPLOYEE_ID, EMPLOYEE, and
DEPARTMENT_ID. Do not allow an employee to be reassigned to another department through the
view.

5. Create a view called SALARY_VU based on the employee name, department name, salary, and salary
grade for all employees. Label the columns Employee, Department, Salary, and Grade, respectively.

** Please save the SQL commands in a text file for further use.
Lab 10 (Sequence)

Exercise:

1. Create a sequence to be used with the primary key column of the DEPARTMENT table. The
sequence should start at 60 and have a maximum value of 200. Have your sequence increment
by ten numbers. Name the sequence DEPT_ID_SEQ.

2. Write a script to display the following information about your sequences: sequence name,
maximum value, increment size, and last number.

3. Write an interactive script to insert a row into the DEPARTMENT table. Be sure to use the
sequence that you created for the ID column. Create a customized
prompt to enter the department name. Execute your script. Add two departments named
Education and Administration. Confirm your additions.
Lab 11 (User Control Access)

Exercise:
Suppose you are the DBA for the following schemas. Complete the following task with appropriate
sql command.
Employee

Eid EName Job Supervisor Sal Did


E001 Asif Manager E009 20000.00 10
E002 Arif Manager E009 30000.00 10
E004 Abul Salesman E001 15000.00 20
E005 Kuddus Salesman E001 15000.00 20
E006 Maruf Salesman E003 15000.00 20
E009 Hasan President 40000.00 10
Did Name Manager Departments

10 Admin E009

20 Sales E002

Products OrderDetais

OrderID ProductID Quantity ProductID PName Price


O001 P001 10
O002 P001 10 P001 Machinery 50000.00
O002 P003 10
O003 P002 10 P002 Hardware 55000.00
a) Create a user Rahul with the password
ret23erz. P003 Software 65000.00
b) Create a new role Accounts.
c) Grant system privileges create table, view and sequence to role Accounts.
d) Assign role Accounts to Rahul.
e) Change password of Rahul with the new password rec34tg
f) Grant query privilege to Asif and Arif on Departments table.
g) Grant privilege update to column Price on OrderDetails table to role Manager and
user Hasan.
h) Give Asif the authority to pass along update and insert privilege on Departments table.
Lab 12 (Project Presentation and Discussion)

You might also like