Slide 9- 1
Chapter 8 Views تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة من الادوات في ذلك. حيث المرجع الاساسي للمادة هي الكتاب المعتمد في وصف المقرر
Levels of Abstraction Views describe how users see the data. Conceptual schema defines logical structure Physical schema describes the files and indexes used. Slides adapted from Rao (ASU) & Franklin (Berkeley) Physical Schema Conceptual Schema View 1View 2View 3 DB
Slide 9- 4 Views in SQL A view is a “virtual” table that is derived from other tables They are used mostly in order to simplify complex queries and to define conceptually different views of the database to different classes of users. Allows full query operations
Slide 9- 5 Specification of Views CREATE VIEW command Give table name, list of attribute names, and a query to specify the contents of the view
Specification of Views in SQL (cont’d.) Specify SQL queries on a view View always up-to-date Responsibility of the DBMS and not the user DROP VIEW command Dispose of a view
Example1 Product ( pname, price, category, maker) Purchase (buyer, seller, store, product) Company (cname, stockPrice, country) Person( per-name, phoneNumber, city) View: purchases of telephony products: CREATE VIEW telephony-purchases AS SELECT product, buyer, seller, store FROM Purchase, Product WHERE Purchase.product = Product.name AND Product.category = “telephony” Slide 9- 7
Example2 CREATE VIEW Seattle-view AS SELECT buyer, seller, product, store FROM Person, Purchase WHERE Person.city = “Seattle” AND Person.name = Purchase.buyer We can later use the views: SELECT name, store FROM Seattle-view, Product WHERE Seattle-view.product = Product.name AND Product.category = “shoes”