CS240A: Databases and Knowledge Bases Applications of Active Database Carlo Zaniolo Department of Computer Science University of California, Los Angeles.

Slides:



Advertisements
Similar presentations
Fall 2005 ICS184/EECS116 – Notes 08 1 ICS 184/EECS116: Introduction to Data Management Lecture Note 8 SQL: Structured Query Language -- DDL.
Advertisements

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification.
Database Management System
Chapter 3 The Relational Model Transparencies © Pearson Education Limited 1995, 2005.
Triggers and Active Databases CS561. Practical Applications of Triggers and Constraints: Successes and Lingering Issues Stefano Ceri Roberta J. Cochrane.
Database Systems: A Practical Approach to Design, Implementation and Management International Computer Science S. Carolyn Begg, Thomas Connolly Lecture.
The SQL Query Language DML1 The SQL Query Language DML Odds and Ends.
Database Management: Getting Data Together Chapter 14.
Fundamentals, Design, and Implementation, 9/e Chapter 11 Managing Databases with SQL Server 2000.
CS 240A: Databases and Knowledge Bases Analysis of Active Databases Carlo Zaniolo Department of Computer Science University of California, Los Angeles.
Chapter 3. 2 Chapter 3 - Objectives Terminology of relational model. Terminology of relational model. How tables are used to represent data. How tables.
Overview Distributed vs. decentralized Why distributed databases
Accounting Databases Chapter 2 The Crossroads of Accounting & IT
Chapter 1 An Overview of Database Management. 1-2 Topics in this Chapter What is a Database System? What is a Database? Why Database? Data Independence.
Triggers and Active Databases Alexandra Klenova Meghan Russ Josh Sunshine Abe Weinograd.
Chapter 1 Introduction to Databases
Team Dosen UMN Physical DB Design Connolly Book Chapter 18.
Chapter 7 Constraints and Triggers Spring 2011 Instructor: Hassan Khosravi.
Chapter 4 The Relational Model Pearson Education © 2014.
Chapter 4 The Relational Model.
Database Design - Lecture 1
CS 240A: Databases and Knowledge Bases Introduction to Active Databases Carlo Zaniolo Department of Computer Science University of California, Los Angeles.
Database Management Systems, 2 nd Edition. R. Ramakrishnan and J. Gehrke1 Data Warehousing and Decision Support Chapter 25, Part B.
Triggers Event handlers in the DBMS. Triggers are event handlers Triggers a executed when an event happens in the DBMS Example events – INSERT, UPDATE.
RDB/1 An introduction to RDBMS Objectives –To learn about the history and future direction of the SQL standard –To get an overall appreciation of a modern.
Chapter 16 Methodology – Physical Database Design for Relational Databases.
SQL Server 7.0 Maintaining Referential Integrity.
Part Two: - The use of views. 1. Topics What is a View? Why Views are useful in Data Warehousing? Understand Materialised Views Understand View Maintenance.
1 ICS 184: Introduction to Data Management Lecture Note 11: Assertions, Triggers, and Index.
Database Design and Management CPTG /23/2015Chapter 12 of 38 Functions of a Database Store data Store data School: student records, class schedules,
Database Management System (DBMS) an Introduction DeSiaMore 1.
Relational Database. Database Management System (DBMS)
Triggers. Why Triggers ? Suppose a warehouse wishes to maintain a minimum inventory of each item. Number of items kept in items table Items(name, number,...)
CS240A: Databases and Knowledge Bases Recursive Queries in SQL 1999 Carlo Zaniolo Department of Computer Science University of California, Los Angeles.
Methodology – Physical Database Design for Relational Databases.
Advanced SQL: Triggers & Assertions
Topics Related to Attribute Values Objectives of the Lecture : To consider sorting relations by attribute values. To consider Triggers and their use for.
1 CS 430 Database Theory Winter 2005 Lecture 4: Relational Model.
Ing. Erick López Ch. M.R.I. Replicación Oracle. What is Replication  Replication is the process of copying and maintaining schema objects in multiple.
CS 240A: Databases and Knowledge Bases Introduction to Active Databases Carlo Zaniolo Department of Computer Science University of California, Los Angeles.
Chapter 5 : Integrity And Security  Domain Constraints  Referential Integrity  Security  Triggers  Authorization  Authorization in SQL  Views 
The Relational Model. 2 Relational Model Terminology u A relation is a table with columns and rows. –Only applies to logical structure of the database,
1 Intro stored procedures Declaring parameters Using in a sproc Intro to transactions Concurrency control & recovery States of transactions Desirable.
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Relational State Assertions These slides.
CS 240A: Databases and Knowledge Bases Analysis of Active Databases Carlo Zaniolo Department of Computer Science University of California, Los Angeles.
The Relational Model © Pearson Education Limited 1995, 2005 Bayu Adhi Tama, M.T.I.
CS240A: Databases and Knowledge Bases TSQL2 Carlo Zaniolo Department of Computer Science University of California, Los Angeles Notes From Chapter 6 of.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 1 Database Systems.
Constraints and Views Chap. 3-5 continued (7 th ed. 5-7)
Chapter 4 The Relational Model Pearson Education © 2009.
SQL Triggers, Functions & Stored Procedures Programming Operations.
LECTURE TWO Introduction to Databases: Data models Relational database concepts Introduction to DDL & DML.
Copyright © 2004 Pearson Education, Inc.. Chapter 24 Enhanced Data Models for Advanced Applications.
7.5 Using Stored-Procedure and Triggers NAME MATRIC NUM GROUP Muhammad Azwan Bin Khairul Anwar CS2305A Muhammad Faiz Bin Badrol Shah CS2305B.
Chapter Name Replication and Mobile Databases Transparencies
Chapter 1: Introduction
Chapter 13 The Data Warehouse
Introduction to Database Systems, CS420
Rules in active databases and integrity constraints
Generalization.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Advanced SQL: Views & Triggers
The Relational Model Transparencies
Data Model.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 11 Managing Databases with SQL Server 2000
Presentation transcript:

