There are
information that are
naturallymulti-dimensional
Examples:
Geographic information:
Circuit board:
Multi-dimensional queries
Queries can be
formulated on
multi-dimensional data.
Example 1:Nearest point query
Suppose we have a
relation containing
points
on a map
Each point is stored
in the following relation:
Point( x, y )
Given a
point p0(10, 20)
Query:
Find the
point that
is closest to
point p0(10, 20)
In SQL:
select *
from Point P /* P is the closest point to p0 */
where not exists
(select *
from Point Q /* A closer point Q cannot exist ! */
where "distance(Q, p0) < distance(P, p0)")
select *
from Point P /* P is the closest point to p0 */
where not exists
(select *
from Point Q /* A closer point Q cannot exist ! */
where (Q.x-10)2 + (Q.y-20)2 < (P.x-10)2 + (P.y-20)2 )
Example 2:containment query
Suppose we have a
relation that define
rectanglar objects:
Rectangle( id, xll, yll, xur, yur )
A rectangle can be
represented (= defined) by the
coordinates of the
Lower Left and
Upper Rightpoints.
Example of representation
of a rectangle:
Given a pointP(10,20)
Query:
Find all rectangles that
contains the
point
P(10,20)
Answer in SQL:
select id
from rectangle
where
xll ≤ 10 AND yll ≤ 20 AND 10 ≤ xur AND 20 ≤ yur
The query specifies
conditions on
some dimensionsbutnot on
all dimensions
Example:
Find all points/objects that
intersects with
y = 50
Range queries
Find objects that
are located
either partial or
wholly within
a certain range
Example:
Find all objects that
have an overlap
with the
green area (= a range specification):
The green area can be
specified as:
x1 ≤ x ≤ x2
y1 ≤ y ≤ y2
Nearest neighbor queries:
Find object(s) that
is locatedclosest (nearest) to
a given point:
Where-am-I queries:
Given a
location
(i.e., coordinate)
Find the object(s) that
contains the
location:
Multi-dimensional indexes
Multi-dimensional index:
Multi-dimensional index =
an index on
the multi-dimensional data that
help us
answer
a (commonly used)
multi-dimensional query
(more)
efficiently (= speedier)
Before we
develop
such multi-dimensionalindex, we
answer this
questionfirst:
Can we
use a one-dimensional index
to help us
answer
(commonly used)
multi-dimensional queries
(more)
efficiently (= speedier) ???