There are
information that are
naturallymulti-dimensional
Examples:
Geographic information:
Circuit board:
Multi-dimensional queries
There are queries on
these
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}
Graphically:
Commonly used multi-dimensional queries
Partial Match queries
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: