You are on page 1of 26

Temporal and

Spatial Database
Dr S SRIDEVI
Conventional DB Vs Temporal DB

• Conventional DBs:
• Evolve through transactions from one state to the next
• Changes are viewed as modifications to the state
• No information about the past
• Snapshot of the enterprise
• Temporal DBs:
• Maintain historical information
• Changes are viewed as additions to the information stored in the
database
• Incorporate notion of time in the system
• Efficient access to past states

05/13/2023 2
Temporal Database
A temporal database is a database with built-in support for handling
data involving time, being related to the slowly changing dimension
concept, for example a temporal data model and a temporal version
of Structured Query Language (SQL).

Temporal Database
contains

Valid Time Transaction Time

Valid time. The valid time denotes when facts are true with respect to
the real world.
Transaction time. The transaction time of a database fact is the time
when the fact is entered in the database.
05/13/2023 3
Types of Temporal Data
• Static Data: This temporal data have zero temporality. Inferences that can be
derived from this data are free from any temporality.
• Sequences: Sequences are ordered sequence of the events or transactions.
This type of temporal data has the temporal relationship such as before, after,
during, meet and overlap etc.
• Time Stamped: This temporal data has explicit time related information.
Relationship can be quantitative. The inference is made through this type of data
may be temporal or non temporal.
• Time Series: Time series data is the special case of the time stamped data. In
time series data, events have uniform distance on the time scale.
• Fully Temporal: Data of this category is fully time dependent. The inferences
are also strictly temporal.
05/13/2023 4
Temporal Database (contd..)

05/13/2023 5
Different Forms of Temporal Database

Historical Database – stores data with respect to valid time.


Rollback Database - stores data with respect to transaction
time.
Bitemporal Database - - stores data with respect to both valid
transaction time.
05/13/2023 6
Allen’s Interval operations
 Since intervals are represented as pairs of
timepoints, comparisons between intervals are based on
timepoint comparisons of the upper and lower bounds.
 Let I1, I2 be two intervals, and Start(I), end(I) be
respectively the lower bound and upper bound of the
interval I.
 The interval comparison operators are BEFORE,
AFTER, DURING, CONTAINS, OVERLAPS, OVERLAPPED BY,
MEETS, MET BY,STARTS, STARTED BY, FINISHES,
FINISHED BY and EQUAL. This set of comparisons was
originally defined by Allen.

05/13/2023 7
Operators on Intervals
Temporal predicate operators:
i1 = [s1,e1]; i2 = [s2,e2]
i1 i2

– i1 BEFORE i2
(e1<s2) i1 i2
– i1 MEETS i2
i1
(s2 = e1)
– i1 EQUALS i2 i2
(s1 = s2 AND e1 = e2) i1
i2
– i1 OVERLAPS i2
(s2 < s1 < e2 OR s1 < s2 < e1)

05/13/2023 8
Sample Query
Retrieve the state of the record for Chung at 9:30AM, April 4, 2004:
Query: Retrieving a Lost Row with Oracle Flashback Query

• SELECT * FROM employees AS OF TIMESTAMP TO_TIMESTAMP('2004-04-04 09:30:00',


'YYYY-MM-DD HH:MI:SS') WHERE last_name = 'Chung';

Query: Restores Chung's information to the employees table:


Restoring a Lost Row After Oracle Flashback Query

• INSERT INTO employees ( SELECT * FROM employees AS OF TIMESTAMP


TO_TIMESTAMP('2004-04-04 09:30:00', 'YYYY-MM-DD HH:MI:SS') WHERE last_name =
'Chung' );

05/13/2023 9
Time Series Databases
• A time series database (TSDB) is a software system that is optimized for handling time
series data, arrays of numbers indexed by time (a datetime or a datetime range). In some
fields these time series are called profiles, curves, or traces.

• Time series data is a sequence of data points collected at regular intervals over a period of
time. In short, it is any data that has a timestamp, including Internet of Things (IoT) device
data, stocks, commodity prices, tide measurements, solar flare tracking, and health
information.

05/13/2023 10
TIME SERIES DATABASE REQUIREMENTS
•Data location: If related data is not co-located on the same physical
storage, queries can be slow and even result in time-outs.
•Fast, easy range queries: Analyzing time series data requires the ability to
write range queries. With many databases, the sheer volume of time series
data may cause the index to outpace the available memory, degrade read
and write performance, and produce errors. A NoSQL database that co-
locates related time series data ensures that requests complete without
error
•High write performance: Many databases are not able to serve requests
predictably and quickly during peak loads. Unless the database prioritizes
cluster availability over strong consistency, the database may become less
responsive or even completely unresponsive.
•Data compaction: As time series data ages, the granularity of the data
often becomes less relevant to the purpose of useful analysis. To be able to
store and retrieve the data efficiently, organizations must have the ability to
roll up and compress the data according to the needs of the business.
05/13/2023 11
BENEFITS OF A TIME SERIES DATABASE

• Massive scalability and performance: An effective time series database enables an


application to scale easily to support millions of IoT devices or time series data points
in a continuous flow and perform real-time analysis.
• Reduced downtime: In scenarios where downtime is unacceptable, the architecture
of a database that is built for time series data ensures that data is always available
even in the event of network partitions or hardware failures.
• Lower costs: High resiliency translates into fewer resources needed to manage
outages. Fast and easy scaling using commodity hardware reduces the operational
and hardware costs of scaling up or down.
• Improved business decisions: By enabling an organization to analyze data in real
time, a time series database helps an organization make faster and more accurate
adjustments for energy consumption, device maintenance, infrastructure changes, or
other important decisions that impact the business.

