Download Unannotated Slides - Stanford Lagunita

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Views
Defining and
Using Views
Jennifer Widom
Defining & Using Views
Three-level vision of database
Physical – Conceptual – Logical
Jennifer Widom
Defining & Using Views
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
Jennifer Widom
Defining & Using Views
Defining and using views
 View V = ViewQuery(R1, R2, …, Rn)
 Schema of V is schema of query result
 Query Q involving V, conceptually:
V := ViewQuery(R1,R2,…,Rn)
Evaluate Q
 In reality, Q rewritten to use R1,…,Rn instead of V
 Note: Ri could itself be a view
Jennifer Widom
Defining & Using Views
SQL Syntax
Create View Vname As
<Query>
Jennifer Widom
Defining & Using Views
SQL Syntax
Create View Vname(A1,A2,…,An) As
<Query>
Demo: simple college admissions database
College(cName,state,enrollment)
Student(sID,sName,GPA,sizeHS)
Apply(sID,cName,major,decision)
Jennifer Widom
Related documents