CS240A: Databases and Knowledge Bases Applications of Active Database Carlo Zaniolo Department of Computer Science University of California, Los Angeles January 2002 Notes From Ch 3 of Advanced Database Systems by Zaniolo, Ceri, Faloutsos, Snodgrass, Subrahmanian and Zicari Morgan Kaufmann, 1997

A Taxonomy of Active Rule Applications  Internal to the database:  Integrity constraint maintenance  Support of data derivation (including data replication).  Extended functionalities (used in many applications):  Workflow management systems  Version managers  Event tracking and logging  Security administration  Business Rules (application specific):  Trading rules for the bond market  Warehouse and inventory management  Energy management rules

Internal VS Extended Rules  Perform classical DBMS functions  Can be approached with structured approaches and techniques  Can be automatically or semi­automatically generated  Can be declaratively specified

Declarative Design of Active Rules for Integrity and View Maintenance  Internal applications of active databases are:  Static  Declarative  High­level, easy to understand  Approach  User specifies application at declarative (high) level  System derives low­level rules that implement it  automatically  or semi­automatically

Framework  Rules should be programmed by DBA  Rule programming should be assisted by rule design tools  Rule derivation can be:  Completely automatic (for few well­defined problems)  Partially automatic—requiring some interaction with users

Integrity Constraint Maintenance  Constraints are static conditions  Every employee's department exists  Every employee's salary is between 30 and 100  Rules monitor dynamic database changes to enforce constraints  when change to employees or departments if an employee's department doesn't exist then fix the constraint  when change to employee salaries if a salary is not between 30 and 100 then fix the constraint  Generalizing:  when potentially invalidating operations  if constraint violated  then fix it

Integrity­Preserving Rules Constraint: condition C  Rules(s): when operations that could make C become false if C is false then make C true or abort transaction Example: C = every employee's department must exist Operations = insert into emp, delete from dept, update to emp.deptno, update to dept.dno  Condition:  There is some employee violating C (due to those ops)  Action: make C true  Rollback insertion of emp  Rollback deletion of dept  Put emp into a dummy dept

Example: Referential Integrity  Constraint: EXISTS (SELECT * FROM Dept WHERE Dno = Emp.Deptno)  Denial form: NOT EXISTS (SELECT * FROM Dept WHERE Dno = Emp.Deptno)  Abort Rules CREATE RULE DeptEmp1 ON Emp WHEN INSERTED,UPDATED(Deptno) IF EXISTS (SELECT * FROM Emp WHERE NOT EXISTS (SELECT * FROM Dept WHERE Dno = Emp.DeptNo)) THEN ROLLBACK CREATE RULE DeptEmp2 ON Dept WHEN DELETED, UPDATED(Dno) IF EXISTS (SELECT * FROM Emp WHERE NOT EXISTS (SELECT * FROM Dept WHERE Dno = Emp.DeptNo)) THEN ROLLBACK

Referential Integrity using Repair Rules for EMP CREATE RULE DeptEmp1 ON Emp WHEN INSERTED IF EXISTS ( SELECT * FROM INSERTED WHERE NOT EXISTS (SELECT * FROM Dept WHERE Dno =Emp.DeptNo)) THEN UPDATE Emp SET DeptNo = NULL WHERE EmpNo IN (SELECT EmpNo FROM INSERTED) AND NOT EXISTS (SELECT * FROM Dept WHERE Dno = Emp.DeptNo))

