Assignment 8
Assignment 8
Aim
Objective
Understand and implement DDL statements to demonstrate views.
Theory
MySQL View:
A database view is a virtual table or logical table which is defined as a SQL SELECT query with
joins. Because a database view is similar to a database table, which consists of rows and
columns, so you can query data against it.
You cannot create an index on a view. MySQL uses indexes of the underlying tables when you
query data against the views that use the merge algorithm. For the views that use the temptable
algorithm, indexes are not utilized when you query data against the views.
You cannot use subqueries in the FROM clause of the SELECT statement defined the view before MySQL
5.7.7
If you drop or rename tables that a view is based on, MySQL does not issue any errors. However,
MySQL does invalidate the view. You can use the CHECK TABLE statement to check whether the
view is valid.
A simple view can be updatable. A view created based on a complex SELECT statement with join,
subquery, etc., cannot be updatable
Syntax
create view view_name as select query;
Example ;
Simple View
create view v1 as select empname, address, salary from employee;
Output
Create view.
References:
1. Raghu Ramkrishanan, Johannes Gehrke 4 th Edition “Database Management Systems” 2. Avi
Silberschatz , Henry F. Korth , S. Sudarshan, “Database System Concepts, Sixth Edition”, ISBN-
13: 978-93-3290-138-4, MCGraw Hill
Q. Questions BT CO
No
1 Explain concept of views? 2 2
2 Explain view updating rules? 2 2
3 Explain constraints on views. 2 2
Marking criteria.
Experiment completion (Timely)
Lab file (neatness and regularity)
Viva (from time to time)
Mock Practical Exam
Exam (end term): Practical + Viva
Assessment Methodology
Timely completion of assignment- 2marks
Program demonstration- 4 marks
Viva-voce -2 marks
Timely submission of journal- 2 marks