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

Assignment 8

This document discusses creating views in MySQL. It defines a view as a virtual table defined by a SELECT query. Views can be used to restrict access to columns or simplify complex queries. The document provides examples of creating simple views, views using joins, views with aggregate functions, and views with nested queries. It notes some restrictions on views, such as not being able to create indexes on views and not being able to update views created from complex queries. Guidelines are provided for students to document their view experiments.

Uploaded by

Ajay Singh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Assignment 8

This document discusses creating views in MySQL. It defines a view as a virtual table defined by a SELECT query. Views can be used to restrict access to columns or simplify complex queries. The document provides examples of creating simple views, views using joins, views with aggregate functions, and views with nested queries. It notes some restrictions on views, such as not being able to create indexes on views and not being able to update views created from complex queries. Guidelines are provided for students to document their view experiments.

Uploaded by

Ajay Singh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

ASSIGNMENT NO.

Aim

Execute DDL statements which demonstrate use of Views.

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.

create view view_name as select statement

MySQL view’s restrictions

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;

View using joins


create view v2 as select empname, dname from employee, department where
employee.did=department.did;
View using aggregate function
create view v3 as select did, sum(salary) from employee group by did;

View using nested Queries

create view v4 as select * from Employee where salary in (select


max(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

Frequently Asked Questions

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

Guidelines for Students


The experiments should be completed and get checked by the concerned teacher in the
lab on or before the date of submission. After which the experiment will not be signed.

Every experiment must be included in the file in following format.


a. Aim: In this section write complete objective of the program you are going to make in
the lab. This section specifies the complete description of the including problem analysis,
input description, method used, fundamental concept and desired output format.
b. Theory: Write brief theory related to practical.
c. Algorithm: Write Algorithm for given task.
d. Input: Write input test data/ or program that are used to test program objective to see
whether program is achieving the given objective or not.
e. Output: describe the results in few lines
f. Conclusion: Write complete conclusion whether what the student has learned from this
experiment.
g. Source Code: Submit in the form of soft copies.

 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

You might also like