Repair Rules for EMP (cont.) CREATE RULE DeptEmp2 ON Emp WHEN UPDATED(Deptno) IF EXISTS (SELECT * FROM NEW­UPDATED WHERE NOT EXISTS (SELECT * FROM Dept WHERE Dno = Emp.DeptNo)) THEN UPDATE Emp SET DeptNo = 99 WHERE EmpNo IN (SELECT EmpNo FROM NEW­UPDATED) AND NOT EXISTS (SELECT * FROM Dept WHERE Dno = Emp.DeptNo))

Repair Rule for Dept  See Chapter 3 of ADS textbook

View Maintenance  Logical tables derived from base tables  Portion of database specified by retrieval query  Used to provide different abstraction levels---similar to external schemas. Referenced in retrieval queries.  Virtual views  Not physically stored  Implemented by query modification  Materialized views  Physically stored  Kept consistent with base tablesee Chapter 2 of textbook

Virtual Views  Views define derived data by static database queries Table high­paid = All employees with high salaries  Virtual views are not stored in the database  Rules dynamically detect queries on virtual views and transform into queries on base tables: When retrieve from high­paid then retrieve from emp where sal > X

Materialized Views  Rules(s): when operations happen that can change the result of Q then modify V  How to generate rule(s) from view?  Generate triggering operations by analyzing Q  Example: V = all employees with high salaries  Ops = insert into emp, delete from emp, update emp.sal  Generate action to modify V 1. Evaluate query Q, set V = result 2. Evaluate Q using changed values, update V 3. Determine if you can use 2 or have to use 1 by analyzing Q

Materialized Views (cont.) define view V as select Cols from Tables where Predicate  Materialized initially, stored in database  Refreshed at rule processing points Changes to base tables => View­Maintaining Rules  Recomputation approach (easy but bad)  when changes to base table then recompute view  Incremental approach (better but harder an not always applicable)  when changes to base tables then change view  Incremental rules is difficult in the presence of duplicates and certain base table operations

Example  Relational view selecting departments with one employee who earns more than 50,000 DEFINE VIEW HighPaidDept AS (SELECT DISTINCT Dept.Name FROM Dept, Emp WHERE Dept.Dno = Emp.Deptno AND Emp.Sal > 50K)  Critical events 1. insertions into Emp 2. insertions into Dept 3. deletions from Emp 4. deletions from Dept 5. updates to Emp.Deptno 6. updates toEmp.Sal 7. updates to Dept.Dno

Refresh Rules written in Starburst CREATE RULE RefreshHighPaidDept1 ON Emp WHEN INSERTED, DELETED, UPDATED(Deptno), UPDATED(Sal) THEN DELETE * FROM HighPaidDept; INSERT INTO HighPaidDept: (SELECT DISTINCT Dept.Name FROM Dept, Emp WHERE Dept.Dno = Emp.Deptno AND Emp.Sal > 50K ) CREATE RULE RefreshHighPaidDept2 ON Dept WHEN INSERTED, DELETED, UPDATED(Dno) THEN DELETE * FROM HighPaidDept; INSERT INTO HighPaidDept: (SELECT DISTINCT Dept.Name FROM Dept, Emp WHERE Dept.Dno = Emp.Deptno AND Emp.Sal > 50K) _______________________________________ Dept and Emp are switched in the ADS book

Incremental Refresh Rules  Incremental refresh rule for Insert on Dept: CREATE RULE IncrRefreshHighPaidDept1 ON Dept WHEN INSERTED THEN INSERT INTO HighPaidDept: (SELECT DISTINCT Dept.Name FROM INSERTED, Emp WHERE INSERTED.Dno = Emp.Deptno AND Emp.Sal > 50K)  This rule is not needed if there is a FK constraint from Emp to Dept  Incremental refresh rules for Insert on Emp ?  Incremental refresh rules for Delete on Dept?  Incremental refresh rules for Delete on Emp ?

Replication  A special case of data derivation (identical copies).  Main application: distributed systems (copies on different servers).  Typical approach: asynchronous.  Capture Step: Active rules react to changes on one copy and collect changes into deltas.  Apply step: Deltas are propagated to other copies at the appropriate time.  Alternatives:  Primary­Secondary  Symmetric

Active Rules for Replication: capture rules CREATE RULE Capture1 ON Primary WHEN INSERTED THEN INSERT INTO PosDelta (SELECT * FROM INSERTED) CREATE RULE Capture2 ON Primary WHEN DELETED THEN INSERT INTO NegDelta (SELECT * FROM DELETED) CREATE RULE Capture3 ON Primary WHEN UPDATED THEN INSERT INTO PosDelta (SELECT * FROM NEW­UPDATED); INSERT INTO NegDelta (SELECT * FROM OLD­UPDATED)

Workflow Management  A new paradigm for organizing the working activities within enterprise.  Intrinsically reactive: workflow managers monitor events and perform the required event management activities.  Two types of events:  Internal: generated from within the workflow manager while workflows are progressing.  External: representing the interaction of the workflowmanager with the external world.  The most significant application of rules:  expressing exceptions to the normal flow.  Example: Energy management system.