You are on page 1of 22

Distributed Data

Advanced Database Models and Applications

Bindu Jose
Advanced Database Models
Objectives
Identify the common features of the advanced
applications and create data models to support the
applications
 Active Databases
 Temporal Databases

Analyse the design and data management issues


Temporal Databases
Temporal Database
Introducing the Time element in the database along with each
record
Temporal databases, encompass all DB applications that require
some aspect of time when organizing their information.

They exhibit the need for developing a set of unifying concepts for
application developers to use.

Temporal DB applications have been developed since the early days


of database usage. However, in creating these applications, it was
mainly left to the application developers to discover, design,
program, and implement the temporal concepts.
[Elmasri, Navathe]
Applications of Temporal Database
Health Care
Patients histories needs to be maintained - not to be
over written
Insurance
Claims and accident histories
Time when the insurance policies are in effect
Reservation systems
Scientific database
Data collected from different experiments includes the
time when each measurement is take
Temporal Database
General relational database design
Information are stored in related tables
Avoid the duplication
Records gets constantly updated
 Update are applied to the original copy
 No record of the original value

The relational model provides poor support for storing


complex temporal information.
The SQL query language provides very limited support
for expressing temporal queries
Temporal Database
Temporal database systems use relational databases
They provide well-defined data models and query
languages
Several extensions are proposed to the relational
database overcome the listed short coming's
Valid Time Relations
Transaction Time Relations
Bitemporal Relations
Temporal Database
Temporal database will store information regarding the
time of a particular database event took place
Update, Insert, Delete
Granularity of the time to be saved must be decided
Single Time Point
 Bank deposit may be associated with a timestamp
 The time at which the deposit is made

Duration Events
 Associated with a specific time period
 Employee working on a specific project

 Start time and End Time


Time Dimensions in the Database
Valid Time – Valid Time Database
Any event of fact associated with a time point or time
period indicates
 The time or time period at which the event took place
 The time period during which the fact was considered to be

true in the real world


This interpretation referred to as the Valid Time
Temporal database using this interpretation is called
Valid Time Database
Time Dimensions in the Database Cont..
Transaction Time – Transaction Time Database
Time refers to the time when the information is actually
stored in the database – timestamp
 Associated time is called Transaction time
Temporal database using this interpretation is known as
Transaction Time Database
Time Dimensions in the Database
Bitemporal Database
Some applications required valid time and transaction
time
Database required both time dimension is known as
Bitemporal Database
Temporal Database
Design and Implementation Issues
Identifying the Time Granularity
Deciding the Time Dimension
Data modelling
 Temporal normal Form
Lack of support from a general purpose DBMS
 Identify and implement the appropriate extensions provided
by the commercial database
Design Considerations
Select the Time granularity
Decide the Time Dimension
Example
Consider a snapshot of the tables from a company
database
Employee Table – SSN primary Key
SSN Name Salary DNo Supervisor_Ssn
Salary of the employees gets updated
Design Considerations
With Day as time granularity Valid Time Relation will be
EMPLOYEE_VT
SSN Name Salary DNo Supervisor_Ssn VST VET

In the employee table the current version of the employee details will be recorded
One record per employee
Employee_VT will have a different versions (records) of the same employee
depending on the changes in their salary
With Valid time the behaviour of the relation (table) changes
Whenever the attribute changes rather than overwriting the value a new version is
created and system will close the current version by changing the VET to the end time
The spatial value NOW implicitly represent the current version
Design Considerations
EMPLOYEE_VT
Design Considerations
With Day as time granularity Transaction Time
Relation will be
EMPLOYEE_TT
SSN Name Salary DNo Supervisor_Ssn TST TET

The current version of the employee record will have


TET as UC (Until Changed)
With Day as time granularity Bitemporal Relation will
be
EMPLOYEE_BT
SSN Name Salary DNo Supervisor_Ssn VST VET TST TET

The current version of the employee record will have


