Enhanced Data Models for Advanced Applications. Active Database Concepts

Similar documents
SQL: A COMMERCIAL DATABASE LANGUAGE. Complex Constraints

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Chapter 24. Active Database Concepts and Triggers. Outline. Trigger Example. Event-Condition-Action (ECA) Model

Database Management Systems Triggers

DATA AND SCHEMA MODIFICATIONS CHAPTERS 4,5 (6/E) CHAPTER 8 (5/E)

Ders # 7. Veri Bütünlüğü Programlama ve Güvenlik. From Elmasri/Navathe textbook Ch9,26 Sciore textbook, Ch 9-10

Chapter 14. Active Databases. Database Systems(Part 2) p. 200/286

COSC344 Database Theory and Applications. Lecture 11 Triggers

DATABASE DESIGN II - 1DL400

Intermediate SQL ( )

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

CSC 261/461 Database Systems Lecture 6. Fall 2017

Integrity Constraints (Reminder)

SQL: A COMMERCIAL DATABASE LANGUAGE. Data Change Statements,

Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No.

SQL- Updates, Asser0ons and Views

SQL: Advanced Queries, Assertions, Triggers, and Views. Copyright 2012 Ramez Elmasri and Shamkant B. Navathe

Sql Server Syllabus. Overview

Integrity and Security

UNIT-IV (Relational Database Language, PL/SQL)

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

Slides by: Ms. Shree Jaswal

SQL Constraints and Triggers. Week 11

The Relational Model

Oracle Database 10g: Introduction to SQL

Data Modelling and Databases. Exercise Session 7: Integrity Constraints

RESTRICTING AND SORTING DATA

Summary Modifications. Database Construction (and Usage) Explicit attribute lists. Insertions with queries. Quiz. Default values

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Data Manipulation (DML) and Data Definition (DDL)

Chapter 4. Basic SQL. SQL Data Definition and Data Types. Basic SQL. SQL language SQL. Terminology: CREATE statement

Interview Questions on DBMS and SQL [Compiled by M V Kamal, Associate Professor, CSE Dept]

Module 9: Managing Schema Objects

Database Foundations. 6-4 Data Manipulation Language (DML) Copyright 2015, Oracle and/or its affiliates. All rights reserved.

Database Programming with SQL

Relational Model History. COSC 416 NoSQL Databases. Relational Model (Review) Relation Example. Relational Model Definitions. Relational Integrity

Simple SQL Queries (contd.)

Retrieving Data Using the SQL SELECT Statement. Copyright 2004, Oracle. All rights reserved.

Assertions, Views, and Programming. CS157A Chris Pollett Oct. 31, 2005.

Debapriyo Majumdar DBMS Fall 2016 Indian Statistical Institute Kolkata

SQL: Data De ni on. B0B36DBS, BD6B36DBS: Database Systems. h p:// Lecture 3

M.C.A. (CBCS) Sem.-III Examination November-2013 CCA-3004 : Database Concepts and Tools. Faculty Code: 003 Subject Code:

5 Integrity Constraints and Triggers

Database Technology. Topic 6: Triggers and Stored Procedures

Assorted Topics Stored Procedures and Triggers Pg 1

INDEX. 1 Basic SQL Statements. 2 Restricting and Sorting Data. 3 Single Row Functions. 4 Displaying data from multiple tables

Part I: Structured Data

SQL STRUCTURED QUERY LANGUAGE

Chapter 4: Intermediate SQL

EGCI 321: Database Systems. Dr. Tanasanee Phienthrakul

COSC 304 Introduction to Database Systems. Views and Security. Dr. Ramon Lawrence University of British Columbia Okanagan

Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa

CSEN 501 CSEN501 - Databases I

DATABASDESIGN FÖR INGENJÖRER - 1DL124

Relational Model. Topics. Relational Model. Why Study the Relational Model? Linda Wu (CMPT )

Database Management Systems,

RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague

Chapter 4: Intermediate SQL

MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9)

Chapter 4. Basic SQL. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Domain Constraints Referential Integrity Assertions Triggers. Authorization Authorization in SQL

Chapter 11 Object and Object- Relational Databases

SQL. Copyright 2013 Ramez Elmasri and Shamkant B. Navathe

SQL: Queries, Constraints, Triggers (iii)

Trigger is a stored procedure which is called implicitly by oracle engine whenever a insert, update or delete statement is fired.

Oracle Database 11g: SQL and PL/SQL Fundamentals

