30 Lab Manual
30 Lab Manual
Objectives
At the end of the course students should
1. Have a good understanding of how DBMS architecture, particularly those concerned with
creation and maintenance of tables and database.
2. Have a good understanding of the fundamental DBMS used in computer science.
3. Be able to understand various types of queries and their execution.
4. Be able to design new database and modify existing ones for new applications and reason
about the efficiency of the result.
5. Have a fair knowledge of PL/SQL.
Software Required:
1. VB, ORACLE and/or DB2
2. VB, MSACCESS
3. VB, MS SQL SERVER 2000
4. JAVA, MYSQL
5. JAVA, ORACLE
Hardware Required:
Processor : Pentium IV
RAM : 1 GB
Hard Disk : 200 GB
ASSIGNMENT NO.1
Q1. Create the following tables:
i) CM (Client_master)
ii) PM (Product_master)
iii) SM (Salesman_master)
v) SOD (Sales_order_details)
Discription: used to store client’s orders with details of each product ordered.
Columnname Datatype Size Attributes
SONO Varchar2 6 Foreign key references
s_order_no of sales_order table.
PNO Varchar2 6 Foreign key references
product_no of product_master table.
Qty_order Number 8
Qty_disp Number 8
Product_rate Number 10,2
i) client_master (CM)
SNO S_name Addr Address City Pin State Salam Tgt_ Ytd Rem
ess1 1 code t to_get Sales
S00001 Aman A/14 worli Mumbai 400002 Mah 3000 100 50 Good
S00002 Omkar 65 Nariman Mumbai 400001 Mah 3000 200 100 Good
S00003 Raj P-7 Bandra Mumbai 400032 Mah 3000 200 100 Good
S00004 Ashish A/5 Juhu Mumbai 400044 Mah 3500 200 150 Good
On the basis of client_master & product_master tables answer the following Questionnaires:
a. Find out the names of all the clients.
b. Retrieve the entire contents of client_master table.
c. Retrieve the list of names, city and state of all the clients.
d. List the various products available from the product_master table.
e. List all the clients who are located in Mumbai.
f. List the names of salesmen who have a salary equal to Rs. 3000
Exercise on updating records in a table.
a. Change the city of client no. ‘C00005’ to ‘Banglore’.
b. Change the bal_due of client no. ‘C00001’ to Rs. 1000.
c. Change the cost price of Trousers to Rs. 950.00.
d. Change the city of salesmen to ‘Pune’.
SONO CNO S_orderdate SNO Dely Bill Y/N Delay date Orderstatus
type
O19001 C00001 12-June-04 S00001 F N 20-July-02 In Process
O19002 C00002 25-June-04 S00002 P N 27-June-02 Cancelled
O46865 C00003 18-Feb-04 S00003 F Y 20-Feb-02 Fulfilled
O19003 C00001 03-Apr-04 S00001 F Y 07-Apr-02 Fulfilled
O46866 C00004 20-May-04 S00002 P N 22-May-02 Cancelled
O19008 C00005 24-May-04 S00004 F N 26-July-02 In Process
ASSIGNMENT NO.5
Exercise on Joins and Correlation:
a. Find out the products which have been sold to ‘Ivan Bayross’.
b. Find out the products and their quantities that have to be delivered in the current month.
c. List the product no. and the description of constantly sold (i.e. rapidly moving) products.
d. Find the names of clients who have purchased ‘Trousers’.
e. List the products and orders from customers who have ordered less than 5 units of ‘Pull
Overs’.
f. Find the product and their quantities for the orders placed by ‘Ivan Bayross’ and ‘Mamta
Mazumdar’.
g. Find the product and their quantities for the orders placed by client no. ‘C00001’ and
‘C00002’.
ASSIGNMENT NO. 6
Write appropriate SQL statements for the following:
a. Create a simple index idx_prod on product cost price from the product_master table.
b. Create a sequence inv_seq with the following parameters, increment by 3, cycle, cache 4
and which will generate the numbers from 1 to 9999 in ascending order.
c. Create a view on order no., orderdate, orderstatus of sales_order table and productno.,
productrate and qtyordered of sales_order_details.
ASSINGNMENT NO. 7
Exercise on DCL statements:
a. Give the user Ivan permission only to view records in the tables sales_order and
sales_order_details along with option to further grant permission on these tables to other
users.
b. Give the user Ivan all data manipulation privileges on the table client_master without an
option to further grant permission on client_master table to other users.
c. Take back all privileges given to the user Ivan on the table client_master.
Exercise on TCL statements:
a. A factory maintains records of stocks_on_hand and material requirements in item_master
table and item_requisite table respectively.
Table Name: item_master
Column Name Data Type Size Default Attributes
item_id Number 4 Primary key, identify number for the item
Description Varchar2 20 Item description
Bal_stock Number 3 Balance stock for an item
a. If at any given point, the value in bal_stock becomes negative, the entire update operation
for all item_id should rollback.
b. If at any given point, the value in bal_stock becomes negative, the update operation for
that particular item_id should rollback.
c. Create user defined Exceptions. Write a program, if the requested qty attempted is more
than the current balance qty held for a item, a user defined exception is raised displaying
an appropriate error message otherwise perform the appropriate task.
ASSINGNMENT NO. 9
Exercise on PL/SQL procedures and functions.
a. Create a procedure that accepts a client_no. and checks if the client_no. exists in the table
client_master. If the client_no. exists, display a message “Valid Client” and if the client_no.
does not exist than display an appropriate error message.
b. Drop the above created procedure.
c. Create a function getMaxClientNo that returns MAX value for client_no. in the table
client_master. Using this function write an insert statement to add a new record in
client_master table.
d. Create a package named mypackage that will hold the function and procedure created
above. Write down the package specification and package body for the package
mypackage.
ASSINGNMENT NO. 10
Exercise on Triggers:
a. Write and update trigger on client_master table. The system should keep track of the
records that are being updated. The old values of the updated record should be added in
the audit_trail table.
b. Write a trigger on delete of client_master table to keep the details of deleted client in
old_client_master table.
c. Write a trigger on update of client_master table and check if client_no is changing then it
should stop operation and give error message.
d. Write a trigger that limits the DML actions to the client_master table to weekdays from
8.30am to 6.30pm. If a user tries to insert/update/delete a row in the client_master table,
a warning message will be prompted.
e. Disable the trigger created in above exercise.
f. Delete the trigger created in above exercise.
The company is organized into DEPARTMENTs. Each department has a name, number and an
employee who manages the department. We keep track of the start date of the department
manager.
Each department controls a number of PROJECTs. Each project has a name, number and is
located at a single location.
We store each EMPLOYEE’s social security number, address, salary, sex, and birthdate. Each
employee works for one department but may work on several projects. We keep track of the
number of hours per week that an employee currently works on each project. We also keep
track of the direct supervisor of each employee.
Each employee may have a number of DEPENDENTs. For each dependent, we keep track of
their name, sex, birthdate, and relationship to employee.
More than one relationship type can exist with the same participating entity types. For
example, MANAGES and WORKS_FOR are distinct relationships between EMPLOYEE and
DEPARTMENT, but with different meanings and different relationship instances.
Design the ER diagram for this problem statement and convert into relational model.
Mini Project
Mini project on designing and implementing one data base management system.
Project Title
Certificate
Acknowledgement
System Overview
Current system
Objectives of the proposed system
Advantages of the Proposed system (over current)
E.R. Diagram
Entities
Relationships
Mapping Constraints
Database Schema/Table Definition
Table Name
Field Name
Data type
Field size
Constraint (e.g. auto generated, primary key, foreign key)
Validation (e.g. not null, default value)
Implementation using Java or .NET
Output
Future Enhancements of the system
Bibliography
Note: From the 3rd lab reporting will be started for project.