Similar documents
Elena Baralis, Silvia Chiusano Politecnico di Torino. Pag. 1. Active database systems. Triggers. Triggers. Active database systems.

Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification

Relational Algebra. Query Languages Review. Operators. Select (σ), Project (π), Union ( ), Difference (-), Join: Natural (*) and Theta ( )

RDBMS Using Oracle. Lecture Week 7 Introduction to Oracle 9i SQL Last Lecture. kamran.munir@gmail.com. Joining Tables

Chapter 1: Introduction. Database Management System (DBMS) University Database Example

Implementing a Data Warehouse with Microsoft SQL Server

COURSE 20463C: IMPLEMENTING A DATA WAREHOUSE WITH MICROSOFT SQL SERVER

Implementing a Data Warehouse with Microsoft SQL Server

Part A: Data Definition Language (DDL) Schema and Catalog CREAT TABLE. Referential Triggered Actions. CSC 742 Database Management Systems

SQL NULL s, Constraints, Triggers

ETL Process in Data Warehouse. G.Lakshmi Priya & Razia Sultana.A Assistant Professor/IT

Basics Of Replication: SQL Server 2000

How To Create A Table In Sql (Ahem)

Implement a Data Warehouse with Microsoft SQL Server 20463C; 5 days

Part 6. Normalization

Maximizing Materialized Views

Handling Exceptions. Copyright 2006, Oracle. All rights reserved. Oracle Database 10g: PL/SQL Fundamentals 8-1

VIEWS virtual relation data duplication consistency problems

Database Design. Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB

Lecture 6. SQL, Logical DB Design

Course 10777A: Implementing a Data Warehouse with Microsoft SQL Server 2012

Introduction to Databases

Microsoft. Course 20463C: Implementing a Data Warehouse with Microsoft SQL Server

Implementing a Data Warehouse with Microsoft SQL Server

14 Triggers / Embedded SQL

Implementing a Data Warehouse with Microsoft SQL Server 2012

Database Management. Chapter Objectives

Implementing a Data Warehouse with Microsoft SQL Server 2014

ATTACHMENT 6 SQL Server 2012 Programming Standards

Implementing a Data Warehouse with Microsoft SQL Server MOC 20463

COURSE OUTLINE MOC 20463: IMPLEMENTING A DATA WAREHOUSE WITH MICROSOFT SQL SERVER

Using Temporary Tables to Improve Performance for SQL Data Services

Extraction Transformation Loading ETL Get data out of sources and load into the DW

Implementing a Data Warehouse with Microsoft SQL Server 2012

Procedural Extension to SQL using Triggers. SS Chung

The Relational Model. Ramakrishnan&Gehrke, Chapter 3 CS4320 1

SYSPRO Point of Sale: Architecture

BCA. Database Management System

There are five fields or columns, with names and types as shown above.

SQL DATA DEFINITION: KEY CONSTRAINTS. CS121: Introduction to Relational Database Systems Fall 2015 Lecture 7

What is a database? COSC 304 Introduction to Database Systems. Database Introduction. Example Problem. Databases in the Real-World

Exercise 1: Relational Model

Course 20463:Implementing a Data Warehouse with Microsoft SQL Server

Implementing a Data Warehouse with Microsoft SQL Server

The Structured Query Language. De facto standard used to interact with relational DB management systems Two major branches

Unit Storage Structures 1. Storage Structures. Unit 4.3

Handling Exceptions. Schedule: Timing Topic. 45 minutes Lecture 20 minutes Practice 65 minutes Total

MTCache: Mid-Tier Database Caching for SQL Server

SQL, PL/SQL FALL Semester 2013

Oracle Data Integrator: Administration and Development

Data security best practices

Chapter 1: Introduction

Database Administrator [DBA]

Outline. Data Modeling. Conceptual Design. ER Model Basics: Entities. ER Model Basics: Relationships. Ternary Relationships. Yanlei Diao UMass Amherst

Chapter 2 Database System Concepts and Architecture

Demystified CONTENTS Acknowledgments xvii Introduction xix CHAPTER 1 Database Fundamentals CHAPTER 2 Exploring Relational Database Components

3. Relational Model and Relational Algebra

The Classical Architecture. Storage 1 / 36

Topics. Database Essential Concepts. What s s a Good Database System? Using Database Software. Using Database Software. Types of Database Programs

Zero Downtime Deployments with Database Migrations. Bob Feldbauer

How to Implement Multi-way Active/Active Replication SIMPLY

Chapter 2: Security in DB2

Percona Server features for OpenStack and Trove Ops

ADDING A NEW SITE IN AN EXISTING ORACLE MULTIMASTER REPLICATION WITHOUT QUIESCING THE REPLICATION