Actual4Test. Actual4test - actual test exam dumps-pass for IT exams

Chapter 6 - Part II The Relational Algebra and Calculus

15CSL58: DATABASE MANAGEMENT LABORATORY

Lecture 08. Spring 2018 Borough of Manhattan Community College

COSC 304 Introduction to Database Systems SQL DDL. Dr. Ramon Lawrence University of British Columbia Okanagan

Database System Concepts"

Principles of Data Management

CSE 530A. Inheritance and Partitioning. Washington University Fall 2013

Examination examples

PROCEDURAL DATABASE PROGRAMMING ( PL/SQL AND T-SQL)

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 7 Introduction to Structured Query Language (SQL)


Lab # 2. Data Definition Language (DDL) Eng. Alaa O Shama

Slides by: Ms. Shree Jaswal

Comp 5311 Database Management Systems. 4b. Structured Query Language 3

Textbook: Chapter 4. Chapter 5: Intermediate SQL. CS425 Fall 2016 Boris Glavic. Chapter 5: Intermediate SQL. View Definition.

Introduction p. 1 The Logical and Physical View of Tables p. 1 Database Types p. 4 NULLs p. 6 DDL and DML Statements p. 7 Column and Table Constraint

DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, X405.5)

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Joining tables. Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c)

COMP102: Introduction to Databases, 20

RETRIEVING DATA USING THE SQL SELECT STATEMENT

Oracle 1Z0-514 Exam Questions and Answers (PDF) Oracle 1Z0-514 Exam Questions 1Z0-514 BrainDumps

CS425 Fall 2017 Boris Glavic Chapter 5: Intermediate SQL

MASTER-DETAIL FORMS. In this Chapter, you will learn about: Master-Detail Forms Page 108

SQL: Part III. Announcements. Constraints. CPS 216 Advanced Database Systems

Debapriyo Majumdar DBMS Fall 2016 Indian Statistical Institute Kolkata

ITCS 3160 DATA BASE DESIGN AND IMPLEMENTATION

SQL Interview Questions

Basic SQL. Basic SQL. Basic SQL

Chapter 7. Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel

1 Prepared By Heena Patel (Asst. Prof)

Where is Database Management System (DBMS) being Used?

Chapter 1: Introduction

Transcription:

Enhanced Data Models for Advanced Applications Active Database Concepts

Topics To Be Discussed Generalized Model for Active Databases and Oracle Triggers Design and Implementation Issues for Active Databases Potential Applications for Active Databases

Active Rules Active databases provide additional functionality for specifying active rules. These rules can be automatically triggered by events that occur, such as a database update or a certain time being reached, and can initiate certain actions that have been specified in the rule declaration if certain conditions are met.

Generalized Model for Active Databases The model that has been used for specifying active database rules is referred to as the Event- Condition-Action, or ECA model. A rule in the ECA model has three components: 1. The event 2. The condition 3. The action

ECA Model 1. The event (or events) that trigger the rule: These events are usually database update operations that are explicitly applied to the database. 2. The condition that determines whether the rule action should be executed: Once the triggering event has occurred, an optional condition may be evaluated. If no condition is specified, the action will be executed once the

ECA Model (Contd ) If a condition is specified, it is first evaluated, and only if it evaluates to true will the rule action be executed. 3. The action to be taken: The action is usually a sequence of SQL statements, but it could also be a database transaction or an external program that will be automatically executed.

Example Note: SUPERVISOR_SSN is a (recursive) foreign key to EMPLOYEE. We assume that null is allowed for DNO, indicating that an employee may be temporarily unassigned MANAGER_SSN is a foreign key to EMPLOYEE TOTAL_SAL attribute is a derived attribute, whose value should be the sum of the salaries of all employees who are assigned to the particular department.

Example (Contd ) We first have to determine the events that may cause a change in the value of TOTAL_SAL, which are as follows: 1. Inserting (one or more) new employee tuples. 2. Changing the salary of (one or more) existing employees. 3. Changing the assignment of existing employees from one department to another.

Example (Contd ) Contition for events: Event 1: we only need to recompute TOTAL_SAL if the new employee is immediately assigned to a department that is, if the value of the DNO attribute for the new employee tuple is not null (assuming null is allowed for DNO)

Example (Contd ) Events 2 and 4: we need to check whether the employee whose salary is changed (or who is being deleted) is currently assigned to a department Event 3: we will always execute an action to maintain the value of TOTAL_SAL correctly, so no condition is needed