TET as uc and VET as now
Implementation Consideration
There are different ways to store the tuples
Every tuple in the same table
Partition the tuples
 Create two tables – Horizontal Partition
 One table for the current valid record (current snapshot)
 Another table for all the remaining tuples
 Current version can be identified by using the values for
VET or TET or together depending on the chosen time
dimension
 Allow the DBA to have different access paths and indexes
 Create two tables – Vertical Partition
 Create a new table with the attribute that gets updated along
with the primary key
 Creating a Temporal Normal Form
SSN Salary VST VET TST TET
Oracle Temporal Support
Work space Manager is Package which has a
Procedure to Enable the Version Control and Disable
the Version Control
Version-enables a table, creating the necessary
structures to enable the table to support multiple
versions of rows.
Effectively creating Temporal database
The Proecedure can be calles as below:

DBMS_WM.EnableVersioning(
table_name IN VARCHAR2,
hist IN VARCHAR2 DEFAULT 'NONE',
isTopology IN BOOLEAN DEFAULT FALSE,
validTime IN BOOLEAN DEFAULT FALSE,
undo_space IN VARCHAR2 DEFAULT NULL);
Oracle Temporal Support
Table_name : Name of the table. The table name is not case sensitive.

Hist : History option, for tracking modifications to table_name. Must be


one of the following values: NONE: No modifications to the table are
tracked. (This is the default.)

VIEW_W_OVERWRITE: The with overwrite (W_OVERWRITE) option. A


view named <table_name>_HIST is created to contain history information,
but it will show only the most recent modifications to the same version of
the table. A history of modifications to the version is not maintained; that
is, subsequent changes to a row in the same version overwrite earlier
changes. (The CREATETIME column of the <table_name>_HIST view
contains only the time of the most recent update.)

VIEW_WO_OVERWRITE: The without overwrite (WO_OVERWRITE)


option. A view named <table_name>_HIST is created to contain history
information, and it will show all modifications to the same version of the
table. A history of modifications to the version is maintained; that is,
subsequent changes to a row in the same version do not overwrite earlier
changes.
Oracle Temporal Support
isTopology: A Boolean value (TRUE or FALSE).
TRUE indicates that the value specified for the table_name
parameter is the name of an Oracle Spatial topology (not a database
table name), as explained in Section 1.14.
FALSE (the default) indicates that the value specified for the
table_name parameter is not an Oracle Spatial topology name.

validTime : A Boolean value (TRUE or FALSE).


TRUE causes valid time support to be included.
FALSE (the default) causes valid time support not to be
included.

undo_space : A string containing UNLIMITED (for no specified


limit) or a number representing the maximum number of bytes for
undo space available for the version-enable operation. Example:
'1048576' for 1 megabyte. Any value specified overrides the value of
the UNDO_SPACE Workspace Manager system parameter
(described in Section 1.5).
Oracle Temporal Support
Enable Valid Time on EMP
EXECUTE DBMS_WM.EnableVersioning ('EMP', 'VIEW_WO_OVERWRITE', FALSE,
TRUE);
Set the valid time
EXECUTE DBMS_WM.SetValidTime(TO_DATE('01-01-2003', 'DD-MM-YYYY'),
DBMS_WM.UNTIL_CHANGED);
Select the existing data
SELECT EMPNO, ENAME, JOB, SAL, TO_CHAR(E.WM_VALID.VALIDFROM,'DD-
MON-YYYY HH24:MI') FROM_DATE,
TO_CHAR(E.WM_VALID.VALIDTILL, 'DD-MON-YYYY') UNTIL_DATE
FROM EMP E;
Update Salary
UPDATE EMP
SET SAL = 3000
WHERE ENAME = 'MILLER';
Now Select the updated data

Disable Valid Time on EMP


EXECUTE DBMS_WM.DisableVersioning (‘EMP');
Summary
Temporal database store information regarding the time
of a particular database event took place
Instead of rewriting the original value (record) temporal
database allows to keep multiple versions of the record
Current version is identified using the time value (now,
uc)
Design and data management must identify the required
time granularity and time dimension
With a general DBMS appropriate Extensions may be
required to manage the temporal aspect

You might also like