EE436L: Database Engineering: Lab Manual

Download as pdf or txt
Download as pdf or txt
You are on page 1of 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