Example (Contd ) The action for events 1, 2, and 4 is to automatically update the value of TOTAL_SAL for the employee s department to reflect the newly inserted, updated, or deleted employee s salary. In the case of event 3, a twofold action is needed; one to update the TOTAL_SAL of the employee s old department and the other to update the TOTAL_SAL of the employee s new department

Syntax in Oracle: Example (Contd )

Example (Contd ) Keywords used in creation of a Trigger: The CREATE TRIGGER statement specifies a trigger (or active rule) name TOTALSAL1 for R1. The AFTER-clause specifies that the rule will be triggered after the events that trigger the rule occur The ON-clause specifies the relation on which the rule is specified EMPLOYEE for R1

FOR EACH ROW clause It is important to note the effect of the optional FOR EACH ROW clause, which signifies that the rule is triggered separately for each tuple. This is known as a row-level trigger. If this clause was left out, the trigger would be known as a statement-level trigger and would be triggered once for each triggering statement. Note that the keywords NEW and OLD can only be used with row-level triggers.

Design and Implementation Issues for Active Databases Issue 1:activation, deactivation, and grouping of rules. A deactivated rule will not be triggered by the triggering event. This feature allows users to selectively deactivate rules for certain periods of time when they are not needed The activate command will make the rule active again.

Design and Implementation Issues for Active Databases(Contd ) Rules can be Grouped into named rule sets, so the whole set of rules could be activated, deactivated, or dropped. It is also useful to have a command that can trigger a rule or rule set via an explicit PROCESS RULES command issued by the user.

Design and Implementation Issues for Active Databases(Contd ) Issue 2: whether the triggered action should be executed before, after, or concurrently with the triggering event A related issue is whether the action being executed should be considered as a separate transaction or whether it should be part of the same transaction that triggered the rule.

Design and Implementation Issues for Active Databases(Contd ) Assuming that the triggering event occurs as part of a transaction execution, following are the various options for how the triggering event is related to the evaluation of the rule s condition. The rule condition evaluation is also known as rule consideration, since the action is to be executed only after considering whether the condition evaluates to true or false.

Design and Implementation Issues for Active Databases(Contd ) There are three main possibilities for rule consideration: 1. Immediate consideration: The condition is evaluated as part of the same transaction as the triggering event, and is evaluated immediately. This case can be further categorized into three options: Evaluate the condition before executing the triggering event. Evaluate the condition after executing the

Design and Implementation Issues for Active Databases(Contd ) The next set of options concern the relationship between evaluating the rule condition and executing the rule action. Here, again, three options are possible: immediate, deferred, and detached execution. However, most active systems use the first option. That is, as soon as the condition is evaluated, if it returns true, the action is immediately executed.

Design and Implementation Issues for Active Databases(Contd ) Issue 3:Another issue concerning active database rules is the distinction between rowlevel rules versus statement-level rules. Because SQL update statements (which act as triggering events) can specify a set of tuples, one has to distinguish between whether the rule should be considered once for the whole statement or whether it should be considered separately for each row (that is, tuple) affected by the statement.

Design and Implementation Issues for Active Databases(Contd ) Drawbacks of Active Rules: there are no easy-to-use techniques for designing, writing, and verifying rules. For example, it is quite difficult to verify that a set of rules is consistent, meaning that two or more rules in the set do not contradict one another. It is also difficult to guarantee termination of a set of rules under all circumstances.

Example Illustrating nontermination of rules Here, rule R1 is triggered by an INSERT event on TABLE1 and its action includes an update event on ATTRIBUTE1 of TABLE2. However, rule R2 s triggering event is an UPDATE event on ATTRIBUTE1 of TABLE2, and its action includes an INSERT event on TABLE1. It is easy to see in this example that these two rules can trigger one another indefinitely, leading to nontermination.

Potential Applications for Active Databases 1. to allow notification of certain conditions that occur. For example, an active database may be used to monitor, say, the temperature of an industrial furnace 2. to maintain replicated tables consistent by specifying rules that modify the replicas whenever the master table is modified.

Potential Applications for Active Databases (Contd ) 3. automatic maintenance of derived data 4. to enforce integrity constraints by specifying the types of events that may cause the constraints to be violated and then evaluating appropriate conditions that check whether the constraints are actually violated by the event or not. For example, in the UNIVERSITY database application, one rule may monitor the grade point average of students whenever a new grade is entered, and it may alert the advisor if the