Title: 3. Logical Models and Query Languages
13. Logical Models and Query Languages
- 2007-09-20
- Hong-Koo Kang
- Department of Computer Science Engineering
- Konkuk University
- E-mail hkkang_at_db.konkuk.ac.kr
- URL http//db.konkuk.ac.kr
2Introduction
- This chapter
- How the representation and querying of geographic
objects can be supported by the DBMS - Abstract Data Type(ADT)
- Combinations of data types and operations
- Ex) type polygon, its operation PolygonArea
- Encapsulation
- ADTs are encapsulated in the sense that they are
accessible only through the operations defined on
them - The DBMS need not have any knowledge on the ADT
implementation
33.1 Reference Schemas (1/2)
- Administrative Units (Schema 1)
- A country (ex the United States or Germany)
consists of states, and a single state, in turn,
consists of counties - The diamond shaped symbol(?)
- Between two entity types express an aggregation
relationship - Ex) a State consists of Counties
- The solid circle symbol(?)
- Is used to denote a one-to-many relationship
Figure 3.1 Administrative units in the United
States (schema 1)
43.1 Reference Schemas (2/2)
- Highway Network Among Cities (Schema 2)
- A highway entity consists of sections
- A section may be shared by several highways
- Many-to-many relationship
- The sections of highways connect cities to each
other - A section starts in a given city and ends in
another - Land Use (Schema 3)
- A particular area in the plane is associated with
a type of use - Such as housing, agricultural area, and forest
Figure 3.2 Highway network among cities (schema 2)
53.2 Reference Queries (1/4)
- Query classification
- Queries with alphanumeric criteria (ALPHA-)
- Queries with a spatial criteria (SPAT-)
- Ex) an operation that applies to the spatial part
of one or several geographic objects - Interactive queries (INTER-)
- which require participation from the end user
- Ex) to select a particular area by drawing it on
a display device using a mouse - Schema
- Administrative units (ADM)
- Roads (R)
- Land use (LU)
- Ex) ALPHA-ADM2 for the second alphanumeric query
on administrative units
63.2 Reference Queries (2/4)
- Queries with alphanumeric criteria are as follows
- ALPHA-ADM1
- Number of inhabitants in the County of San
Francisco - ALPHA-ADM2
- List of the counties of the State of California
- ALPHA-ADM3
- Number of inhabitants in the United States
- ALPHA-R1
- Number of lanes in the first section of
Interstate 99 - ALPHA-R2
- Name of all sections that constitute Interstate
99
73.2 Reference Queries (3/4)
- Queries involving spatial criteria are as follows
- SPAT-ADM4
- Counties adjacent to the County of San Francisco
in the same state - SPAT-ADM5
- Display of the State of California
- SPAT-ADM6
- Counties larger than the largest county in
California - SPAT-R3
- Length of Interstate 99
- SPAT-ADM-R1
- All highways going through the State of
California - SPAT-ADM-LU1
- Display of all residential area in the County of
San Jose - SPAT-ADM-LU2
- Overlay of the themes of administrative units and
land use
83.2 Reference Queries (4/4)
- Interactive queries are as follows
- INTER-ADM7
- Description of the county pointed to on the
screen - INTER-ADM8
- Counties that intersect a given rectangle on the
screen - INTER-ADM9
- Parts of counties within a given rectangle on the
screen - INTER-R5
- Description of the section pointed to on the
screen - INTER-R6
- Description of the highway of which a section is
pointed to on the screen
93.3 Spatial Abstract Data Types
- Extending Data Models with Spatial ADTs
- Designing Spatial ADTs
- Exploring Relationships Between Spatial Objects
Topological Predicates
10Extending Data Models with Spatial ADTs (1/6)
- Spatial ADTs Basic Concepts
- The list of operations that one can perform on
the spatial object - Independently of its internal representation
- ex) Testing of intersection with other objects,
area size calculation - Geographic data models and spatial data models
11Extending Data Models with Spatial ADTs (2/6)
- The abstraction of the region in the geographic
data model allows for any choice of spatial data
model - Ex) spaghetti, network, or topological
12Extending Data Models with Spatial ADTs (3/6)
- Choosing Appropriate Types
- A set of possible choices for geometric types
13Extending Data Models with Spatial ADTs (4/6)
- Simple choices in representing spatial objects
- Type point (zero-dimensional)
- A point is an instance of this type
- Type polyline, line in short (one-dimensional)
- A list of pairwise connected segments
- An endpoint can be shared by, at most, two
segments - Type region ?? (two-dimensional)
- Any set of nonoverlapping polygons
- We do not consider polygons with holes
14Extending Data Models with Spatial ADTs (5/6)
- Defining Spatial ADT Operations
- The result of the operation must be either any
atomic type provided by the DBMS or one of the
three abstract types
15Extending Data Models with Spatial ADTs (6/6)
- Region ADT operations
- PointInRegion region?point -gt bool
- Overlaps region?region -gt bool
- OverlapsRect region?rectangle -gt bool
- Clipping region?rectangle -gt region
- Intersection region?region -gt region
- Meets region?region -gt bool
- Area region -gt real
- RegionUnion region -gt region
- Line ADT operations
- PointInline line?point -gt bool
- Length line -gt real
- OverlapsLR line?region -gt bool
- Point ADT operations
- Distance region?point -gt real
16Designing Spatial ADTs (1/5)
- The spatial operation classification
- Unary operations with Boolean result
- Test a spatial object for a given property
- Ex) convex, connected
- Unary operations with scalar result
- Computing the length, area size, and perimeter of
a spatial object - Unary operations with spatial result
- Topological transforms
- Rotation, translation, scale change, symmetry
- Boundary
- Mapping a d-dimensional object into a
(d-1)-dimensional one (d gt 0) - Object extraction
- minimal bounding rectangle, region centroid
17Designing Spatial ADTs (2/5)
- N-ary operations with spatial result
- Voronoi diagram construction of a set of points
- and convex hull
- Binary operations with spatial result
- Ex) intersection, union, difference
- Binary operations with Boolean result (spatial
predicates) - Topological predicates
- Ex) intersects, contains, adjacent
- Direction predicates
- Ex) above, North of
- Metric predicates
- Whether the distance between two objects is less
than a given number of units - Binary operations with scalar result
- Ex) Distance
18Designing Spatial ADTs (3/5)
- Semantics of Operations
- An operation may have different meanings
depending on the dimension considered - For example, intersection operation
- Two convex polygons
- Always a single convex polygon
- Two nonconvex polygons
- May generate many polygons
- A line and a polygon
- The part of the line inside the polygon
- The intersection points between the line and the
boundary of the polygon - Two lines
- A segment
- The set of segments common to the two lines given
as argument - The set of points of intersection between the two
lines - Two adjacent polygons or regions
- Regularized intersection the returned value is
empty - Geometric intersection the returned value is
their common boundary
19Designing Spatial ADTs (4/5)
20Designing Spatial ADTs (5/5)
- The result of spatial operations should satisfy
one of the existing types - The limits of simple type system
- The intersection of a line and a region returns
many points - The union of two (poly)lines is not a (poly)line
- The difference of two polygons (without holes)
may be a polygon with a hole - Weak typing
- Chooses a type large enough to remain closed
under a set of common operations - Ex) geometry a set of either points or polygons
- Strong typing
- Control on the operations
- Ex) Modeling a line by as set of segments enables
us to perform a union of lines
21Exploring Relationships Between Spatial Objects
Topological Predicates (1/5)
- Focus on topological relationship between two
objects - Definitions for the relations
- Function point(x)
- The set of points that belongs to a spatial
region x - Set operations
- , ?, ?, n
- Definition of following relations
- x y corresponds to point(x) point(y)
- x ? y corresponds to point(x) ? point(y)
- x inside y corresponds to point(x) ? point(y)
- x outside y corresponds to point(x) n point(y)
Ø - x intersects y corresponds to point(x) n point(y)
? Ø
22Exploring Relationships Between Spatial Objects
Topological Predicates (2/5)
- 4-intersection schema
- With the notion of boundary and interior
- Overlap and meets can be distinguished
- By comparing whether or not boundaries and
interiors of two spatial regions intersect - ??
- A non-empty set of points
- A0 interior of A
- dA boundary of A
23Exploring Relationships Between Spatial Objects
Topological Predicates (3/5)
24Exploring Relationships Between Spatial Objects
Topological Predicates (4/5)
25Exploring Relationships Between Spatial Objects
Topological Predicates (5/5)
263.4 Relational Models Extended with ADT
- Representation of reference schemas
- Reference Queries
27Representation of reference schemas (1/3)
- Administrative units (schema 1)
28Representation of reference schemas (2/3)
- Highway network and cities (schema 2)
29Representation of reference schemas (3/3)
30Reference Queries (1/9)
- ALPHA-ADM1
- Number of inhabitants in the County of San
Francisco - ALPHA-ADM2
- List of the names of the counties in the State of
California
31Reference Queries (2/9)
- ALPHA-ADM3
- Number of inhabitants of the United States of
America - ALPHA-R1
- Number of lanes in the first section of
Interstate 99
32Reference Queries (3/9)
- ALPHA-R2
- Names of sections that constitute Interstate 99
33Reference Queries (4/9)
- SPAT-ADM4
- Counties adjacent to the County of San Francisco
in the same state - SPAT-ADM5
- Display of the State of California
34Reference Queries (5/9)
- SPAT-ADM6
- Counties larger than the largest county in
California - SPAT-R3
- Length of Interstate 99
35Reference Queries (6/9)
- SPAT-ADMR1
- All highways going through the State of
California - SPAT-ADM-LU1
- Display of all residential areas in the County of
San Jose
36Reference Queries (7/9)
- SPAT-ADM-LU2
- Overlay of the themes of administrative units and
land use
37Reference Queries (8/9)
- INTER-ADM7
- Description of the county pointed to on the
screen - INTER-ADM8
- Counties that intersect a given rectangle on the
screen - INTER-ADM9
- Parts of counties within a given rectangle on the
screen
38Reference Queries (9/9)
- INTER-R5
- Description of the section pointed to on the
screen - INTER-R6
- Description of the highway of which a section is
pointed to on the screen
393.5 Object-Oriented Models
- A Brief Overview of Object-Oriented DBMS
- Representation of Reference Schemas
- Spatial Classes
- Reference Queries
40A Brief Overview of Object-Oriented DBMS
- Database systems object-oriented programming
languages - Object Identity
- Using an identifier or oid (object identifier)
- Types, Classes, and Methods
- Type corresponds to its structure and to the
operations - Class objects with same type are grouped into
classes - Method express behavior of objects
- Encapsulation
- One accesses objects only via the methods defined
on the class they belong to - Without any knowledge of their detail of
implementation - Inheritance
- To define a (sub)class from an existing
(super)class with a refinement of its structure - Ex) Person -gt Student
41Representation of Reference Schemas (1/3)
- Each theme and each spatial ADT is materialized
by a class - Administrative Units (Schema 1)
42Representation of Reference Schemas (2/3)
- Highway Network (Schema 2)
43Representation of Reference Schemas (3/3)
44Spatial Classes (1/2)
45Spatial Classes (2/2)
- Methods in class Region
- method pointInRegion (p Point) in class Region
boolean - method overlaps (r Region) in class Region
boolean - method overlapsRect (r Rectangle) in class
Region boolean - method clipping (r Rectangle) in class Region
Region - method intersection (r Region) in class Region
Region - method meets (r Region) in class Region boolean
- method area in class Region real
- Methods in class Line
- method pointInLine (p Point) in class Line
boolean - method length in class Line real
- method overlapsLR (r Region) in class Line
boolean - Methods in class Point
- method distance (r Region) in class Point real
46Reference Queries (1/2)
- OQL
- Similar to SQL
- Proposed by the Object Database Management
Group(ODMG) - To access complex structures, to run methods, and
to return a result that may be structured in a
complex way - Queries with Alphanumeric Criteria
- ALPHA-ADM1
- Number of inhabitants in the County of San
Francisco
47Reference Queries (2/2)
- Queries Involving Spatial Criteria
- SPAT-R3
- Length of Interstate 99