0% found this document useful (0 votes)
25 views

Database Systems Laboratory Exercises Lab2

This document outlines exercises for an introduction to database systems laboratory, including: 1) Altering existing tables by adding and modifying columns, dropping and recreating primary/foreign keys 2) Using SQL aggregate functions to calculate totals, averages, counts of data 3) Using different types of joins (inner, left, right) to combine data from multiple tables 4) Creating views and stored procedures to manipulate and retrieve data

Uploaded by

dinaras bekele
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)
25 views

Database Systems Laboratory Exercises Lab2

This document outlines exercises for an introduction to database systems laboratory, including: 1) Altering existing tables by adding and modifying columns, dropping and recreating primary/foreign keys 2) Using SQL aggregate functions to calculate totals, averages, counts of data 3) Using different types of joins (inner, left, right) to combine data from multiple tables 4) Creating views and stored procedures to manipulate and retrieve data

Uploaded by

dinaras bekele
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/ 2

Introduction to Database Systems Laboratory Exercises 1

Introduction to Database Systems Laboratory Exercises


Objectives:
• Altering existing table to modify existing attribute and add a new attribute to the table.
• Exercising different join statements between tables (inner join, left join, right join)
• Exercising Views, functions and stored procedures

I. Exercises on Altering Existing Tables


1. Add one new columns to the department table, which is created in the previous lab, that holds
the location of the department of varchar data type which holds up to 50 characters and have a
default value of Addis Ababa
2. Add a new column to the instructors table holds monthly part-time income of each instructor
with default null value.
3. Update the instructor table to insert the monthly income of each instructor with your preferred
amount.
4. Modify the department table to change the location column to hold a maximum of 100
characters.
5. Drop the primary key of the department table and recreate it.
6. Drop the foreign key of instructor table and recreate it by including all the necessary integrity
constraint.
7. Remove the location column of the department table which is added to the department table
in step one of this exercise.
II. Exercises on Using SQL Aggregate functions
1. Select the annual budget of the school using SQL aggregate function (Assume that the annual
budget of the school is the sum of the departments’ annual budget.)
2. Determine the average salary of the instructors which is paid in the school.
3. Determine the number of instructor which are available in the school using SQL aggregate
function.
4. Determine the minimum and maximum salary which is paid in the in the school.

Version: 01 Lab: 02 Nov, 2016


1
Introduction to Database Systems Laboratory Exercises 2

III. Exercises on Different SQL Join Statements


1. Show instructor ID, instructor name, the course ID of the course which taught by each
instructor, the semester and year. The result shall include instructors who are only assigned
to a certain course currently or on the previous academic periods.
2. Select all information about instructors and the course taught by instructors. If the instructor
is not delivering a certain course currently or in previous academic years, the information shall
be included in the result.
3. Find the Cartesian product of the instructor and teaches table to display all the possible
combination of information about the instructors and the course which is taught by the
instructor.
(Note: While joining tables if the same attribute exists in tables to be joined, aliases or full
attribute identifier (table_name.attribute_name) shall be used.)
IV. Views and stored procedures
1. Create a new view that that holds the instructor ID, instructor name, department name,
course ID and section ID and populated with the existing data in respective tables which
contain those data. After creating the view try to insert a new data and update the
existing of the created and report the result.
2. Write a stored procedure to insert and update data on department table
3. Write a custom function to calculate tax given salary. The tax is 30% of the salary. Apply
this function to do tax for all instructors
4. General Exercises
1. Select the instructor ID and the number of courses thought by each instructor.
2. Determine the number of instructors assigned in each section.
3. Select all instructors that have a monthly salary of 10,000 or 15,000 without using logical
operators and the result shall be grouped by salary;
4. Count the number of instructors having a salary of 10,000 or 15 000 and show the result without
using logical operators.

Version: 01 Lab: 02 Nov, 2016


2

You might also like