0% found this document useful (0 votes)
22 views

Unit II Spatial and Temporal Databases

Uploaded by

funfor340
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Unit II Spatial and Temporal Databases

Uploaded by

funfor340
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

UNIT II

SPATIAL AND TEMPORAL DATABASES

ACTIVE DATABASE MODEL


 Active Database
 Generalized Model for active databases and Oracle Triggers
ECA Model–Event –Condition –Action
Types of Triggers
Active Rules
 Design and Implementation Issues for Active Databases
 Issue 1: Activate ,deactivate and grouping of rules
 Issue 2: When to execute Trigger Actions: 1.Before 2.After 3.Instead of
 Issue 3: Rule Consideration: 1.Immediate Con. 2.Deferred con. 3. Detached
Con.
 Issue 4: Row level Rules or Statement Level Rules
 Potential Applications for Active Databases
 Allow notification of certain conditions that occur eg:raising
 Enforce integrity constraints
 Automatically maintain derived data
 Maintain consistency of materialized views
 Enable consistency of replicated tables

Active Database:
Active Database is a database consisting of set of triggers.
A trigger is a procedure which is automatically invoked by the DBMS in response to changes
to the database, and is specified by the database administrator (DBA). A database with a set of
associated triggers is generally called an active database.
Example :
Triggers included in Oracle, Sybase,DB2
Inventory control – reordering items when quantity in stock falls below threshold.
Travel Waiting list –Book ticket as soon as right kind is available
Stock Market –Buy/Sell stocks when price below /above threshold .
Event-condition-action (ECA) model or(Parts of trigger)
A triggers description contains three parts, which are as follows −
 Event − Event triggers a rule
Usually database update operations
An event is a change to the database which activates the trigger.
 Condition −Action will complete only if condition evaluates to true
 Action −A procedure which is executed when the trigger is activated and its condition
is true. Sequence of SQL statements, transaction, or external program

Types of triggers
The different types of triggers are explained below −
 Statement level trigger − It is fired only once for DML statement irrespective of
number of rows affected by statement. Statement-level triggers are the default type of
trigger.
 Before-triggers − At the time of defining a trigger we can specify whether the trigger is
to be fired before a command like INSERT, DELETE, or UPDATE is executed or after
the command is executed. Before triggers are automatically used to check the validity
of data before the action is performed. For instance, we can use before trigger to
prevent deletion of rows if deletion should not be allowed in a given case.
 After-triggers − It is used after the triggering action is completed. For example, if the
trigger is associated with the INSERT command then it is fired after the row is
inserted into the table.
 Row-level triggers − It is fired for each row that is affected by DML command. For
example, if an UPDATE command updates 150 rows then a row-level trigger is fired
150 times whereas a statement-level trigger is fired only for once.
Create database trigger
The syntax to create database trigger is as follows –

<trigger> CREATE TRIGGER <trigger name>


<Events> {BEFORE|AFTER} <Triggering events - DELETE|INSERT|UPDATE > ON
<table name>
<Condition> [FOR EACH ROW ]
[WHEN <condition>]
<triggering <trigger actions >;
event > <trigger event> { OR <trigger event> }
<actions > INSERT |DELETE|UPDATE [OF <column name ><,<column name>}]
PL/SQL BLOCK

Active Rules: Rules that are automatically triggered by events in the database
Example:
 Events that may cause a change in value of Total_sal attribute
 Inserting new employee -R1
 Changing salary -R2
 Reassigning or deleting employees -R3

Figure 26.1 A simplified COMPANY database used for active rule examples
Figure 26.2 Specifying active rules as triggers in Oracle notation (a) Triggers for
automatically maintaining the consistency of Total_sal of DEPARTMENT

DESIGN AND IMPLEMENTATION ISSUES FOR ACTIVE DATABASES


ISSUE 1:
 Deactivated rule
 Will not be triggered by the triggering event
 Activate command
 Makes the rule active again
 Drop command
 Deletes the rule from the system
 Approach: group rules into rule sets
 Entire rule set can be activated, deactivated, or dropped
 Rules or Rules set triggered by PROCESS RULES command issued by user
ISSUE 2:
 Timing of action
 Before trigger executes trigger before executing event that caused the trigger
 After trigger executes trigger after executing the event
 Instead of trigger executes trigger instead of executing the event
 Action can be considered separate transaction Or part of same transaction that
triggered the rule
ISSUE 3:
 Rule consideration
 Immediate consideration
 Condition evaluated as part of same transaction
 Evaluate condition either before, after, or instead of executing the
triggering event
 Deferred consideration
 Condition evaluated at the end of the transaction
 Detached consideration
 Condition evaluated as a separate transaction
