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

EE436L: Database Engineering: Lab Manual

This document is a lab manual for a database engineering course. It provides instructions on using views and triggers in MySQL. It defines views as reusable queries that encapsulate complex queries and provide security. It then lists 5 common commands for working with views: CREATE VIEW, INSERT IN VIEW, DELETE IN VIEW, UPDATE OF VIEW, and DROP OF VIEW. It provides examples of using these commands to create and access views of a hotel booking database. It also provides an instruction to create an audit trigger for an employee table to log changes to the employeeAudit table.

Uploaded by

Usman Ilamdin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views

EE436L: Database Engineering: Lab Manual

This document is a lab manual for a database engineering course. It provides instructions on using views and triggers in MySQL. It defines views as reusable queries that encapsulate complex queries and provide security. It then lists 5 common commands for working with views: CREATE VIEW, INSERT IN VIEW, DELETE IN VIEW, UPDATE OF VIEW, and DROP OF VIEW. It provides examples of using these commands to create and access views of a hotel booking database. It also provides an instruction to create an audit trigger for an employee table to log changes to the employeeAudit table.

Uploaded by

Usman Ilamdin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Lab Manual

EE436L: Database

9 Engineering
Department of Electrical Engineering
University of Engineering and Technology Lahore 2020
Instructor: Mr. Umer Shahid

Name
Registration Number _

Views and Triggers


Views in MySQL help to encapsulate complex query and make it reusable. It also provides user
security on each view - it depends on your data policy security. There are a few commands
which are applied on Database to create, edit, or delete any view.

1. COMMAND NAME: CREATE VIEW


COMMAND DESCRIPTION: CREATE VIEW command is used to define a view.
2. COMMAND NAME: INSERT IN VIEW
COMMAND DESCRIPTION: INSERT command is used to insert a new row into the
view.
3. COMMAND NAME: DELETE IN VIEW
COMMAND DESCRIPTION: DELETE command is used to delete a row from the view.
4. COMMAND NAME: UPDATE OF VIEW
COMMAND DESCRIPTION: UPDATE command is used to change a value in a tuple
without changing all values in the tuple.
5. COMMAND NAME: DROP OF VIEW
COMMAND DESCRIPTION: DROP command is used to drop the view table

Please write the following queries to create and access the views on the database that you
are using in last 2 labs.
I. Use views to list the details of all rooms at the Marriott Hotel, including the name of the
guest(s) staying in the room, if the room is occupied and the prices of the rooms.
(VIEW1)

1
II. Use View to List the names and addresses of all guests in London, alphabetically ordered
by name. (VIEW2)
III. Use View to List the bookings for which no dateTo has been specified. (VIEW3)
IV. Insert a new tuple in VIEW2 by using “INSERT INTO VIEW2” command and check if
new data has updated the original table or not.
V. Update the price of all rooms in VIEW1 and check if update operation is performed on
original database or not.
VI. Create a trigger to audit the changes of the employee table. First, create an employee
table with appropriate attributes. Then, create an employeeAudit table that keeps the
changes in the employee table. Add appropriate attributes in the table. In order to fetch
the details of trigger, you may refer the following link:
https://www.w3resource.com/mysql/mysql-triggers.php

You might also like