1 Context “Updating Union, Intersection and Difference views” - introduces a systematic approach to updating a view formed specifically by using  Union.

Slides:



Advertisements
Similar presentations
Data manipulation operations on views 1. 2 Outline retrieval operations in theory in practice (SQL92 and PostgreSQL) update operations in theory - basics.
Advertisements

Rasool Jalili; 2 nd semester ; Database Security, Sharif Uni. of Tech. The Jajodia & Sandhu model Jajodia & Sandhu (1991), a model for the application.
The Hierarchical Model
The Relational Model and Relational Algebra Nothing is so practical as a good theory Kurt Lewin, 1945.
 Definition  Components  Advantages  Limitations Contents  Definition Definition  Normal Forms Normal Forms  First Normal Form First Normal Form.
1 Constraints, Triggers and Active Databases Chapter 9.
Relational Database Design UNIT II 1. 2 Advantages of Using Database Systems Centralized control of a firm’s data Redundancy can be reduced (avoid keeping.
CS240A: Databases and Knowledge Bases From Deductive Rules to Active Rules Carlo Zaniolo Department of Computer Science University of California, Los Angeles.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 SQL: Queries, Programming, Triggers Chapter 5 Modified by Donghui Zhang.
RJP/RDA 1 /93 Relational Data Analysis (RDA) RDA organises all the system’s data items into a set of well NORMALISED relations. These should avoid: 1.
Fall 2005 ICS184/EECS116 – Notes 08 1 ICS 184/EECS116: Introduction to Data Management Lecture Note 8 SQL: Structured Query Language -- DDL.
SQL Constraints and Triggers
Constraints and Triggers Foreign Keys Local and Global Constraints Triggers.
Triggers The different types of integrity constraints discussed so far provide a declarative mechanism to associate “simple” conditions with a table such.
Chapter 8 Normal Forms Based on Functional Dependencies Deborah Costa Oct 18, 2007.
Chapter 3 An Introduction to Relational Databases.
I.1 ii.2 iii.3 iv.4 1+1=. i.1 ii.2 iii.3 iv.4 1+1=
I.1 ii.2 iii.3 iv.4 1+1=. i.1 ii.2 iii.3 iv.4 1+1=
10/3/2000SIMS 257: Database Management -- Ray Larson Relational Algebra and Calculus University of California, Berkeley School of Information Management.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 157 Database Systems I SQL Constraints and Triggers.
LOGICAL DATABASE DESIGN
Transforming Data Models into Database Designs
Module Title? DBMS E-R Model to Relational Model.
Week 6 Lecture Normalization
CSC 280: INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS Dr. Adam Anthony Fall 2012.
1 What is database 2? What is normalization? What is SQL? What is transaction?
Chapter 10 Views. Topics in this Chapter What are Views For? View Retrievals View Updates Snapshots SQL Facilities.
Natural vs. Generated Keys. Definitions Natural key—a key that occurs in the data, that uniquely identifies rows. AKA candidate key. Generated key—a key.
SQL (DDL & DML Commands)
1 ICS 184: Introduction to Data Management Lecture Note 11: Assertions, Triggers, and Index.
Database Management COP4540, SCS, FIU Constraints and security in SQL (Ch. 8.6, Ch22.2)
The Relational Algebra. 1 Relational Algebra Operations From Set Theory * UNIONUNION * INTERSECTIONINTERSECTION * MINUSMINUS * CARTESIAN OPERATIONCARTESIAN.
Normalization Ioan Despi 2 The basic objective of logical modeling: to develop a “good” description of the data, its relationships and its constraints.
FEN Introduction to the database field:  The Relational Model Seminar: Introduction to relational databases.
For Project 1, Deliverable 4, you will add referential integrity (FOREIGN KEY) constraints to existing tables, as well as composing general assertions.
Unit III. Views A table that is derived from other tables Considered as a virtual table Does not store data.
Fall 2001Database Systems1 Triggers Assertions –Assertions describe rules that should hold for a given database. –An assertion is checked anytime a table.
Advanced SQL: Triggers & Assertions
Dec 8, 2003Murali Mani Constraints B term 2004: lecture 15.
Advanced Relational Algebra & SQL (Part1 )
1 CS 430 Database Theory Winter 2005 Lecture 4: Relational Model.
COMP3030 Database Management System Final Review
Chapter 5 : Integrity And Security  Domain Constraints  Referential Integrity  Security  Triggers  Authorization  Authorization in SQL  Views 
Presentation by: Tim Sablik.  There are two basic types of operations that will be addressed:  Unary operations are applied to only one relation. 
Functional dependency: a relationship between two attributes (or sub-sets of attributes) in a relational database, such that the value of the first attribute.
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.
SQL advanced select using Oracle 1 Multiple Tables: Joins and Set Operations Subqueries: Nested Queries.
Ch 7: Normalization-Part 1
N-ary Relations & Their Applications. 2 n-ary Relations Let A 1, A 2, …, A n be sets. An n-ary relation on these sets is a subset of A 1 x A 2 x … x A.
IMS 4212: Constraints & Triggers 1 Dr. Lawrence West, Management Dept., University of Central Florida Stored Procedures in SQL Server.
Chapter 8 Relational Database Design. 2 Relational Database Design: Goals n Reduce data redundancy (undesirable replication of data values) n Minimize.
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.
NormalisationNormalisation Normalization is the technique of organizing data elements into records. Normalization is the technique of organizing data elements.
Databases Introduction - concepts. Concepts of Relational Databases.
NORMALIZATION Handout - 4 DBMS. What is Normalization? The process of grouping data elements into tables in a way that simplifies retrieval, reduces data.
Chapter 8 Advanced SQL. Relational Set Operators UNIONINTERSECTMINUS Work properly if relations are union- compatible –Names of relation attributes must.
SQL- Updates, Assertions and Views. Data Definition, Constraints, and Schema Changes Used to CREATE, DROP, and ALTER the descriptions of the tables (relations)
1 The Relational Data Model David J. Stucki. Relational Model Concepts 2 Fundamental concept: the relation  The Relational Model represents an entire.
Chapter 3 An Introduction to Relational Databases.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 The Relational Data Model and Relational Database Constraints تنبيه.
Chapter 6: Integrity (and Security)
Chapter 10 Views.
Quiz Questions Q.1 An entity set that does not have sufficient attributes to form a primary key is a (A) strong entity set. (B) weak entity set. (C) simple.
STRUCTURE OF PRESENTATION :
SQL Views CS542.
Advanced SQL: Views & Triggers
Database Design: Relational Model
ISC321 Database Systems I Chapter 4: SQL: Data definition, Constraints, and Basic Queries and Updates Fall 2015 Dr. Abdullah Almutairi.
So What are Views and Triggers anyway?
Presentation transcript:

1 Context “Updating Union, Intersection and Difference views” - introduces a systematic approach to updating a view formed specifically by using  Union  Intersection  Difference operators

2 Updating a Table The predicate of a table represents the criterion for update acceptability for that table. Ex. Let the meaning (or the predicate) of base table EMP be the following: e.EMP# in EMP# domain AND e.ENAME in NAME domain AND e.DEPT# in DEPT# domain AND e.SALARY in US CURRENCY domain AND IF e.DEPT# = 'D1' THEN e.SALARY < 44K EMP# is the primary key Try : 1. Insert a tuple (‘E5’, ‘Lopez’, ‘D1’, 20K)  Insert OK. 2. Update the above tuple and make salary = 50K  Update FAILED.

3 Updating a View A view is nothing but a derived table A view can updated only if the predicate of the view is satisfied

4 Updating a Union View CREATE VIEW UV AS (SELECT * FROM EMP WHERE DEPT# = ‘D1’) A UNION (SELECT * FROM EMP WHERE SALARY > 30K) ---- B Table : 1 EMP Table : 4 VIEW UV(A UNION B) Table : 2 VIEW A Table : 3 VIEW B

5 Updating a Union View…Contd. I. Insert : The new row is inserted if it satisfies either PA or PB or both. Caution : The new row must not already appear in either A or B, because otherwise we would be trying to insert a row that already exists. Ex. 1. Insert (E5,Smith,D1,20K). This row satisfies PA though not PB. It is therefore inserted into A i.e effectively, inserted into the EMP base table. 2. Insert (E6,Jones,D1,40K). This row satisfies PA and PB. It is therefore logically inserted into both, effectively only once into the EMP base table

6 Updating Union View … Contd. II. Delete : If the row to be deleted appears in A, it is deleted from A. If it (still) appears in B, it is deleted from B. Ex. 1. Delete (E1,JOHN, D1, 20K) -> Present in A, deleted from A 2. Delete (E3,JAMES,D1,40K) -> Present in A, deleted from A.

7 Updating Union View … Contd. III. Update : The row to be updated must be such that the updated version satisfies PA or PB or both. Note : Update is accomplished by deleting the old record and then inserting a new record Ex. Update(E1,JOHN,D1,20K) to (E1,JOHN,D2,40K) 1. Delete from A, if it appears in A, without performing triggered actions.(such as cascade delete and so on) 2. Delete from B, if it (still) appears in B 3. If the updated version of the row satisfies PA, it is inserted into A. 4. Finally, if the updated version satisfies PB, it is inserted into B, unless it was inserted into B already as a side-effect of inserting it into A.

8 Updating Intersection Views I. Insert: The new row must satisfy both PA and PB. If it does not currently appear in A, it is inserted into A. If it (still) does not appear in B, it is inserted into B. II. Delete: The row to be deleted is deleted from A. If it (still) appears in B, it is deleted from B. III. Update: The row to be updated must be such that the updated version satisfies both PA and PB. CREATE VIEW IV AS (SELECT * FROM EMP WHERE DEPT# = ‘D1’) A INTERSECT (SELECT * FROM EMP WHERE SALARY > 30K) ---- B

9 Updating Difference Views I. Insert: The new row must satisfy PA and not PB. It is inserted into A II. Delete: The row to be deleted is deleted from A. III. Update : The row to be updated must be such that the updated version satisfies PA and not PB. The row is deleted from A and the updated version of the row is then inserted into A CREATE VIEW DV AS (SELECT * FROM EMP WHERE DEPT# = ‘D1’) A MINUS (SELECT * FROM EMP WHERE SALARY > 30K) ---- B

10 Comments A systematic approach to view update problem It adheres to the semantics of the data and is thus database- independent.

11 Reference Date, C. J. and McGoveran, D.O. : “Updating Union, Intersection and Difference Views”, Database Programming & Design 7, No. 6 (June 1994)