ISSUE 4:
 Row-level rule
 Rule considered separately for each row
 Statement-level rule
 Rule considered once for entire statement
 Difficult to guarantee consistency and termination of rules

Examples of Statement-Level Active Rules in STARBURST


Figure 26.5 (continues) Active rules using statement-level semantics in STARBURST notation

Triggers in SQL-99

s
Figure 26.6 Trigger T1 illustrating the syntax for defining triggers in SQL-99
Spatial Data Mining Temporal Data Mining

Spatial data mining refers to the temporal data mining refers to the process of
extraction of knowledge, spatial extraction of knowledge about the occurrence
relationships and interesting patterns of an event whether they follow, random,
that are not specifically stored in a cyclic, seasonal variation, etc
spatial database.

It needs space. It needs time.

Primarily, it deals with spatial data Primarily, it deals with implicit and explicit
such as location, geo-referenced. temporal content, form a huge set of data.

It involves characteristic rules, It targets mining new patterns and unknown


discriminant rules, evaluation rules, knowledge, which takes the temporal aspects of
and association rules. data.

Examples: Finding hotspots, unusual Examples: An association rules which seems -


locations. "Any person who buys motorcycle also buys
helmet". By temporal aspect, this rule would be
- "Any person who buys a motorcycle also buy a
helmet after that."
SPATIAL DATABASE
 Spatial database
Applications
Common Analytical Operations on sapatial data
 Spatial Data types MAP (point, line, polygon), Attribute, Image
 Spatial Data models
1. Field Model
2. Object Model
 Spatial Operator
1. Topological Operator
2. Projective Operator
3. Metric Operator
4. Dynamic Operator
 Spatial Queries
1. Range Queries
2. Nearest neighbor queries
3. Spatial join or overlays
 Spatial Data Indexing Technique
1. Grid Files
2. R-Trees
3. Spatial Join index
 Spatial Data Mining
1. Spatial Classification
2. Spatial Clustering
3. Spatial Association
 Applications of Spatial Data
1. Goegraphy
2. Remote Sensing
3. Urban Planning
4. Natural Resource Management
What is Spatial database?
❖ Spatial data is associated with geographic locations such as cities, towns etc.
❖ A spatial database is optimized to store and query data representing objects.
❖ These are the objects which are defined in a geometric space.

Applications of Spatial database:


1. Urban Planning - Urban planning requires analysis of long historical data using a
computer for modelling and simulation.
2. Military Operations - Spatial data holds crucial importance to the Military
Commander in the battlefield as it helps in decision-making in the planning and
development of a state’s growth.
3. Farming - Geographic Information Systems is helpful in being able to map and
present current and future changes in rainfall, temperature, crop production and
more.
4. Disaster and Emergency - All phases of managing diaster and emergencies depend on
data from various sources.
5. Weather Forecasting - GIS is the key component in weather processing systems
which allows instantaneous plotting, interpolation and animation of weather data
across any isobaric level of the atmosphere.
Common Analytical Operations on spatial data

Spatial data types:

❖ Spatial data are of two types according to the storing technique, namely,
1) Raster data - it is composed of grid cells identified by row and column. The
whole geographic area is divided into groups of individual cells, which
represent an image. Satellite images, photographs, scanned images, etc., are
examples of raster data.
2) Vector data - it is composed of points, polylines, and polygons. Wells, houses,
etc., are represented by points. Roads, rivers, streams, etc., are represented by
polylines. Villages and towns are represented by polygons. Vector data
composed of points, lines, polygons
1.Map Data

Includes Various geographic or spatial features of objects in a map ,such as


object shape and the location of the object within the map.
➢ Points - It represents a discrete location on the ground.
➢ Lines - It represents linear features such as rivers, roads and
transmission cables.
➢ Polygons - It represents a boundary of region.

2. Attribute Data:-
It is a descriptive data that GIS system associate with map Features
.example:Population,largest city,area in square miles

3. Image data :-
It includes data such as satellite images and aerial photographs, which are created
by camera.
Image can also be attribute of Map features .

Spatial Operators:
❖ Topological operators: through topology we can express predicates about the
connection, the number of components, the presence/absence of holes as well as
topological relations (which describe whether two objects intersect or not, and, in the
former case, how they intersect)
❖ Projective operators: through projective operators, we can express predicates about
the concavity/convexity of objects as well as other spatial relations (e.g., being inside
the concavity of a given object)
❖ Metric operators: through metrics, we can express predicates about the compactness
or symmetry properties of objects as well as distance and directional relations.
❖ Dynamic Spatial Operators : Dynamic operations change the objects upon which the
operators are applied. Create, destroy, and update are the fundamental dynamic
operations.

