Chapter 13 Views (up to p.495) Jason C. H. Chen, Ph.D.

Slides:



Advertisements
Similar presentations
AP STUDY SESSION 2.
Advertisements

Advanced SQL Topics Edward Wu.
1
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
David Burdett May 11, 2004 Package Binding for WS CDL.
Prepared by: Workforce Enterprise Services For: The Illinois Department of Commerce and Economic Opportunity Bureau of Workforce Development ENTRY OF EMPLOYER.
Local Customization Chapter 2. Local Customization 2-2 Objectives Customization Considerations Types of Data Elements Location for Locally Defined Data.
Create an Application Title 1Y - Youth Chapter 5.
Process a Customer Chapter 2. Process a Customer 2-2 Objectives Understand what defines a Customer Learn how to check for an existing Customer Learn how.
Custom Statutory Programs Chapter 3. Customary Statutory Programs and Titles 3-2 Objectives Add Local Statutory Programs Create Customer Application For.
Custom Services and Training Provider Details Chapter 4.
Add Governors Discretionary (1G) Grants Chapter 6.
CALENDAR.
The 5S numbers game..
Photo Slideshow Instructions (delete before presenting or this page will show when slideshow loops) 1.Set PowerPoint to work in Outline. View/Normal click.
Break Time Remaining 10:00.
Factoring Quadratics — ax² + bx + c Topic
Database Performance Tuning and Query Optimization
PP Test Review Sections 6-1 to 6-6
Chapter 10: Applications of Arrays and the class vector
User Friendly Price Book Maintenance A Family of Enhancements For iSeries 400 DMAS from Copyright I/O International, 2006, 2007, 2008, 2010 Skip Intro.
Contingency tables enable us to compare one characteristic of the sample, e.g. degree of religious fundamentalism, for groups or subsets of cases defined.
Chapter 7 Working with Databases and MySQL
9 Copyright © 2004, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
Introduction to Structured Query Language (SQL)
© Paradigm Publishing, Inc Access 2010 Level 1 Unit 1Creating Tables and Queries Chapter 2Creating Relationships between Tables.
Yong Choi School of Business CSU, Bakersfield
Displaying Data from Multiple Tables
Access Tables 1. Creating a Table Design View Define each field and its properties Data Sheet View Essentially spreadsheet Enter fields You must go to.
Dynamic Access Control the file server, reimagined Presented by Mark on twitter 1 contents copyright 2013 Mark Minasi.
Copyright © 2012, Elsevier Inc. All rights Reserved. 1 Chapter 7 Modeling Structure with Blocks.
 Copyright I/O International, 2013 Visit us at: A Feature Within from Item Class User Friendly Maintenance  Copyright.
