Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe
CHAPTER 26 Ehaced Data Models: Itroductio to Active, Temporal, Spatial, Multimedia, ad Deductive Databases Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe
26.1 Active Database Cocepts ad Triggers Database systems implemet rules that specify actios automatically triggered by certai evets Triggers Techique for specifyig certai types of active rules Commercial relatioal DBMSs have various versios of triggers available Oracle sytax used to illustrate cocepts Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-3
Geeralized Model for Active Databases ad Oracle Triggers Evet-coditio-actio (ECA) model Evet triggers a rule Usually database update operatios Coditio determies whether rule actio should be completed Optioal Actio will complete oly if coditio evaluates to true Actio to be take Sequece of SQL statemets, trasactio, or exteral program Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-4
Example Evets that may cause a chage i value of Total_sal attribute Isertig ew employee Chagig salary Reassigig or deletig employees Figure 26.1 A simplified COMPANY database used for active rule examples Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-5
Example (cot d.) Coditio to be evaluated Check that value of Do attribute is ot NULL Actio to be take Automatically update the value of Total_sal Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-6
Figure 26.2 Specifyig active rules as triggers i Oracle otatio (a) Triggers for automatically maitaiig the cosistecy of Total_sal of DEPARTMENT Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-7
Figure 26.2 (cot d.) Specifyig active rules as triggers i Oracle otatio (b) Trigger for comparig a employee s salary with that of his or her supervisor Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-8
Desig ad Implemetatio Issues for Active Databases Deactivated rule Will ot be triggered by the triggerig evet Activate commad Makes the rule active agai Drop commad Deletes the rule from the system Approach: group rules ito rule sets Etire rule set ca be activated, deactivated, or dropped Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-9
Desig ad Implemetatio Issues for Active Databases (cot d.) Timig of actio Before trigger executes trigger before executig evet that caused the trigger After trigger executes trigger after executig the evet Istead of trigger executes trigger istead of executig the evet Actio ca be cosidered separate trasactio Or part of same trasactio that triggered the rule Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-10
Desig ad Implemetatio Issues for Active Databases (cot d.) Rule cosideratio Immediate cosideratio Coditio evaluated as part of same trasactio Evaluate coditio either before, after, or istead of executig the triggerig evet Deferred cosideratio Coditio evaluated at the ed of the trasactio Detached cosideratio Coditio evaluated as a separate trasactio Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-11
Desig ad Implemetatio Issues for Active Databases (cot d.) Row-level rule Rule cosidered separately for each row Statemet-level rule Rule cosidered oce for etire statemet Difficult to guaratee cosistecy ad termiatio of rules Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-12
Examples of Statemet-Level Active Rules i STARBURST Figure 26.5 (cotiues) Active rules usig statemet-level sematics i STARBURST otatio Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-13
Examples of Statemet-Level Active Rules i STARBURST (cot d.) Figure 26.5 (cot d.) Active rules usig statemet-level sematics i STARBURST otatio Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-14
Potetial Applicatios for Active Databases Allow otificatio of certai coditios that occur Eforce itegrity costraits Automatically maitai derived data Maitai cosistecy of materialized views Eable cosistecy of replicated tables Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-15
Triggers i SQL-99 Figure 26.6 Trigger T1 illustratig the sytax for defiig triggers i SQL-99 Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-16
26.2 Temporal Database Cocepts Temporal databases require some aspect of time whe orgaizig iformatio Healthcare Isurace Reservatio systems Scietific databases Time cosidered as ordered sequece of poits Graularity determied by the applicatio Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-17
Temporal Database Cocepts (cot d.) Chroo Term used to describe miimal graularity of a particular applicatio Referece poit for measurig specific time evets Various caledars SQL2 temporal data types DATE, TIME, TIMESTAMP, INTERVAL, PERIOD Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-18
Temporal Database Cocepts (cot d.) Poit evets or facts Typically associated with a sigle time poit Time series data Duratio evets or facts Associated with specific time period Time period represeted by start ad ed poits Valid time True i the real world Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-19
Temporal Database Cocepts (cot d.) Trasactio time Value of the system clock whe iformatio is valid i the system User-defied time Bitemporal database Uses valid time ad trasactio time Valid time relatios Used to represet history of chages Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-20
Temporal Database Cocepts (cot d.) Figure 26.7 Differet types of temporal relatioal databases (a) Valid time database schema (b) Trasactio time database schema (c) Bitemporal database schema Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-21
Temporal Database Cocepts (cot d.) Figure 26.8 Some tuple versios i the valid time relatios EMP_VT ad DEPT_VT Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-22
Temporal Database Cocepts (cot d.) Types of updates Proactive Retroactive Simultaeous Timestamp recorded wheever chage is applied to database Bitemporal relatios Applicatio requires both valid time ad trasactio time Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-23
Temporal Database Cocepts (cot d.) Implemetatio cosideratios Store all tuples i the same table Create two tables: oe for curretly valid iformatio ad oe for the rest Vertically partitio temporal relatio attributes ito separate relatios New tuple created wheever ay attribute updated Apped-oly database Keeps complete record of chages ad correctios Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-24
Temporal Database Cocepts (cot d.) Attribute versioig Simple complex object used to store all temporal chages of the object Time-varyig attribute Values versioed over time by addig temporal periods to the attribute No-time-varyig attribute Values do ot chage over time Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-25
Figure 26.10 Possible ODL schema for a temporal valid time EMPLOYEE_VT object class usig attribute versioig Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-26
Temporal Database Cocepts (cot d.) TSQL2 laguage Exteds SQL for queryig valid time ad trasactio time tables Used to specify whether a relatio is temporal or otemporal Temporal database query coditios may ivolve time ad attributes Pure time coditio ivolves oly time Attribute ad time coditios Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-27
Temporal Database Cocepts (cot d.) CREATE TABLE statemet Exteded with optioal AS clause Allows users to declare differet temporal optios Examples: AS VALID STATE<GRANULARITY> (valid time relatio with valid time period) AS TRANSACTION (trasactio time relatio with trasactio time period) Keywords STATE ad EVENT Specify whether a time period or poit is associated with valid time dimesio Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-28
Temporal Database Cocepts (cot d.) Time series data Ofte used i fiacial, sales, ad ecoomics applicatios Special type of valid evet data Evet s time poits predetermied accordig to fixed caledar Maaged usig specialized time series maagemet systems Supported by some commercial DBMS packages Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-29
26.3 Spatial Database Cocepts Spatial databases support iformatio about objects i multidimesioal space Examples: cartographic databases, geographic iformatio systems, weather iformatio databases Spatial relatioships amog the objects are importat Optimized to query data such as poits, lies, ad polygos Spatial queries Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-30
Spatial Database Cocepts (cot d.) Measuremet operatios Used to measure global properties of sigle objects Spatial aalysis operatios Ucover spatial relatioships withi ad amog mapped data layers Flow aalysis operatios Help determie shortest path betwee two poits Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-31
Spatial Database Cocepts (cot d.) Locatio aalysis Determie whether give set of poits ad lies lie withi a give polygo Digital terrai aalysis Used to build three-dimesioal models Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-32
Spatial Database Cocepts (cot d.) Table 26.1 Commo types of aalysis for spatial data Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-33
Spatial Database Cocepts (cot d.) Spatial data types Map data Geographic or spatial features of objects i a map Attribute data Descriptive data associated with map features Image data Satellite images Models of spatial iformatio Field models Object models Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-34
Spatial Database Cocepts (cot d.) Spatial operator categories Topological operators Properties do ot chage whe topological trasformatios applied Projective operators Express cocavity/covexity of objects Metric operators Specifically describe object s geometry Dyamic spatial operators Create, destroy, ad update Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-35
Spatial Database Cocepts (cot d.) Spatial queries Rage queries Example: fid all hospitals with the Metropolita Atlata city area Nearest eighbor queries Example: fid police car earest locatio of a crime Spatial jois or overlays Example: fid all homes withi two miles of a lake Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-36
Spatial Database Cocepts (cot d.) Spatial data idexig Grid files R-trees Spatial joi idex Spatial data miig techiques Spatial classificatio Spatial associatio Spatial clusterig Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-37
26.4 Multimedia Database Cocepts Multimedia databases allow users to store ad query images, video, audio, ad documets Cotet-based retrieval Automatic aalysis Maual idetificatio Color ofte used i cotet-based image retrieval Texture ad shape Object recogitio Scale-ivariat feature trasform (SIFT) approach Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-38
Multimedia Database Cocepts (cot d.) Sematic taggig of images User-supplied tags Automated geeratio of image tags Web Otology Laguage (OWL) provides cocept hierarchy Aalysis of audio data sources Text-based idexig Cotet-based idexig Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-39
26.5 Itroductio to Deductive Databases Deductive database uses facts ad rules Iferece egie ca deduce ew facts usig rules Prolog/Datalog otatio Based o providig predicates with uique ames Predicate has a implicit meaig ad a fixed umber of argumets If argumets are all costat values, predicate states that a certai fact is true If argumets are variables, cosidered as a query or part of a rule or costrait Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-40
Prolog Notatio ad The Supervisory Tree Figure 26.11 (a) Prolog otatio (b) The supervisory tree Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-41
Itroductio to Deductive Databases (cot d.) Datalog otatio Program built from basic objects called atomic formulas Literals of the form p(a 1,a 2, a ) p is the predicate ame is the umber of argumets for predicate p Iterpretatios of rules Proof-theoretic versus model-theoretic Deductive axioms Groud axioms Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-42
Itroductio to Deductive Databases (cot d.) Figure 26.12 Provig a ew fact Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-43
Itroductio to Deductive Databases (cot d.) Safe program or rule Geerates a fiite set of facts Norecursive query Icludes oly orecursive predicates Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-44
Use of Relatioal Operatios Figure 26.16 Predicates for illustratig relatioal operatios Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-45
26.6 Summary Active databases Specify active rules Temporal databases Ivolve time cocepts Spatial databases Ivolve spatial characteristics Multimedia databases Store images, audio, video, documets, ad more Deductive databases Prolog ad Datalog otatio Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Slide 26-46