Active Object-oriented DBMS Case Study Using Ode - PowerPoint PPT Presentation

1 / 39
About This Presentation
Title:

Active Object-oriented DBMS Case Study Using Ode

Description:

When a detector is tripped, controller records that event, sound the alarms. ... void trip(); 35. Ode Schemes: Alarm. persistent class Alarm { private: ... – PowerPoint PPT presentation

Number of Views:37
Avg rating:3.0/5.0
Slides: 40
Provided by: ecstCs
Category:

less

Transcript and Presenter's Notes

Title: Active Object-oriented DBMS Case Study Using Ode


1
Active Object-oriented DBMS Case Study Using Ode
  • Khanh Le
  • Email khanhle_at_us.ibm.com

2
Topics
  • Introduction to Ode.
  • What is Ode?
  • O Database Facilities
  • Using Ode to implement a home security system.
  • Requirement spec of a home security system
  • Data design and implementation
  • Behavior implementation example

3
What is Ode?
  • An active, Object Database System and Environment
    based on object paradigm.
  • Developed by Database System Research Department
    of ATT Bell Lab (in 1989?).
  • Use a programming language called O.
  • upward-compatible extension of C.
  • offers a simple, elegant notion of persistence.
  • Be able to query and modify the database.
  • provide sophisticated trigger facilities (trigger
    is the basic ingredient of active database.)

4
What is Ode? (cont.)
  • Version 4.2 currently run on SunOs 4.1.x, Solaris
    2.3, Windows NT, Windows 95.
  • Product family
  • OdeltEOSgt (aka Ode) disk-based version of Ode,
    using EOS storage manager. It is free to
    download.
  • MM-OdeltDaligt (aka MM-Ode) main-memory based
    version of Ode, using the Dali main-memory
    storage manager, useful for time-critical
    applications.
  • OdeFS file system interface to Ode object
    database, allow objects to be treated and
    manipulated like files.
  • Ode/Oql an interpreter that execute select
    statement that query objects in Ode.

5
O language
6
O vs. C
  • Has 35 new keywords.
  • Database creation and manipulation.
  • Capability to create objects persist beyond the
    lifetime of the program creating them.
  • Provide iterator to manipulate set of objects
    similar to SQL
  • Transaction support
  • Capability to create access multiple versions
    of an object.
  • Capability to attach to object the condition
    action that are triggered when condition is T.

7
Class database
  • Open, close, remove. Example
  • void main()
  • database db
  • if ((db databaseopen(security)) NULL)
  • cout ltlt Cannot create database security ltlt
    endl
  • exit(1)
  • int i db-gtclose()
  • cout ltlt close() ltlt i
  • registerAction(..)
  • int transCount 0
  • void incrementCount () transCount
  • databaseregisterAction(databaseAFTER_COMMIT,in
    crementCount)

8
Persistent Objects
  • Volatile object vs. persistent object.
  • Example
  • persistent class Person
  • public
  • indexable char Name50
  • int Age
  • Person(char n, int a)
  • persistent Person p
  • p pnew Person(John Doe, 35)
  • pdelete p

9
Clusters of Persistent Objects
  • Cluster is a physical grouping of persistent
    objects
  • By default, all persistent objects of the same
    type are grouped together in a cluster the name
    of a cluster is the same as that of the
    corresponding type
  • Objects of class type can be accessed using the
    iterator.

10
Query
  • All objects
  • for (pe in Person)
  • cout ltlt pe-gtName ltlt pe-gtAge
  • Restrict the query by suchthat
  • for (pe in Person) suchthat (pe-gtAge gt 20)
  • cout ltlt pe-gtName ltlt pe-gtAge
  • All object and its derived objects
  • class Employee public Person
  • for (pe in all Person)

11
Indexing a cluster
  • You can build an index on a data member (declare
    with indexable) of a persistent class type
  • databaseBuildIndex(Person,
    PersonName,DB, 1, HASH_TYPE)
  • Index type can be Hash table or B-tree

12
Transaction in O
  • All code interacting with DB (except open and
    close) or manipulate persistent obj must be
    within transaction block.
  • Update transaction
  • trans
  • Read-only transaction
  • readonly trans
  • Hypothetical transaction
  • hypothetical trans
  • Transaction abort inside trans block tabort

13
Versions
  • Updating an object does not create a new version.
    New versions must be created explicitly by
    invoking the function newvers
  • Temporal relationship vs. Derived-from
    relationship
  • Example
  • persistent Part p, vp1, vp2, vp3, vtemp
  • p pnew Part
  • vp1 newvers(p)

14
(No Transcript)
15
Triggers - Example
  • persistent class Person
  • void Alert (persistent Person , const char , .
    . .)
  • persistent class Stock
  • char name40
  • float price
  • public
  • void NewPrice(float price)
  • . . .
  • event after NewPrice
  • . . .
  • trigger AboveLimit(persistent Person p,
    float limit)
  • after NewPrice (price gt limit)
  • gt Alert(p, s currently trading at
    .2f, name, price)

16
Triggers
  • Declare events all the basic events used in a
    trigger must be declared in the class containing
    the trigger.
  • Declare trigger
  • trigger trigger_name (parameter) trigger-body
  • Trigger-body Event gt Action
  • Activate trigger ps-gtAboveLimit(Joe, 500.0)
  • Fire a trigger action is an independent
    transaction. If triggering trans aborted, then
    trigger action is aborted.

17
A Case Study
  • A Home Security System

18
Requirement Specification
  • Center controller monitors detectors, alarms, and
    notifies emergency personnel according to a
    protocol specified in a schedule.
  • When a detector is tripped, controller records
    that event, sound the alarms. The resident has a
    certain amount of time to abort the protocol. If
    not, notify emergency personnel.

19
Requirement Spec (cont.)
  • Control panel is an interface that allows user to
    initialize system, reset alarms, setup, change,
    delete schedule.
  • Schedule has start, stop time and a choice of
    mode (Immediate, Short Delay, Long Delay)

20
(No Transcript)
21
OBM of Active Objects
  • Control Panel
  • Center Controller
  • Detector
  • Alarm
  • Emergency Notifier

22
OBM of Control Panel Object
23
OBM of Center Controller Obj
24
OBM of Detector
25
OBM of Alarm
26
OBM of Emergency Notifyer
27
Database Schemes
  • Emergency Notifier(Emergency Phone Number)
  • Detection Event(Detector ID, Timestamp)
  • Center Controller(State, (Detection Event))
  • Schedule(Schedule ID, Start Hour, Start Minute,
    Stop Hour, Stop Minute, Mode, Short Delay Time,
    Long Delay Time)

28
Database Schemes (cont)
  • Control Panel(Active Schedule ID, (Schedule))
  • Detector(Detector ID, State)
  • Alarm(AlarmID, State)

29
Ode Schemes EmergencyNofitier
  • persistent class EmergencyNotifier
  • private
  • char phoneNumberMAX
  • public
  • void changeNumber(char NMAX)
  • void notify()

30
Ode Schemes DetectionEvent
  • persistent class DetectionEvent
  • public
  • indexable int detectorID
  • indexable char timestampMAX

31
Ode Schemes CenterController
  • persistent class CenterController
  • private
  • int state
  • persistent DetectionEvent detectionEvents
  • public
  • void reset()
  • void detection(int detectorID)
  • void addDetector(int detectorID)
  • void deleteDetector(int detectorID)
  • void addAlarm(int alarmID)
  • void deleteAlarm(int alarmID)

32
Ode Schemes Schedule
  • persistent class Schedule
  • public
  • indexable int scheduleID
  • int startH, startM, stopH, stopM
  • int mode
  • int shortDelay
  • int longDelay

33
Ode Schemes ControlPanel
  • persistent class ControlPanel
  • private
  • indexable int activeScheduleID
  • persistent Schedule schedules
  • public
  • void reset()
  • void changeSchedule(int schedID)
  • void addSchedule(int schedID)
  • void deleteSchedule(int schedID)
  • void activateSchedule(int schedID)

34
Ode Schemes Detector
  • persistent class Detector
  • private
  • indexable int detectorID
  • int state
  • public
  • void reset()
  • void trip()

35
Ode Schemes Alarm
  • persistent class Alarm
  • private
  • indexable int alarmID
  • int state
  • public
  • void reset()
  • void activate()

36
Behavior Implementation Example
  • persistent EmergencyNotifier emergencyNotifier
  • persistent CenterController centerController
  • persistent ControlPanel controlPanel
  •  
  • void CenterControllerdetection(int detectorID)
  • . . .
  • for (alarms in Alarm)
  • alarms-gtactivate()
  •  
  • detectionEvents pnew DetectionEvent(detectorID,
    makeTimeStamp())
  • wait FALSE

37
Behavior Implementation (cont)
  • if (controlPanel-gtgetActiveMode()
    MODE_IMMEDIATE)
  • state ACTIVE
  • else
  • wait TRUE
  • if (wait)
  • if (controlPanel-gtgetActiveMode()
    MODE_SHORT)
  • delaytime controlPanel-gtgetShortDelay()
  • else
  • delaytime controlPanel-gtgetLongDelay()
  •  
  • targetTime gettime() delaytime
  • delaying TRUE

38
Behavior Implementation (cont)
  • while (delaying)
  • if (timeEqual(targetTime))
  • emergencyNotifier-gtnotify()
  • state ACTIVE
  • delaying FALSE
  • else if (userAbortButtonPressed())
  • reset()
  • state READY
  • delaying FALSE

39
Credit
  • This home security system case study is extracted
    from Chapter 17 from Object Database Development
    Concepts and Principles by David W. Embley
  • Code for this case study is extracted from
    security.c file, developed by Matthew Lundgreen,
    Brian Bouck, and Michael Martin
Write a Comment
User Comments (0)
About PowerShow.com