Note: A bolded number or letter refers to an entire lesson or appendix. A Adding Data Through a View ADD_MONTHS Function 03-22, 03-23, 03-46,
1..
Adding Up In Chunks.
MaK_Full ahead loaded 1 Alarm Page Directory (F11)
1 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt Synthetic.
GEtServices Services Training For Suppliers Requests/Proposals.
Before Between After.
Subtraction: Adding UP
: 3 00.
5 minutes.
1 hi at no doifpi me be go we of at be do go hi if me no of pi we Inorder Traversal Inorder traversal. n Visit the left subtree. n Visit the node. n Visit.
Types of selection structures
Chapter 12 Working with Forms Principles of Web Design, 4 th Edition.
Essential Cell Biology
Converting a Fraction to %
CSE20 Lecture 15 Karnaugh Maps Professor CK Cheng CSE Dept. UC San Diego 1.
Clock will move after 1 minute
Physics for Scientists & Engineers, 3rd Edition
Select a time to count down from the clock above
© Paradigm Publishing, Inc Access 2010 Level 2 Unit 2Advanced Reports, Access Tools, and Customizing Access Chapter 8Integrating Access Data.
Import Tracking and Landed Cost Processing An Enhancement For AS/400 DMAS from  Copyright I/O International, 2001, 2005, 2008, 2012 Skip Intro Version.
Copyright Tim Morris/St Stephen's School
A Data Warehouse Mining Tool Stephen Turner Chris Frala
Dr. Chen, Oracle Database System (Oracle) 1 Chapter 12 Subqueries and Merge Statements (up to p.451) Jason C. H. Chen, Ph.D. Professor of MIS School of.
Chapter 11 Group Functions (up to p.402)
Introduction to Structured Query Language (SQL)
Introduction to Oracle9i: SQL1 Views. Introduction to Oracle9i: SQL2 Chapter Objectives Create a view, using CREATE VIEW command or the CREATE OR REPLACE.
Dr. Chen, Oracle Database System (Oracle) 1 Chapter 4 Constraints Jason C. H. Chen, Ph.D. Professor of MIS School of Business Gonzaga University Spokane,
Chapter 5 Data Manipulation and Transaction Control
Dr. Chen, Oracle Database System (Oracle) 1 HW Discussion Chapter 5 (#9) –Why need two “deletes”? SQL> --9. SQL> SQL> DELETE FROM orderitems 2 WHERE order#
Dr. Chen, Oracle Database System (Oracle) 1 Chapter 6 Additional Database Objects (up to p.195 and all in the pptx file) Jason C. H. Chen, Ph.D. Professor.
Dr. Chen, Business Database Systems (Oracle) Instruction on Creating sql files and SPOOL Jason C.H. Chen, Ph.D. Professor of MIS School of Business, Gonzaga.
Chapter 13 Views Oracle 10g: SQL. Oracle 10g: SQL2 Objectives Create a view, using CREATE VIEW command or the CREATE OR REPLACE VIEW command Employ the.
Dr. Chen, Oracle Database System (Oracle) 1 Basic Nested Queries and Views Jason C. H. Chen, Ph.D. Professor of MIS School of Business Gonzaga University.
Basic Nested Queries and Views
Presentation transcript:

Chapter 13 Views (up to p.495) Jason C. H. Chen, Ph.D. Professor of MIS School of Business Gonzaga University Spokane, WA 99258 USA chen@jepson.gonzaga.edu

Objectives Create a view by using CREATE VIEW command or the CREATE OR REPLACE VIEW command Employ the FORCE and NOFORCE options State the purpose of the WITH CHECK OPTION constraint Explain the effect of the WITH READ ONLY option Update a record in a simple view Re-create a view

Objectives (continued) Explain the implication of an expression in a view for DML operations Update a record in a complex view Identify problems associated with adding records to a complex view Identify the key-preserved table underlying a complex view Drop a view Explain inline views and the use of ROWNUM to perform a “TOP-N” analysis Create a materialized view to replicate data

Database Views Table-1 Table-2 Table-N database Database view Query A database view is a logical (virtual) table based on a query. Table-1 Table-2 Table-N It does not store data, but presents it in a format different from the one in which it is stored in the underlying tables. With the database view, you can view database records, but you can’t insert new records or modify or delete exiting records. database Single view table Database view Query Output: Report, Graphs

Views Permanent objects (logical or virtual table) that store queries but ____ data Based on a source query that: can specify a subset of a single table’s fields or records can join multiple tables Two purposes Reduce complex query requirements Restrict users’ access to sensitive data (enforce security; user has access to view but not underlying table) no

Creating and Using Database Views Views can be updateable if: SELECT clause contains only fieldnames, no functions or calculations Can ____ contain the ORDER BY, DISTINCT, or GROUP BY clauses, group functions, or set operators search condition cannot contain a nested query Views are used like tables for selecting, inserting, updating and deleting data (only updatable views can be modified) not

Database View (cont.) SELECT view_name FROM user_views; SELECT view_name FROM ALL_VIEWS WHERE owner=‘SYSTEM’; DROP VIEW <view_name>; CREATE OR REPLACE VIEW <view_name> AS <view query specification>;

Types of Views Table 13-1 Overview of View Concepts

I. Creating a View You use the CREATE VIEW keywords to create a view Use OR REPLACE if the view already exists Use FORCE if the underlying table does not exist at the time of creation Provide new column names if necessary WITH CHECK OPTION constraint – if used, prevents data changes that will make the data subsequently inaccessible to the view WITH READ ONLY – prevents DML operations Figure 13-2 Syntax of the CREATE VIEW command

CREATE OR REPLACE VIEW book_vu AS SELECT isbn, title, category FROM books WHERE category = 'COOKING'; SELECT * FROM book_vu; SQL> SELECT * 2 FROM book_vu; ISBN TITLE CATEGORY ---------- ------------------------------ --------- 3437212490 COOKING WITH MUSHROOMS COOKING 0299282519 THE WOK WAY TO COOK COOKING See next slide for detailed process

FROM clause in query references a view rather than a table BOOK_VU view (view stored in database) SELECT* FROM book_vu; Stores query: SELECT isbn, title, category FROM books WHERE category=‘COOKING’; 1 3 4 2 Processing steps: A query references a view rather than a table in the FROM clause. The query stored in the view is executed. The results from the view query are stored in temporary storage. The original query uses the temporary query results of the view as a table and completes execution. Figure 13-1 View Processing

DML Operations on a Simple View Any DML operations are allowed through simple views unless created with WITH READ ONLY option DML operations that violate constraints on the underlying table are not allowed -- chapter 13, Figure 13-5; p.478 CREATE VIEW region_ne AS SELECT * FROM customers WHERE region = 'NE'; SELECT customer#, lastname, city, state, region FROM region_ne; -- chapter 13, Figure 13-4; p.477 CREATE VIEW inventory AS SELECT isbn, title, retail price FROM books WITH READ ONLY; SELECT * FROM inventory;

Why Failed to Update? -- chapter 13, Figure 13-6; p.479 UPDATE inventory SET price = 45.96 WHERE title LIKE '%POEM'; -- “SELECT” is working (READ) SELECT * FROM inventory WHERE title LIKE '%POEM%'; SET title = 'THE SHORTEST POEMS' SQL> UPDATE inventory 2 SET price = 45.96 3 WHERE title LIKE '%POEM'; SET price = 45.96 * ERROR at line 2: ORA-42399: cannot perform a DML operation on a read-only view ISBN TITLE PRICE ---------- ------------------ ---------- 2147428890 SHORTEST POEMS 39.95 SQL> UPDATE inventory 2 SET title = 'THE SHORTEST POEMS' 3 WHERE title LIKE '%POEM%'; SET title = 'THE SHORTEST POEMS' * ERROR at line 2: ORA-42399: cannot perform a DML operation on a read-only view READY ONLY Figure 13-6 Failed updates on the INVENTORY view

Combining Topics – VIEW and NON-Equality Join Combing both VIEW (chapter 13) and NON-EQUALITY JOINS (chapter 9; p.304) A non-equality join enables you to store a range's minimum value in one column of a record and the maximum value in another column. So instead of finding a column-to-column match, you can use a non-equality join to determine whether the item being shipped falls between minimum and maximum ranges in the columns. If the join does find a matching range for the item, the corresponding shipping fee (and others) can be returned in the results

Business Scenario Once a year, JustLee Books offers weeklong promotion in which customers receive a gift based on the value of each book purchase. If a customer purchases a book with a retail price of $12 or less, the customer receives a bookmark. If the retail price is more than $12 but less than or equal to $25, the customer receives a box of book-owner labels. For books retailing for more than $25 and less than or equal to $56, the customer is entitled to a free book cover. For books retailing for more than $56, the customer receives free shipping. SQL> SELECT * FROM promotion; GIFT MINRETAIL MAXRETAIL --------------- ---------- ---------- BOOKMARKER 0 12 BOOK LABELS 12.01 25 BOOK COVER 25.01 56 FREE SHIPPING 56.01 999.99

Task … Your job is to produce a report listing book title, publisher name, profit and its gift (note individual gift that is based on the retail price falls between minimal and maximal retail prices) Hint: Because the rows in the BOOKS and PROMOTION tables don't contain equivalent values (pk and fk), you must use a non-equality join to determine which gift a customer receives during the promotion.

-- First Create VIEW for ‘book’ and publisher CREATE OR REPLACE VIEW book_profit_vu AS SELECT b.title, pu.name Publisher_Name, b.retail, b.retail-b.cost Profit FROM books b, publisher pu WHERE b.pubid = pu.pubid; SQL> SELECT * FROM book_profit_vu; TITLE PUBLISHER_NAME RETAIL PROFIT ------------------------------ ----------------------- ---------- ---------- REVENGE OF MICKEY PRINTING IS US 22 7.8 HOW TO MANAGE THE MANAGER PRINTING IS US 31.95 16.55 E-BUSINESS THE EASY WAY PUBLISH OUR WAY 54.5 16.6 BUILDING A CAR WITH TOOTHPICKS PUBLISH OUR WAY 59.95 22.15 HOLY GRAIL OF ORACLE AMERICAN PUBLISHING 75.95 28.7 DATABASE IMPLEMENTATION AMERICAN PUBLISHING 55.95 24.55 HANDCRANKED COMPUTERS AMERICAN PUBLISHING 25 3.2 COOKING WITH MUSHROOMS READING MATERIALS INC. 19.95 7.45 THE WOK WAY TO COOK READING MATERIALS INC. 28.75 9.75 HOW TO GET FASTER PIZZA READING MATERIALS INC. 29.95 12.1 BODYBUILD IN 10 MINUTES A DAY READING MATERIALS INC. 30.95 12.2 PAINLESS CHILD-REARING REED-N-RITE 89.95 41.95 BIG BEAR AND LITTLE DOVE REED-N-RITE 8.95 3.63 SHORTEST POEMS REED-N-RITE 39.95 18.1 14 rows selected.

-- use "NON-EQUALITY JOIN" (p.304) SELECT title, Publisher_name, retail, p.gift, TO_CHAR(profit, '$999.99') Proft FROM book_profit_vu bpvu, promotion p WHERE bpvu.retail BETWEEN p.minretail AND p.maxretail ORDER BY profit; column title format A23 COLUMN name format A18 column proft format $999.99 column retail format $999.99 column gift format A13 SELECT title, Publisher_name, retail, p.gift, TO_CHAR(profit, '$999.99') Proft FROM book_profit_vu bpvu, promotion p WHERE bpvu.retail BETWEEN p.minretail AND p.maxretail ORDER BY profit;

TITLE PUBLISHER_NAME RETAIL GIFT PROFT ----------------------- ----------------------- -------- ------------- -------- HANDCRANKED COMPUTERS AMERICAN PUBLISHING $25.00 BOOK LABELS $3.20 BIG BEAR AND LITTLE DOV REED-N-RITE $8.95 BOOKMARKER $3.63 E COOKING WITH MUSHROOMS READING MATERIALS INC. $19.95 BOOK LABELS $7.45 REVENGE OF MICKEY PRINTING IS US $22.00 BOOK LABELS $7.80 THE WOK WAY TO COOK READING MATERIALS INC. $28.75 BOOK COVER $9.75 HOW TO GET FASTER PIZZA READING MATERIALS INC. $29.95 BOOK COVER $12.10 BODYBUILD IN 10 MINUTES READING MATERIALS INC. $30.95 BOOK COVER $12.20 A DAY HOW TO MANAGE THE MANAG PRINTING IS US $31.95 BOOK COVER $16.55 ER E-BUSINESS THE EASY WAY PUBLISH OUR WAY $54.50 BOOK COVER $16.60 SHORTEST POEMS REED-N-RITE $39.95 BOOK COVER $18.10 BUILDING A CAR WITH TOO PUBLISH OUR WAY $59.95 FREE SHIPPING $22.15 THPICKS DATABASE IMPLEMENTATION AMERICAN PUBLISHING $55.95 BOOK COVER $24.55 HOLY GRAIL OF ORACLE AMERICAN PUBLISHING $75.95 FREE SHIPPING $28.70 PAINLESS CHILD-REARING REED-N-RITE $89.95 FREE SHIPPING $41.95 14 rows selected. GIFT MINRETAIL MAXRETAIL --------------- ---------- ---------- BOOKMARKER 0 12 BOOK LABELS 12.01 25 BOOK COVER 25.01 56 FREE SHIPPING 56.01 999.99

A Version without VIEW --1c.(TRADITIONAL JOIN; modified version from p.305) SELECT b.title, pu.name "Publisher Name", b.retail, p.gift, b.retail-b.cost proft FROM books b, publisher pu, promotion p WHERE b.pubid = pu.pubid AND b.retail BETWEEN p.minretail AND p.maxretail ORDER BY b.retail-b.cost;

DML Operations on a Simple View (continued) -- chapter 13, Figure 13-7; p.480 CREATE OR REPLACE VIEW inventory AS SELECT isbn, title, retail price FROM books; SELECT * FROM inventory WHERE title LIKE '%BODYBUILD%'; -- chapter 13, Figure 13-8; p.481 UPDATE inventory SET price = 49.95 WHERE title LIKE '%BODYBUILD%'; SELECT * FROM inventory FROM books

Rule for DML operations As long as the view isn’t created with the WITH READ ONLY option and any DML operation is allowed if it doesn’t violate an existing constraint on the underlying table. You can add, modify, and even delete data in an underlying table as long as one of the following constraints doesn’t prevent the operation: PRIMARY KEY - FOREIGN KEY UNIQUE - NOT NULL WITH CHECK OPTION Practice Figure 13-9 to 13-11 (pp.482-483)

Practice all the examples in the text. Exercises Practice all the examples in the text. A Script file is available on the Bb (file name: ch13Queries.sql) After completing all examples, do the HW. In-class Exercise #1 --1. CREATE VIEW contact AS SELECT contact, phone FROM publisher;

Homework - Hands-On Assignments Email me with one attachment (Oracle_ch13_Spool_Lname_Fname.) to: chen@jepson.gonzaga.edu with subject title of bmis441_Oracle_ch13 (or Bmis441-02_Oracle_ch13) Read and Practice all examples on Chapters 13 1. Read Oracle assignment and create a script file Oracle_ch13_Lname_Fname.sql for questions (#1-5 and 9,10; p.508) on “Hands-on Assignments”. 2. Execute and test one problem at a time and make sure they are all running successfully. 3. When you done, spool the script files (see next slide for spooling instructions) and UPLOAD script and spooled files (Oracle_ch13_Spool_Lname_Fname.txt) by the midnight before the next class.

How to Spool your Script and Output Files After you tested the script file of Oracle_ch13_Lname_Fname.sql successfully, follow the instructions below to spool both script and output files: Step 0. Run the following script file from SQL*Plus (since you have created JLDB tables) 1. type the following on SQL> Spool c:\oradata\Oracle_ch13B_Spool_Lname_Fname.txt (make sure your name is entered) 2. open Oracle_ch13_Lname_Fname.sql that you already tested 3. copy and paste all the SQL commands (including all comments) to the SQL*PLUS 4. type Spool Off on the SQL> The output should contain your personal information, all SQL commands and their solution on the .txt file and saved in C: drive (oradata\ folder) UPLOAD script and spooled files (*.sql and *.txt)

PART II

II. Creating a Complex View A complex view may contain data from multiple tables or data created with the GROUP BY clause, functions, or expressions Type of DML operations allowed depends on various factors

DML Operations on a Complex View with an Arithmetic Expression Figure 13-12 Create and update a complex view named prices

Rule#1: DML operations are not permitted if the view includes a column based on arithmetic expression Figure 13-14 Failed attempts to add a new book via the PRICES view -- chapter 13, Figure 13-15; p.488 INSERT INTO prices (isbn, title, cost, retail) VALUES(0202020202, 'A New Book', 8.95, 15.95);

Rule#2: DML operations are not permitted if they violate a constraint such as NOT NULL, UNIQUE etc. no pubid is inserted Figure 13-16 Constraint violation with an INSERT command via the PRICES view

DML Operations on a Complex View Containing Data from Multiple Tables DML operations cannot be performed on non-key-preserved tables, but they are permitted on key-preserved tables Figure 13-17 PRICES view with a table join Practice: Figure 13-18

DML Operations on a Complex View Containing Data from Multiple Tables (continued) Rule#3: DML operations can’t be performed on a non-key-preserved table. Figure 13-19 Failed attempt to update the publisher name via the PRICES view

DML Operations on a Complex View Containing Functions or Grouped Data Rule#4: DML operations are not permitted if the view includes a group function or a GROUP BY clause, the DISTINCT keyword, or the ROWNUM pseudocolumn. -- chapter 13, Figure 13-21; p.492 CREATE VIEW balancedue AS SELECT customer#, order#, SUM(quantity * retail) Amtdue FROM customers JOIN orders USING (customer#) JOIN orderitems USING (order#) JOIN books USING (isbn) GROUP BY customer#, order#; SELECT * FROM balancedue; Figure 13-21 View including grouped data

SELECT * FROM balancedue; Figure 13-21 View including grouped data

DML Operations on a Complex View Containing Functions or Grouped Data (continued) Figure 13-22 Failed DELETE command on a view with grouped data

Dropping a View Use DROP VIEW command Figure 13-25 Command to drop the PRICES view

III. Creating an Inline View An inline view is a temporary table created by using a subquery in the FROM clause It can only be referenced while the command is being executed Most common usage – “TOP-N” analysis

ORDER BY included to identify top values: “TOP-N” Analysis ORDER BY included to identify top values: Descending for highest values Ascending for lowest values Extract data based on ROWNUM Up to “N” rows returned Figure 13-26 Syntax of TOP-N analysis

“TOP-N” Analysis (continued) Figure 13-28 TOP-N analysis to identify the five most profitable books

Figure 13-28 TOP-N analysis to identify the five most profitable books Figure 13-28 TOP-N analysis to determine the three lest profitable books

Practice all the examples in the text. Exercises Practice all the examples in the text. A Script file is available on the Bb (file name: ch13Queries.sql) After completing all examples, do the HW. In-class Exercise #1 --1. CREATE VIEW contact AS SELECT contact, phone FROM publisher;

Homework - Hands-On Assignments Email me with one attachment (Oracle_ch13_Spool_Lname_Fname.) to: chen@jepson.gonzaga.edu with subject title of Bmis441-01_Oracle_ch13 (or Bmis441-02_Oracle_ch13) Read and Practice all examples on Chapters 13 1. Read Oracle assignment and create a script file Oracle_ch13_Lname_Fname.sql for questions (#1-5 and 9,10; p.508) on “Hands-on Assignments”. 2. Execute and test one problem at a time and make sure they are all running successfully. 3. When you done, spool the script files (see next slide for spooling instructions) and email the file (Oracle_ch13_Spool_Lname_Fname.txt) to me by the midnight before the next class.

How to Spool your Script and Output Files After you tested the script file of Oracle_ch13_Lname_Fname.sql successfully, follow the instructions below to spool both script and output files: Step 0. Run the following script file from SQL*Plus (since you have created JLDB tables) 1. type the following on SQL> Spool c:\oradata\Oracle_ch13B_Spool_Lname_Fname.txt (make sure your name is entered) 2. open Oracle_ch13_Lname_Fname.sql that you already tested 3. copy and paste all the SQL commands (including all comments) to the SQL*PLUS 4. type Spool Off on the SQL> The output should contain your personal information, all SQL commands and their solution on the .txt file and saved in C: drive (oradata\ folder) Email me with the spooled file (.txt) with attachment to: chen@jepson.gonzaga.edu with subject title of Bmis441-01_Oracle_ch13 (or Bmis441-02_Oracle_ch13)

PART III

Materialized Views Replicate data Store data retrieved from view query Referred to as “snapshots”

Materialized Views (continued) Figure 13-30 Creating a materialized view named CUSTBAL_MV

Figure 13-31 Query a materialized view

Materialized Views (continued) Figure 13-32 Drop a materialized view

Summary A view is a temporary or virtual table that is used to retrieve data that exists in the underlying database tables The view query must be executed each time the view is used A view can be used to simplify queries or to restrict access to sensitive data A view is created with the CREATE VIEW command A view cannot be modified; to change a view, it must be dropped and then re-created, or the CREATE OR REPLACE VIEW command must be used

Summary (continued) Any DML operation can be performed on a simple query if it does not violate a constraint A view that contains expressions or functions, or that joins multiple tables, is considered a complex view A complex view can be used to update only one table; the table must be a key-preserved table Data cannot be added to a view column that contains an expression DML operations are not permitted on non-key-preserved tables

Summary (continued) DML operations are not permitted on views that include group functions, a GROUP BY clause, the ROWNUM pseudocolumn, or the DISTINCT keyword Oracle 11g assigns a row number to every row in a table to indicate its position in the table; the row number can be referenced by the keyword ROWNUM A view can be dropped with the DROPVIEW command; the data is not affected, because it exists in the original tables An inline view can be used only by the current statement and can include an ORDER BY clause “TOP-N” analysis uses the row number of sorted data to determine a range of top values Materialized views physically store view query results