Spatial Data Models:

❖ Field - Oriented Model - In modelling geographic phenomena the domain of x is most


often the two dimensions of geographic space, but may include the third spatial
dimension for applications that extend above or below the Earth’s surface, and may
include time for dynamic phenomena.
❖ Object -oriented Model - It treat the physical space as it is populated by discrete,
identiable , spatially-referenced entities. Geometry is the fundamental peculiarity of
spatial data.

Spatial queries:
❖ Spatial queries are queries in a spatial database that can be answered on the basis of
geometric information only, i.e., the spatial position and extent of the objects
involved.
❖ There are mainly three types of spatial queries as given below.
1. Nearest neighbour queries:
It requests objects that present near a specified location. The nearest-neighbour
query requests the object that is nearest to a specified point.
For example, we may want to find the nearest Railway station.
2. Range queries:
It deals with spatial regions. For example, a query can ask for objects that are
present partially or completely within a fixed region. A query to find all medicine
shops within the geographic boundaries of a given town or we can find all the
available schools in a particular city.
3. Union/Intersection:
In this type of queries, we may also request intersections and unions of regions.
For example, given region information, such as annual rainfall and population
density, a query may request all regions with a low annual rainfall as well as a
high population density.
Spatial Data Indexing Techniques:
1. Grid Files:
Fixed grid index is an n×n array of equal-size cells. Each one is associated with a list of
spatial objects which intersect or overlap with the cell. Figure 3 depicts a fixed 4×4 gird
indexing a collection of three spatial objects.

Figure 3. An example of a fixed grid structure.


To further decrease the redundancy, a hierarchical uniform decomposition of the
plane can be enabled. The index-creation process decomposes the plane into an m-
level grid hierarchy (Microsoft SQL Server uses 4 level and IBM DB2 uses 3 level).
These levels are referred to as level 1 (the top level), level 2, level 3… level m. The
decomposition is more complex when the level gets higher. As shown in Figure 4,
each cell at a higher level is decomposed into a 4x4 grid at the next level.

2. R-Tree:
The minimum bounding rectangle, or MBR, which is also called minimum bounding
box, or MBB. An MBR is a single rectangle that minimally encloses the geometry in
2D plane.
The coverage of covering rectangles and overlaps between them in the R-tree are
affected by the objects are being partitioned into groups by its splitting algorithm. This
hierarchical structure is based on the heuristic optimization of the area of MBRs in
each node in order to improve the access efficiency.

M4 through M9 are MBRs of spatial objects in a layer. They are the leaf nodes of the
R-tree index, and contain minimum bounding rectangles of spatial objects, along with
pointers to the spatial objects. M2 and M3 are parents of the leaf nodes. M1 is the
root, containing all the MBRs. This R-tree has a depth of three.

3. Spatial Join Index:

A spatial join index precomputes a spatial join operation and stores the pointers to a
related object in an index structure .
Join indexes improve the performance of recurring join queries .
Spatial join conditions are used to answer the queries such as “Create a list of highway
–river combinations that cross .

Spatial Data Mining Techniques:

1. Spatial Classification :
The task of classification is to assign an object to a class from a given set of classes
based on the attribute values of this object. In spatial classification the attribute values
of neighbouring objects are also considered.
2. Spatial Clustering:
Spatial clustering is a process of grouping a set of spatial objects into clusters so that
objects within a cluster have high similarity in comparison to one another, but are
dissimilar to objects in other clusters. For example, clustering is used to determine the
“hot spots” in crime analysis and disease tracking. Hot spot analysis is the process of
finding unusually dense event clusters across time and space. Many criminal justice
agencies are exploring the benefits provided by computer technologies to identify
crime hot spots in order to take preventive strategies such as deploying saturation
patrols in hot spot areas.

3. Spatial association:
This rule is a rule indicating a certain association relationship among a set of spatial
and possibly some non-spatial predicates. A strong rule indicates that the patterns in
the rule have relatively frequent occurrences in the database and strong implication
relationships.

Multimedia databases

 Multimedia Database
 Content of Multimedia database – Text, Graphic, Video, Audio, Animation
 Types of Multimedia Data –Static, dynamic, dimensional
 Content-based retrieval
 Automatic analysis of images
 Object Recognition in Images
 Semantic Tagging of Images –Semantic tag , OWL
 Analysis of Audio Data Source - Text-based indexing, Content-based indexing
 Challenges of Multimedia Database
 Categories of Multimedia Data Mining
 Multimedia Database Applications
Multimedia Database
The multimedia databases are used to store multimedia data such as images, animation,
audio, video along with text. This data is stored in the form of multiple file types like
.txt(text), .jpg(images), .swf(videos), .mp3(audio) etc.
Contents of the Multimedia Database

