Presentation is loading. Please wait.

Presentation is loading. Please wait.

Views Defining and Using Views.

Similar presentations


Presentation on theme: "Views Defining and Using Views."— Presentation transcript:

1 Views Defining and Using Views

2 Three-level vision of database Physical – Conceptual – Logical
Defining & Using Views Three-level vision of database Physical – Conceptual – Logical

3 Hide some data from some users Make some queries easier / more natural
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

4 Defining and using views View V = ViewQuery(R1, R2, …, Rn)
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: In reality, Q rewritten to use R1,…,Rn instead of V Note: Ri could itself be a view V := ViewQuery(R1,R2,…,Rn) Evaluate Q

5 Defining & Using Views SQL Syntax Create View Vname As <Query>

6 Demo: simple college admissions database
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)


Download ppt "Views Defining and Using Views."

Similar presentations


Ads by Google