ETL PROCESS IN DATA WAREHOUSE

Oracle Database 10g Express

Chapter 6: Integrity Constraints

Database Replication with Oracle 11g and MS SQL Server 2008

The Relational Model. Why Study the Relational Model? Relational Database: Definitions. Chapter 3

AV-005: Administering and Implementing a Data Warehouse with SQL Server 2014

Data Modeling. Database Systems: The Complete Book Ch ,

Implementing and Maintaining Microsoft SQL Server 2008 Integration Services

CSE 530A Database Management Systems. Introduction. Washington University Fall 2013

Database System Concepts

CSC 443 Data Base Management Systems. Basic SQL

System R: Relational Approach to Database Management

Course Outline. Module 1: Introduction to Data Warehousing

Physical DB design and tuning: outline

Oracle PL/SQL Best Practices

Principles of Database Management Systems. Overview. Principles of Data Layout. Topic for today. "Executive Summary": here.

DB2 for z/os: Utilities and Application Development

AVOIDANCE OF CYCLICAL REFERENCE OF FOREIGN KEYS IN DATA MODELING USING THE ENTITY-RELATIONSHIP MODEL


Physical Database Design Process. Physical Database Design Process. Major Inputs to Physical Database. Components of Physical Database Design

The Relational Model. Why Study the Relational Model?

7. Databases and Database Management Systems

T-SQL STANDARD ELEMENTS

Implementing a Data Warehouse with Microsoft SQL Server 2012 MOC 10777

Temporal features in SQL:2011

Managing large sound databases using Mpeg7

Database Replication with MySQL and PostgreSQL

THE OPEN UNIVERSITY OF TANZANIA FACULTY OF SCIENCE TECHNOLOGY AND ENVIRONMENTAL STUDIES BACHELOR OF SIENCE IN DATA MANAGEMENT

Benefits of Normalisation in a Data Base - Part 1

DATABASE MANAGEMENT SYSTEM

Transactions, Views, Indexes. Controlling Concurrent Behavior Virtual and Materialized Views Speeding Accesses to Data



Recovery System C H A P T E R16. Practice Exercises

Transcription:

Ch3 Active Database Systems {1{ Applications of Active Rules Internal to the database: { Integrity constraint maintenance { Support of data derivation (including data replication). Extended functionalities: { Workow management systems { Version managers { Event tracking and logging { Security administration Business Rules: { Trading rules for the bond market { Warehouse and inventory management { Energy management rules

Ch3 Active Database Systems {2{ Internal and Extended Rules Perform classical DBMS functions Can be approached with structured approaches and techniques Can be automatically or semi-automatically generated Can be declaratively specied

Ch3 Active Database Systems {3{ 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 species application at declarative (high) level { System derives low-level rules that implement it (automatically or semi-automatically)

Ch3 Active Database Systems {4{ 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-dened problems) { Partially automatic (interactive system)

Ch3 Active Database Systems {5{ 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 x the constraint { when change to employee salaries if a salary is not between 30 and 100 then x the constraint Generalizing: { when potentially invalidating operations if constraint violated then x it { Constraint consistency points = Rule processing points

Ch3 Active Database Systems {6{ Integrity-Preserving Rules Constraint: condition C Rules(s): when operations that could make Example: C become false if C is false then make C true or abort transaction C = every employee's department exists Operations = insert into emp, delete from dept, update to emp.deptno, update to dept.dno Condition: { There is some employee violating C (due to above ops) Action: make C true { Rollback insertion of emp { Rollback deletion of dept { Put emp into a dummy dept

Ch3 Active Database Systems {7{ 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 THEN ROLLBACK (SELECT * FROM Dept WHERE Dno = Emp.DeptNo)) 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

Ch3 Active Database Systems {8{ Example: 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))

Ch3 Active Database Systems {9{ Example: Repair Rules for EMP (2) 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))

Ch3 Active Database Systems {10{ Example: Repair Rules for DEPT Repair rules on table Dept CREATE RULE DeptEmp3 ON Dept WHEN DELETED IF EXISTS (SELECT * FROM Emp WHERE EXISTS (SELECT * FROM DELETED WHERE Dno = Emp.DeptNo)) THEN DELETE FROM Emp WHERE EXISTS (SELECT * FROM DELETED WHERE Dno = Emp.Deptno) CREATE RULE DeptEmp4 ON Dept WHEN UPDATED(Dno) IF EXISTS (SELECT * FROM Emp WHERE EXISTS (SELECT * FROM OLD-UPDATED WHERE Dno = Emp.Deptno)) THEN DELETE FROM Emp WHERE EXISTS (SELECT * FROM OLD-UPDATED WHERE Dno = Emp.DeptNo)

Ch3 Active Database Systems {11{ View Maintenance Logical tables derived from base tables { Portion of database specied by retrieval query { Used to provide dierent abstraction levels (or: external schemas) Referenced in retrieval queries Virtual views { Not physically stored { Implemented by query modication Materialized views { Physically stored { Kept consistent with base tables

Ch3 Active Database Systems {12{ Virtual Views Views dene 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

Ch3 Active Database Systems {13{ Materialized Views View: V = query Q Rules(s): when operations that can change the result of Q then modify V How to generate rule(s) from view? Generate triggering operations by analyzing Q V = all employees with high salaries Ops = insert into emp, delete from emp, update emp.sal Generate action to modify V { Evaluate query Q, set V = result { Evaluate Q using changed values, update V { Determine which by analyzing Q

Ch3 Active Database Systems {14{ Materialized Views and Rules SQL select expressions dene view V as select Cols from Tables where Predicate Materialized initially, stored in database \Refreshed" at rule processing points Changes to base tables! Production rules modify view

Ch3 Active Database Systems {15{ View-Maintaining Rules Recomputation approach (easy but bad) when changes to base tables then recompute view Incremental approach (good but hard) when changes to base tables then change view Incremental rules is complicated for: { Views with duplicates { Certain base table operations

Ch3 Active Database Systems {16{ 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 to Emp.Sal 7. updates to Dept.Dno

Ch3 Active Database Systems {17{ Refresh Rules written in Starburst Refresh rules CREATE RULE RefreshHighPaidDept1 ON Dept 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 Emp 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)

Ch3 Active Database Systems {18{ Incremental Rule for Insert on Dept Incremental refresh rule 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)

Ch3 Active Database Systems {19{ Replication A special case of data derivation (identical copies). Main application: distributed systems (copies on dierent 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

Ch3 Active Database Systems {20{ 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)

Ch3 Active Database Systems {21{ Workow Management A new paradigm for organizing the working activities within enterprise. Intrinsecally reactive: workow managers monitor events and perform the required event management activities. Events are: { Internal: generated from within the workow manager while workows are progressing. { External: representing the interaction of the workow manager with the external world. The most signicant application of rules: expressing exceptions to the normal ow.

Ch3 Active Database Systems {22{ Examples of Active Rules for Workow Management dene trigger WF1 for Agent events modify(agent.availability) condition Agent(A), occurred(modify(agent.availability),a), A.Availability=FALSE, task(t), T.Responsible=A, T.Type='Urgent', Agent(B), A.Substitute=B, B.Availability=TRUE actions modify(task.responsible, T, B) end dene trigger WF2 for Accident events create(accident) condition Accident(A), occurred(create, A), Booking(B), B.Car = A.DamagedCar, actions create(warning,[b.number,b.agent],x) end

Ch3 Active Database Systems {23{ Business Rules Performing a part of the application-specic business. Examples: { Stock and bond trading in nancial applications. { Airway assignment to ights in air trac control systems { Order management in inventory control systems. Key design principle: knowledge independence. { Factoring knowledge out of the applications. { Rules automatically shared by all applications. { Rules logically part of the database schema (designed by \DBA"). { Knowledge evolution feasible and controllable (changing rules without changing applications)).

Ch3 Active Database Systems {24{ Energy Management System The ENEL Energy Management System uses a "radial topology" network ( forest), each "user" connected to a single "distributor" through a network of intermediate "nodes". The purpose of the network is to transfer the exact power from distributors to users through nodes and (directed) branches connecting pairs of nodes. A transaction changes the user's prole, then the system nds the appropriate layout and power supply.

Ch3 Active Database Systems {25{ Active Rules R1: If a new user requires power, connect it to the closest node R2: If a user or a node requires less power, change the power of the user or node and propagate the change to its input branch R3: If a branch requires less power, change the power of the branch and propagate the change to its input node R4: If the power required from a distributor is decreased, change its output power accordingly R5: If a user or node requires more power, change the power of the user or node and propagate the change to its input branch R6: If a branch requires more power, change the power of the branch and propagate the change to its input node R7: If the power required from a distributor is increased, change its output power accordingly R8: If a distributor's power exceeds its maximum, rollback the entire transaction R9: If a branch's power is changed, change the power of some of its wires accordingly R10: If a wire's power is above its threshold, change wire type R11: If there's no suitable wire type, add another wire to the branch R12: If a wire is not included into a tube, add a tube around it R13: If a tube is too small to fit all its wires, change it into a larger tube R14: If a wire inside a tube is high voltage and the tube is not protected, change it into a protected tube R15: If there's no suitable tube, split the branch into two branches