Views-basics 1. 2 Introduction a view is a perspective of the database different users may need to see the database differently; this is achieved through.

Slides:



Advertisements
Similar presentations
0 - 0.
Advertisements

ALGEBRAIC EXPRESSIONS
Addition Facts
Relational data objects 1 Lecture 6. Relational data objects 2 Answer to last lectures activity.
Introduction to Relational Database Systems 1 Lecture 4.
Introduction to SQL 1 Lecture 5. Introduction to SQL 2 Note in different implementations the syntax might slightly differ different features might be.
The ANSI/SPARC Architecture of a Database Environment
Query optimisation.
Active database concepts
Relational operators 1 Lecture 7 Relational Operators.
Limitations of the relational model 1. 2 Overview application areas for which the relational model is inadequate - reasons drawbacks of relational DBMSs.
Relational data integrity
Data manipulation operations on views 1. 2 Outline retrieval operations in theory in practice (SQL92 and PostgreSQL) update operations in theory - basics.
1 Term 2, 2004, Lecture 6, Views and SecurityMarian Ursu, Department of Computing, Goldsmiths College Views and Security 3.
1 Term 2, 2004, Lecture 9, Distributed DatabasesMarian Ursu, Department of Computing, Goldsmiths College Distributed databases 3.
Access Control & Views Reading: C&B, Chap 7. Dept of Computing Science, University of Aberdeen2 In this lecture you will learn the principles of object.
Data Definition and Integrity Constraints
Dr. Alexandra I. Cristea CS 252: Fundamentals of Relational Databases: SQL5.
Surgery OR Procedure Card Database David L. Odom 1. Secure Password into Database:
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
9 Copyright © 2004, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
9 Creating and Managing Tables. Objectives After completing this lesson, you should be able to do the following: Describe the main database objects Create.
1 Chapter 12 Data Manipulation Language (DML) View Dr. Chitsaz Objectives Definition Create a view Retrieve data from a view Insert, delete, update to/from.
Creating Tables. 2 home back first prev next last What Will I Learn? List and provide an example of each of the number, character, and date data types.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification.
Past Tense Probe. Past Tense Probe Past Tense Probe – Practice 1.
Fundamentals of Database Systems Fourth Edition El Masri & Navathe
Addition 1’s to 20.
Test B, 100 Subtraction Facts
Week 1.
Chapter 15 A Table with a View: Database Queries.
13 Copyright © Oracle Corporation, All rights reserved. Controlling User Access.
SQL Subqueries Objectives of the Lecture : To consider the general nature of subqueries. To consider simple versus correlated subqueries. To consider the.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification.
Midterm Review Lecture 14b. 14 Lectures So Far 1.Introduction 2.The Relational Model 3.Disks and Files 4.Relational Algebra 5.File Org, Indexes 6.Relational.
Database Systems More SQL Database Design -- More SQL1.
View and Materialized view. What is a view? Logically represents subset of data from one or more table. In sql, a view is a virtual relation based on.
Security and Integrity
CSC271 Database Systems Lecture # 6. Summary: Previous Lecture  Relational model terminology  Mathematical relations  Database relations  Properties.
CSE314 Database Systems More SQL: Complex Queries, Triggers, Views, and Schema Modification Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson.
Normalization (Codd, 1972) Practical Information For Real World Database Design.
Chapter 10 Views. Topics in this Chapter What are Views For? View Retrievals View Updates Snapshots SQL Facilities.
1 Information Retrieval and Use (IRU) CE An Introduction To SQL Part 1.
Views In some cases, it is not desirable for all users to see the entire logical model (that is, all the actual relations stored in the database.) In some.
INFO1408 Database Design Concepts Week 15: Introduction to Database Management Systems.
Outline Introduction Basic SQL Setting Up and Using PostgreSQL
Chapter 2 Views. Objectives ◦ Create simple and complex views ◦ Creating a view with a check constraint ◦ Retrieve data from views ◦ Data manipulation.
1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.
IS 230Lecture 6Slide 1 Lecture 7 Advanced SQL Introduction to Database Systems IS 230 This is the instructor’s notes and student has to read the textbook.
11-1 Copyright  Oracle Corporation, All rights reserved. What Are Constraints? Constraints enforce rules at the table level. Constraints prevent.
Indexes and Views Unit 7.
Chapter 5 : Integrity And Security  Domain Constraints  Referential Integrity  Security  Triggers  Authorization  Authorization in SQL  Views 
Mining real world data RDBMS and SQL. Index RDBMS introduction SQL (Structured Query language)
Chapter 10 Views. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.10-2 Topics in this Chapter What are Views For? View Retrievals View Updates.
Views Prof. Yin-Fu Huang CSIE, NYUST Chapter 10. Advanced Database System Yin-Fu Huang 10.1Introduction Example: Var Good_Supplier View (S Where Status.
Constraints and Views Chap. 3-5 continued (7 th ed. 5-7)
SQL- Updates, Assertions and Views. Data Definition, Constraints, and Schema Changes Used to CREATE, DROP, and ALTER the descriptions of the tables (relations)
More SQL: Complex Queries, Triggers, Views, and Schema Modification
More SQL: Complex Queries,
Chapter 10 Views.
Physical Changes That Don’t Change the Logical Design
Views.
What Is a View? EMPNO ENAME JOB EMP Table EMPVU10 View
Chapter 2 Views.
More SQL: Complex Queries, Triggers, Views, and Schema Modification
Chapter 2 Views.
IST 318 Database Administration
SQL-Views and External Schemas
Views.
Presentation transcript:

Views-basics 1

2 Introduction a view is a perspective of the database different users may need to see the database differently; this is achieved through the view mechanism a view is part of the external level remember the three level architecture: internal, conceptual and external

Views-basics 3 Introduction view = a named relational expression suppose Employee ( Emp_Id, Name, Address, Salary, Dept_id ) Department (Dept_id, Manager, Budget, Office ) then views can be defined as SELECT Name, Salary, Dept_id FROM Employee WHERE Salary > 35 SELECT Name, Employee.Dept_id FROM Employee, Department WHERE Budget > 1500 AND Employee.Dept_id = Department.Dept_id

Views-basics 4 View - a window to the database the database - a set of base tables

Views-basics 5 View named expression of relational algebra (calculus) relational closure virtual relation substitution process

Views-basics 6 Data definition for views in SQL CREATE VIEW [ ] AS [WITH CHECK OPTION] ; DROP VIEW ; ::= RESTRICT | CASCADE

Views-basics 7 SQL views - vertical and horizontal --vertical view CREATE VIEW Emp AS SELECT Emp_Id, Name, Address, Dept_id FROM Employee ; --supposing that the salary is confidential --horizontal view CREATE VIEW GoodEmp AS SELECT Emp_id, Name, Address, Salary, Dept_id FROM Employee WHERE Salary > 45 ;

Views-basics 8 SQL views - join --an employee is safe if s/he works for a rich department CREATE VIEW SafeEmployees AS SELECTName, Employee.Dept_id FROM Employee, Department WHERE Budget > 1500 AND Employee.Dept_id = Department.Dept_id

Views-basics 9 SQL views - aggregate functions CREATE VIEW TotSalPerDept AS SELECTDept_id, SUM(Salary) AS TotSal FROM Employee GROUP BY Dept_id

Views-basics 10 Using views views are used as if they were base relations from the point of view of the user, a view is the same as a base relation however, certain restrictions exist e.g. see next slide

Views-basics 11 SQL restrictions on views in a view, a column that is based on an aggregate function cannot be subject to an aggregate function or to a WHERE clause (e.g. TotSal before) a grouped view may never be joined with a base table or another view

Views-basics 12 WITH CHECK OPTION only for updateable views migrating rows a row of a view, after being updated, may not satisfy the condition of the view anymore, therefore it will migrate out of the view WITH CHECK OPTION avoids such situations; the update is not permitted if the row will no longer satisfy the condition of the defining query

Views-basics 13 View resolution view = virtual relation view = expression that is evaluated every time it is used evaluating an expression on a view = view resolution view resolution substitution

Views-basics 14 Activity Consider a view definition and a query on this view. Explain how (do you think) the expression is evaluated.

Views-basics 15 Advantages logical data independence users and user programs are immune to changes in the logical structure of the DB to what extent logical data independence can be guaranteed? restructuring tables : add/delete columns, change key definition, change integrity constraints, rename columns/tables, split tables,...

Views-basics 16 Advantages automatic/improved security reduced complexity through macro facility customisation the same data can be seen differently by users through macro facility data integrity –WITH CHECK OPTION

Views-basics 17 Disadvantages update restriction will see in more detail next lecture structure restriction performance

Views-basics 18 Activity Find out, through experiments, to what extent logical data independence is provided in Postgres some changes on base relations or on the views used in other views definitions can be made without requiring the redefinition of the views some other changes require view redefinition, but the structure (and name) of the view can stay the same