lecture-08-views

lecture-08-views - Views Materialised Views Views T. M....

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Views Materialised Views Views T. M. Murali September 20, 2010 T. M. Murali September 20, 2010 CS 4604: Views Views Materialised Views What are Views? I A view is a relation that does not exist physically. I A view is defined by a query over other relations (tables and/or views). I Just like a table, a view can be queried: the query processor replaces the view by its definition. I Just like a table, a view can be used in other queries. I Unlike a table, a view cannot be updated unless it satisfies certain conditions. T. M. Murali September 20, 2010 CS 4604: Views Views Materialised Views Defining a View I CREATE VIEW ViewName AS Query; T. M. Murali September 20, 2010 CS 4604: Views Views Materialised Views Defining a View I CREATE VIEW ViewName AS Query; I Suppose we want to perform a set of queries on those students who have taken courses in the computer science departments. I Let us create a view to store the PIDs of these students and the numbers of the CS courses they are taking. T. M. Murali September 20, 2010 CS 4604: Views Views Materialised Views Defining a View I CREATE VIEW ViewName AS Query; I Suppose we want to perform a set of queries on those students who have taken courses in the computer science departments. I Let us create a view to store the PIDs of these students and the numbers of the CS courses they are taking. CREATE VIEW CSStudents AS SELECT StudentPID, Number FROM Take WHERE (DeptName = CS); T. M. Murali September 20, 2010 CS 4604: Views Views Materialised Views Defining a View I CREATE VIEW ViewName AS Query; I Suppose we want to perform a set of queries on those students who have taken courses in the computer science departments. I Let us create a view to store the PIDs of these students and the numbers of the CS courses they are taking. CREATE VIEW CSStudents(PID, CSCourseNumber) AS SELECT StudentPID, Number FROM Take WHERE (DeptName = CS); I Can name attributes in the views schema. T. M. Murali September 20, 2010 CS 4604: Views Views Materialised Views Querying Views I We can query views just as we can query tables. T. M. Murali September 20, 2010 CS 4604: Views Views Materialised Views Querying Views I We can query views just as we can query tables. I How many students took a CS course, i.e., what was the total enrollment in CS courses? T. M. Murali September 20, 2010 CS 4604: Views Views Materialised Views Querying Views I We can query views just as we can query tables. I How many students took a CS course, i.e., what was the total enrollment in CS courses? SELECT COUNT (PID) FROM CSStudents; T. M. Murali September 20, 2010 CS 4604: Views Views Materialised Views Querying Views I We can query views just as we can query tables....
View Full Document

Page1 / 46

lecture-08-views - Views Materialised Views Views T. M....

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online