Database Management System Lecture - 39 © Virtual University of Pakistan
© Virtual University of Pakistan Index Classification Clustered vs. unclustered: If order of data records is the same as order of index data entries, then called clustered index. © Virtual University of Pakistan
© Virtual University of Pakistan Index Classification A file can be clustered on at most one search key. Cost of retrieving data records through index varies greatly based on whether index is clustered or not! © Virtual University of Pakistan
Clustered vs. Unclustered Index Index entries direct search for data entries Data entries Data entries (Index File) (Data file) Data Records Data Records © Virtual University of Pakistan
© Virtual University of Pakistan When to Use Indexes Useful on large tables Required on PK Useful for attributes appearing in where, order by and group by clauses © Virtual University of Pakistan
© Virtual University of Pakistan When to use Significant variety in values Check the limit of indexes with your DBMS Make your decision very much justifiable; indexes introduce overhead © Virtual University of Pakistan
© Virtual University of Pakistan Indexes Summary Useful tool to speedup the data access Can be unique or non-unique Can be implemented through different techniques Be careful; they involve overhead © Virtual University of Pakistan
© Virtual University of Pakistan Views © Virtual University of Pakistan
© Virtual University of Pakistan Definition A view is defined to combine certain data from one or more tables for different reasons A view is like a window through which we can see data from one or more tables © Virtual University of Pakistan
© Virtual University of Pakistan Why Views? Security Show the data to a users’ group that is necessary/required for them Give only necessary authorizations No concern with rest of the data © Virtual University of Pakistan
© Virtual University of Pakistan Why Views? Efficiency Part of a query that is frequently used (a subquery), define it as a view The view definition will be stored and will be executed anytime anywhere view is referred © Virtual University of Pakistan
© Virtual University of Pakistan Why Views? Join columns from multiple tables so that they look like a single table Aggregate information instead of supplying details © Virtual University of Pakistan
Characteristics of Views Not exactly the external views of 3-level schema architecture Major Types Dynamic Materialized Partitioned Simple/complex © Virtual University of Pakistan
© Virtual University of Pakistan Dynamic Views Data is not stored for the views Definition is stored in the schema Executed every time view is referred © Virtual University of Pakistan
Defining Dynamic Views CREATE VIEW [ < database_name > . ] [ < owner > . ] view_name [ ( column [ ,...n ] ) ] [ WITH ENCRYPTION | SCHEMABINDING [ ,...n ] ] AS select_statement [ WITH CHECK OPTION ] © Virtual University of Pakistan
Database Management System Lecture - 39 © Virtual University of Pakistan