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 p_{0}(10, 20)
Query:
Find the
point that
is closest to
point p_{0}(10, 20)
In SQL:
select *
from Point P /* P is the closest point to p_{0} */
where not exists
(select *
from Point Q /* A closer point Q cannot exist ! */
where "distance(Q, p_{0}) < distance(P, p_{0})")
select *
from Point P /* P is the closest point to p_{0} */
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, x_{ll}, y_{ll}, x_{ur}, y_{ur} )
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
x_{ll} ≤ 10 AND y_{ll} ≤ 20 AND 10 ≤ x_{ur} AND 20 ≤ y_{ur}
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:
x_{1} ≤ x ≤ x_{2}
y_{1} ≤ y ≤ y_{2}
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) ???