05/13/2023 12
Applications of Temporal Database and Time Series
Database

•Health care: patient histories need to be maintained

•Insurance: claims and accident histories are required

•Finance : portfolio management, accounting & banking, stock market analysis, audit analysis

•Personnel management: salary and position history need to be maintained

•Banking: credit histories

•Data Warehousing: historical trends for analysis

• Scheduling apps.: airline, car, hotel reservations and project management

• Scientific apps.: weather monitoring, chemical process monitoring

05/13/2023 13
What is a SDBMS ? (Spatial DBMS)
• A SDBMS is a software module that
• can work with an underlying DBMS
• supports spatial data models, spatial abstract data types (ADTs) and a
query language from which these ADTs are callable
• supports spatial indexing, efficient algorithms for processing spatial
operations, and domain specific rules for query optimization
• Example: Oracle Spatial data cartridge, ESRI SDE
• can work with Oracle 8i DBMS
• Has spatial data types (e.g. polygon), operations (e.g. overlap) callable
from SQL3 query language
• Has spatial indices, e.g. R-trees
Modeling: What need to be presented?
• Single object
Points, Lines and Regions
Modeling: What need to be presented?
• Spatially related collections of objects
Partitions-----a set of regions
Networks-----points and lines
SDBMS Example
• Consider a spatial dataset with:
• County boundary (dashed white line)
• Census block - name, area, population,
boundary (dark line)
• Water bodies (dark polygons)
• Satellite Imagery (gray scale pixels)

• Storage in a SDBMS table:


create table census_blocks (
name string,
area float,
population number,
boundary polygon );

Fig 1.2
Spatial Data Types and Post-relational Databases
• Post-relational DBMS
• Support user defined abstract data types
• Spatial data types (e.g. polygon) can be added
• Choice of post-relational DBMS
• Object oriented (OO) DBMS
• Object relational (OR) DBMS
• A spatial database is a collection of spatial data types, operators, indices,
processing strategies, etc. and can work with many post-relational DBMS as
well as programming languages like Java, Visual Basic etc.
How is a SDBMS different from a GIS ?
• GIS is a software to visualize and analyze spatial data using spatial
analysis functions such as
• Search Thematic search, search by region, (re-)classification
• Location analysis Buffer, corridor, overlay
• Terrain analysis Slope/aspect, catchment, drainage network
• Flow analysis Connectivity, shortest path
• Distribution Change detection, proximity, nearest neighbor
• Spatial analysis/Statistics Pattern, centrality, autocorrelation, indices of similarity, topology: hole
description
• Measurements Distance, perimeter, shape, adjacency, direction

• GIS uses SDBMS


• to store, search, query, share large spatial data sets
How is a SDBMS different from a GIS ?
• SDBMS focusses on
• Efficient storage, querying, sharing of large spatial datasets
• Provides simpler set based query operations
• Example operations: search by region, overlay, nearest neighbor, distance, adjacency,
perimeter etc.
• Uses spatial indices and query optimization to speedup queries over large spatial datasets.
• SDBMS may be used by applications other than GIS
• Astronomy, Genomics, Multimedia information systems, ...
• Will one use a GIS or a SDBM to answer the following:
• How many neighboring countries does USA have?
• Which country has highest number of neighbors?
Components of a SDBMS
• Recall: a SDBMS is a software module that
• can work with an underlying DBMS
• supports spatial data models, spatial ADTs and a query language from which these ADTs are
callable
• supports spatial indexing, algorithms for processing spatial operations, and domain specific
rules for query optimization
• Components include
• spatial data model, query language, query processing, file organization and indices, query
optimization, etc.
• Figure 1.6 shows these components
• We discuss each component briefly in chapter 1.6 and in more detail in later chapters.
Three Layer Architecture Fig 1.6
1.6.2 Spatial Query Language
• Spatial query language
• Spatial data types, e.g. point, linestring, polygon, …
• Spatial operations, e.g. overlap, distance, nearest neighbor, …
• Callable from a query language (e.g. SQL3) of underlying DBMS
SELECT S.name
FROM Senator S
WHERE S.district.Area() > 300

• Standards
• SQL3 (a.k.a. SQL 1999) is a standard for query languages
• OGIS is a standard for spatial data types and operators
• Both standards enjoy wide support in industry
• More details in chapters 2 and 3
1.6.3 •Query Processing
Efficient algorithms to answer spatial queries
• Common Strategy - filter and refine
• Filter Step:Query Region overlaps with MBRs of B,C and D
• Refine Step: Query Region overlaps with B and C

Fig 1.8
Query Processing of Join Queries
•Example - Determining pairs of intersecting rectangles
• (a):Two sets R and S of rectangles, (b): A rectangle with 2 opposite corners
marked, (c ): Rectangles sorted by smallest X coordinate value
• Plane sweep filter identifies 5 pairs out of 12 for refinement step
• Details of plane sweep algorithm on page 15

Fig 1.9
Spatial Indexing: Search Data-Structures
•Choice for spatial indexing:
• B-tree is a hierarchical collection of ranges of linear keys, e.g. numbers
• B-tree index is used for efficient search of traditional data
• B-tree can be used with space filling curve on spatial data
• R-tree provides better search performance yet!
• R-tree is a hierarchical collection of rectangles
• More details in chapter 4

Fig 1.12: B-tree Fig. 1.13: R- tree

You might also like