The multimedia database stored the multimedia data and information related to it. This is
given in detail as follows −
Media data
This is the multimedia data that is stored in the database such as images, videos, audios,
animation etc.

Media format data


The Media format data contains the formatting information related to the media data such as
sampling rate, frame rate, encoding scheme etc.
Media keyword data
This contains the keyword data related to the media in the database. For an image the
keyword data can be date and time of the image, description of the image etc.

Media feature data


The Media feature data describes the features of the media data. For an image, feature data
can be colours of the image, textures in the image etc. The last three types are called
metadata as they describe several different aspects of the media data. The media keyword
data and media feature data are used as indices for searching purpose.

Types of Multimedia database

The multimedia database can be classified into three types. These types are:
1. Static media
2. Dynamic media
3. Dimensional media

Static media contains text (digital library, creating SMS and MMS) and
images (photos and medical images) .time independent
Dynamic media contains Audio (music and MP3 sounds) and Video
(movies). time dependent
Dimensional data are 3D game and computer aided drafting programs

Content-based retrieval,
The multimedia source is being retrieved based on its containing certain objects or activities.
For example, one may want to locate all video clips in a video database of a person, say
Michael Jackson

Automatic analysis of Images


The Visual feature such as color (RGB,HSV) ,Texture and shape used to retrieve image.
Object Recognition in Images
Object Recognition is a task of identifying real world objects in Images or video sequence .
Even though varying in view points ,size ,scale ,rotated and translated example :
In a given image showing a tiger in the jungle, a tiger sub image may be detected against the
background of the jungle, and when compared with a set of training images, it may be tagged
as a tiger approach

1. One approach is to divide the image into homogeneous segments using a homogeneous
predicate. For example, in a colored image, adjacent cells that have similar pixel values are
grouped into a segment. The homogeneity predicate defines conditions for automatically
grouping those cells .

2. Another approach
finds measurements of the object that are invariant to transformations. It is impossible to
keep a database of examples of all the different transformations of an image . To deal with
this, object recognition approaches find interesting points (or features) in an image that are
invariant to transformations used scale invariant features from images to perform reliable
object recognition. This approach is called scale-invariant feature transform (SIFT)

Semantic Tagging of Images:


Multiple tags may attach to an image or a sub image: for instance, in the example we referred
to above, tags such as “tiger,” “jungle,” “green,” and “stripes” may be associated with that
image
e. Most image search techniques retrieve images based on user-supplied tags that are often
not very accurate or comprehensive.
The techniques have proposed the use of concept hierarchies, taxonomies, or ontologies
using OWL (Web Ontology Language), in which terms and their relationships are clearly
defined. These can be used to infer higher level concepts based on tags. Concepts like “sky”
and “grass” may be further divided into “clear sky” and “cloudy sky” or “dry grass” and “green
grass” in such taxonomy.
Analysis of Audio Data Source
Audio data must be digitized before it can be processed and stored. Indexing and retrieval of
audio data is arguably the toughest among all types of media, because like video, it is
continuous in time. speech data often uses speech recognition techniques to aid the actual
audio content, as this can make indexing this data a lot easier and more accurate. This is
sometimes referred to as text-based indexing of audio data.
Speech metadata :
The length of the speech, the number of speakers, and so on.

Challenges of Multimedia Database


There are many challenges to implement a multimedia database. Some of these are:
 Multimedia databases contains data in a large type of formats such as .txt(text),
.jpg(images), .swf(videos), .mp3(audio) etc. It is difficult to convert one type of data
format to another.
 The multimedia database requires a large size as the multimedia data is quite large and
needs to be stored successfully in the database.
 It takes a lot of time to process multimedia data so multimedia database is slow.

s
Categories of Multimedia Data Mining

Multimedia mining refers to analyzing a large amount of multimedia information to extract


patterns based on their statistical relationships. Multimedia data mining is classified into
two broad categories:

Multimedia Database Applications:

1. Documents and record management: Industries which keep a lot of documentation


and records. Ex: Insurance claim industry.
2. Knowledge dissemination: Multimedia database is an extremely efficient tool for
knowledge dissemination and providing several resources. Ex: electronic books
3. Education and training: Multimedia sources can be used to create resources useful in
education and training. These are popular sources of learning in recent days. Ex:
Digital libraries.
4. Real-time monitoring and control: Multimedia presentation when coupled with active
database technology can be an effective means for controlling and monitoring
complex tasks. Ex: Manufacture control
5. Marketing
6. Advertisement
7. Retailing
8. Entertainment
9. Travel

You might also like