Jennifer Widom Views Materialized Views. Jennifer Widom Why use views?  Hide some data from some users  Make some queries easier / more natural  Modularity.

Slides:



Advertisements
Similar presentations
Testing Relational Database
Advertisements

Split Databases. What is a split database? Two databases Back-end database –Contains tables (data) only –Resides on server Front-end database –Contains.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Relational Algebra Chapter 4, Part A.
CMPT 354 Views and Indexes Spring 2012 Instructor: Hassan Khosravi.
SQL This presentation will cover: A Brief History of DBMS View in database MySQL installation.
Visibility Information Exchange Web System. Source Data Import Source Data Validation Database Rules Program Logic Storage RetrievalPresentation AnalysisInterpretation.
Incremental Maintenance for Non-Distributive Aggregate Functions work done at IBM Almaden Research Center Themis Palpanas (U of Toronto) Richard Sidle.
Chapter 3 The Relational Model Transparencies © Pearson Education Limited 1995, 2005.
Chapter 3. 2 Chapter 3 - Objectives Terminology of relational model. Terminology of relational model. How tables are used to represent data. How tables.
CS240A: Databases and Knowledge Bases Applications of Active Database Carlo Zaniolo Department of Computer Science University of California, Los Angeles.
1 Views. 2 What are views good for?(1) Simplifying complex queries: we saw one example. Here is another example that allows the user to "pretend" that.
1 Rewriting Minus Queries Using Not In SELECT S.sname FROM Sailors S, Boats B, Reserves R WHERE S.sid = R.sid and R.bid = B.bid and B.color = ‘red’ MINUS.
1 Views. 2 What are views good for? (1) Simplifying complex queries: We saw one example. Here is another that allows the user to "pretend" that there.
Data Warehouse View Maintenance Presented By: Katrina Salamon For CS561.
Relational Databases Relational Algebra (2)
Jennifer Widom Views Defining and Using Views. Jennifer Widom Defining & Using Views Three-level vision of database Physical – Conceptual – Logical.
Jennifer Widom SQL Data Modification Statements. Jennifer Widom Insert Into Table Values(A 1,A 2,…,A n ) SQL: Modifications Inserting new data (2 methods)
Lecture 2 The Relational Model. Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical relations.
Chapter 4 The Relational Model Pearson Education © 2014.
Views Lesson 7.
Advanced Database CS-426 Week 1 - Introduction. Database Management System DBMS contains information about a particular enterprise Collection of interrelated.
What is a Package? A package is an Oracle object, which holds other objects within it. Objects commonly held within a package are procedures, functions,
Module Coordinator Tan Szu Tak School of Information and Communication Technology, Politeknik Brunei Semester
Introduction to Databases
View 1. Lu Chaojun, SJTU 2 View Three-level vision of DB users Virtual DB views DB Designer Logical DB relations DBA DBA Physical DB stored info.
MySQL and GRID status Gabriele Carcassi 9 September 2002.
Chapter 5 : Integrity And Security  Domain Constraints  Referential Integrity  Security  Triggers  Authorization  Authorization in SQL  Views 
The Relational Model. 2 Relational Model Terminology u A relation is a table with columns and rows. –Only applies to logical structure of the database,
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Database Management Systems Chapter 5 SQL.
Jennifer Widom Relational Databases The Relational Model.
The Relational Model © Pearson Education Limited 1995, 2005 Bayu Adhi Tama, M.T.I.
Lecture 15: Query Optimization. Very Big Picture Usually, there are many possible query execution plans. The optimizer is trying to chose a good one.
CS1100: Data, Databases, Queries Action Queries CS11001Advanced Queries.
Hoi Le. Why database? Spreadsheet is not good to: Store very large information Efficiently update data Use in multi-user mode Hoi Le2.
Chapter 4 The Relational Model Pearson Education © 2009.
1 Introduction to Database Systems, CS420 SQL Views and Indexes.
SQL: Interactive Queries (2) Prof. Weining Zhang Cs.utsa.edu.
Jennifer Widom Relational Databases Relational Algebra (1) Select, project, join.
7.5 Using Stored-Procedure and Triggers NAME MATRIC NUM GROUP Muhammad Azwan Bin Khairul Anwar CS2305A Muhammad Faiz Bin Badrol Shah CS2305B.
Jennifer Widom Authorization. Jennifer Widom Authorization Database Authorization  Make sure users see only the data they’re supposed to see  Guard.
Jennifer Widom Indexes. Jennifer Widom Indexes  Primary mechanism to get improved performance on a database  Persistent data structure, stored in database.
More SQL: Complex Queries, Triggers, Views, and Schema Modification
Transactions Introduction.
Querying Relational Databases
6 Benefits of Using Microsoft Access Database. Microsoft Access is an efficient program that helps companies to carry out complex business processes in.
Views Defining and Using Views.
Views View Modifications  Introduction.
Transactions Introduction.
Indexes.
Views Materialized Views.
Relational Databases Relational Algebra (2)
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Querying Relational Databases
Chapter 4 The Relational Model Pearson Education © 2009.
CS 440 Database Management Systems
Views View Modifications  Introduction.
Views Automatic View Modifications.
SQL This presentation will cover: View in database MySQL installation
The Relational Model Transparencies
Chapter 4 The Relational Model Pearson Education © 2009.
Instructor 彭智勇 武汉大学软件工程国家重点实验室 电话:
Chapter 4 The Relational Model Pearson Education © 2009.
Views View Modifications Using Triggers.
Topic 15 Lesson 1 – Action queries
Views 1.
Chapter 4 The Relational Model Pearson Education © 2009.
SQL Views Presented by: Dr. Samir Tartir
Views Base Relation View
Chapter 8 Views and Indexes
Presentation transcript:

Jennifer Widom Views Materialized Views

Jennifer Widom Why use views?  Hide some data from some users  Make some queries easier / more natural  Modularity of database access Real applications tend to use lots and lots (and lots and lots!) of views Materialized Views

Jennifer Widom Why use (virtual) views?  Hide some data from some users  Make some queries easier / more natural  Modularity of database access Materialized Views

Jennifer Widom Why use materialized views?  Hide some data from some users  Make some queries easier / more natural  Modularity of database access  Improve query performance Materialized Views

Jennifer Widom Virtual views  View V = ViewQuery(R 1, R 2, …, R n )  Schema of V is schema of query result  Query Q involving V, conceptually:  In reality, Q rewritten to use R 1,…,R n instead of V V := ViewQuery(R 1,R 2,…,R n ); Evaluate Q; Materialized Views

Jennifer Widom Materialized views  View V = ViewQuery(R 1, R 2, …, R n )  Create table V with schema of query result  Execute ViewQuery and put results in V  Queries refer to V as if it’s a table But…  V could be very large  Modifications to R 1, R 2, …, R n  recompute or modify V Materialized Views

Jennifer Widom Create Materialized View CA-CS As Select C.cName, S.sName From College C, Student S, Apply A Where C.cName = A.cName And S.sID = A.sID And C.state = ‘CA’ And A.major = ‘CS’ cNamestateenr sIDsNameGPAHSsIDcNamemajordec CollegeStudentApply + Can use CA-CS as if it’s a table (it is!) Materialized Views

Jennifer Widom Create Materialized View CA-CS As Select C.cName, S.sName From College C, Student S, Apply A Where C.cName = A.cName And S.sID = A.sID And C.state = ‘CA’ And A.major = ‘CS’ cNamestateenr sIDsNameGPAHSsIDcNamemajordec CollegeStudentApply  Modifications to base data invalidate view Materialized Views

Jennifer Widom Create Materialized View CA-CS As Select C.cName, S.sName From College C, Student S, Apply A Where C.cName = A.cName And S.sID = A.sID And C.state = ‘CA’ And A.major = ‘CS’  Modifications to base data invalidate view Materialized Views

Jennifer Widom Queries over materialized views  View V = ViewQuery(R 1, R 2, …, R n )  Create table V with schema of query result  Execute ViewQuery and put results in V  Queries refer to V as if it’s a table Modifications on materialized views?  Good news: just update the stored table  Bad news: base tables must stay in synch  Same issues as with virtual views Materialized Views

Jennifer Widom  Modifications to V must also modify base tables Materialized Views

Jennifer Widom Picking which materialized views to create (Efficiency) benefits of a materialized view depend on:  Size of data  Complexity of view  Number of queries using view  Number of modifications affecting view Also “incremental maintenance” versus full recomputation Materialized Views

Jennifer Widom Automatic query rewriting to use materialized views Materialized Views Create Materialized View CA-Apply As Select sID, cName, major From Apply A Where cName In (Select cName From College Where state = ‘CA’) Select Distinct S.sID, S.GPA From College C, Student S, Apply A Where C.cName = A.cName And S.sID = A.sID And S.GPA > 3.5 And C.state = ‘CA’ And A.Major = ‘CS’

Jennifer Widom Why use materialized views?  Hide some data from some users  Make some queries easier / more natural  Modularity of database access  Improve query performance Materialized Views