Sie sind auf Seite 1von 11

Outline

Introduction
Spatial Concepts & Models of Spatial Information

Data Models

Three-Step Database Design
Extending the ER Model with Spatial Concepts
Object-Oriented Data Modeling with UML
Prof. Chuan-Ming Liu Summary
CSIE
National Taipei University of Technology

1 2
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab

Learning Objectives What is a Data Model?


Learning Objectives (LO) What is a model? (Dictionary meaning)
A set of plans (blueprint drawing) for a building
LO1: Understand concept of data models
A miniature representation of a system to analyze
What is a data model? properties of interest
Why use data models? Data Model
LO2 : Understand the models of spatial Specifies structure or schema of a data set
information (Section 2.1) Documents description of data
LO3: Understand the 3-step design of databases Facilitates early analysis of some properties, e.g. querying
ability, redundancy, consistency, storage space
(Section 2.2) requirements, etc.
LO4: Learn about the trends in spatial data models Examples:
(Section 2.3 and 2.4) GIS organize spatial set as a set of layers
Databases organize dataset as a collection of tables
3 4
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab

Why Data Models? Types of Data Models


Data models facilitate Two Types of data models
Early analysis of properties, e.g. storage cost, querying ability, ...
Reuse of shared data among multiple applications Generic data models
Exchange of data across organization Developed for business data processing
Conversion of data to new software / environment Support simple abstract data types (ADTs), e.g. numbers, strings, date
Example- Y2K crisis for year 2000 Not convenient for spatial ADTs, e.g. polygons
Many computer software systems were developed without well-defined data Recall a polygon becomes dozens of rows in 3 tables (Fig. 1.4, pp. 8)
models in 1960s and 1970s. These systems used a variety of data models for Need to extend with spatial concepts, e.g. ADTs
representing time and date. Some of the representations used two digits to
represent years. In late 1990s, people worried that the 2 digit representation of year Application Domain specific, e.g. spatial models
may lead to errorneous behaviour. For example age of a person born in 1960 Set of concepts developed in Geographic Info. Science
(represented as 60) in year 2000 (represented as 00) may appear negative and may
be flagged as illegal data item. A large amount of effort and resources (hundreds Common spatial ADTs across different GIS applications
of Billions of dollars) was spent in revising the software.
Proper use of data model may have significantly reduced the costs. If time and
Plan of Study
date were modeled as abstract data types in a software, only a small portion of the First study concepts in spatial models
software implementing the date ADT had to be reviewed and revised.
Then study generic model
5
Finally put the two together 6
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab
Learning Objectives An Example for Illustration
Learning Objectives (LO) A state-park SDB
LO1: Understand concept of data models forest-stands: a species of trees
LO2 : Understand the models of spatial forests: collection of forest-stands
information (Section 2.1) fire-stations: monitoring and managing fires
Field based model facilities: offices, camping groups, etc
Object based model
manager: officer
LO3: Understand the 3-step design of databases
(Section 2.2) rivers: passing the state part and supplying water
to different facilities
LO4: Learn about the trends in spatial data models
(Section 2.3 and 2.4) roads: accessing the state-park

7 8
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab

Models of Spatial Information Modeling the Forest (1)


Two common models: field and object models There are three species in the forest
Consider the following forest stand map Using functional view f : Domain Range
having three species: Fir, Oak, and Pine Domain: the underlying geographic space
Range: a set consisting of three elements
x (0,4)
In the example, the function f is a step function
Pine
" Pine, " 2 x 4;2 < y 4
(0,2)
f ( x, y ) = " Fir, " 0 x 2;0 y 2
Fir Oak " Oak, " 2 < x 4;0 y 2

(0,0) (2,0) (4,0) Such a model is called the field model
y 9 10
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab

Modeling the Forest (2) Object Viewpoint of the Map


If the boundaries of forest-stand are highly
irregular, the ranges of x and y are not simple. Dominant
Area ID Area/Boundary
Tree Species
Consider the places where f changes values
and we can obtain the boundaries of polygons. FS1 Pine [(0,2),(4,2),(4,4),(0,4)]
Each polygon can represent a tree species. FS2 Fir [(0,0),(2,0),(2,2),(0,2)]
The forest can be modeled as a collection of
FS3 Oak [(2,0),(4,0),(4,2),(2,2)]
polygons (i.e. forest-stands) object viewpoint

11 12
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab
Field Model v.s. Object Model Field-Based Model
The decision to use either model depends on Three main components:
the requirement of the applications. Spatial Framework is a partitioning of space
e.g., Grid imposed by Latitude and Longitude
Field models are often used to model
continuous spatial trends, including Field Functions
temperature, elevation, etc. f: Spatial Framework Attribute Domain
Field Operations
Object models are more common in modeling
Examples, addition(+) and composition(o).
transportation network, land parcels, etc f + g : x f ( x) + g ( x)
f g : x f ( g ( x))

13 14
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab

Field Operations (1) Field Operations (2)


Field operations can be classified into three Focal operations
categories: local, focal, and zonal value of the resulting field at a given location depends
Local operations on the values that the input field assumes in a small
value of the new field at a given location in the neighborhood of the location (e.g., Gradient)
spatial frame-work depends only on the value of Zonal operations
the input field at that location Zonal operations are naturally associated with
1 if x =" tree" 1 if x =" lake" aggregate operators or the integration function.
f ( x) = g ( x) =
0 otherwise 0 otherwise
An operation that calculates the average height of the
1 if x =" tree" or " lake" trees for each species is a zonal operation.
The union of f and g : ( f + g )( x) =
0 otherwise
15 16
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab

Exercise Object Models


Classify following operations on elevation field Object model concepts
(I) Identify peaks (points higher than its neighbors)
Objects: distinct identifiable things relevant to an
(II) Identify mountain ranges (elevation over 2000 feet)
application
(III) Determine average elevation of a set of river basins
Objects have attributes and operations
Attribute: a simple property of an object
Operation: function related to the object
The attributes of spatial objects diverge into
two categories: spatial and nonspatial

17 18
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab
Example Object Models Spatial Data Types
Example from a roadmap In object-based models, a key issue is the
Objects: roads, landmarks, ... choice of a basic set of spatial data types used
Attributes of road objects: to present data.
spatial: location, e.g. polygon boundary of land-parcel The geometry described via a spatial
non-spatial: name (e.g. Route 66), type (e.g. interstate, representation system is commonly used to
residential street), number of lanes, speed limit,
represent the spatial shapes.
Operations on road objects:
determine center line
determine length
determine intersection with other roads
... Mobile Computing & Software Engineering Lab 19
Mobile Computing & Software Engineering Lab
20

Categories of Geometry Example


The geometry can be divided into four classes
point: zero-dimensional object
Spatial Object Types Example Object Dimension
curve: one-dimensional object
surface: a two-dimensional object and modeled by Point City 0
a polygon Curve River 1
geometry collection: complex shapes and having Surface Country 2
three types
Multipoint
Multicurve
Multisurface
21 22
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab

Spatial Object Types in OGIS


Data Model Operations on Spatial
blocks of spatial geometry in UML Classifying operations
Set based: 2-dimensional spatial objects (e.g. polygons) are sets of points
Geometry Spatial Reference System
a set operation (e.g. intersection) of 2 polygons produce another polygon
Topological: Boundary of USA touches boundary of Canada
Directional: New York city is to east of Chicago
Point Curve Surface Geometry Collection Metric: Chicago is about 700 miles from New York city.
1..* 2..*
Q? Identify classes of spatial operations not listed in this slide.

Line String Polygon Multisurface Multicurve Multipoint Set-Oriented Union, Intersection, Containment,
1..*
2..*
Toplogical Touches, Disjoint, Overlap, etc.
Line LinearRing 1..* Multipolygon Multilinestring
Directional East,North-West, etc.

23
Metric Distance 24
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab
Topological Relationships Example Topological Operations
Topological Relationships Example queries with topological operations
invariant under elastic deformation (without tear, What is the topological relationship between two
merge). objects A and B ?
Two countries which touch each other in a planar Find all objects which have a given topological
paper map will continue to do so in spherical globe relationship to object A ?
maps.
Topology is the study of topological
relationships

25 26
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab

Topological Concepts Binary Topological Relationship


Interior, boundary, exterior Many topological relationship between two
Let A be an object in a Universe U. objects A and B can be specified using 9
intersection matrix and each element take a
Green is As interior ( A o )
U value of 0 (false) or 1 (true).
Red is the boundary of A ( A )

Blue (Green + Red) is


As exterior ( A )
A

Question: Define Interior, boundary, exterior on curves


and points. 27 28
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab

Illustration Intersection Matrices Metric Space


9-intersection matrices for a few topological operations A set X is a metric space if for any pair of
points x and y in X, there is an associated real
number d(x,y), called the distance (or metric)
0 0 1 1 1 1 1 0 0 1 0 0
between x and y, having the following
0
1
0
1
1
1
0
0
0
0
1
1
1
1
0
1
0
1
0
0
1
0
0
1
properties
disjoint contains inside equal
d(x,y)0 and d(x,y)=0
d(x,y)=d(y,x),
d(x,y) d(x,z)+d(z,y)
0 0 1 1 1 1 1 0 0 1 1 1 for all x, y, z in X.
0 1 1 0 1 1 1 1 0 1 1 1
1 1 1 0 0 1 1 1 1 1 1 1
meet covers coveredBy overlap
29 30
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab
Dynamic Spatial Operations Using Object Model
Dynamic operations alter the objects upon Object model of spatial data
which the operations act OGIS standard set of spatial data types and
operations
Three major dynamic operations
Similar to the object model in computer software
Create Easily used with many computer software systems
Destroy Programming languages like Java, C++, Visual
Update basic
Example use in a Java program is in section 2.1.6
Post-relational databases, e.g. OODBMS,
ORDBMS
31
Example usage in chapter 3 through 6 32
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab

Learning Objectives Three-Step Database Design


Learning Objectives (LO) Database applications are modeled using a
LO1: Understand concept of data models
three-step design process
LO2: Understand the models of spatial information
(Section 2.1) Conceptual data model: datatypes, relationships
LO3: Understand the 3-step design of databases and constraints (ER model)
(Section 2.2) Logical modeling: mapping to a relational model
Conceptual - ER model and associated query language (Relational Algebra)
Logical - Relational model Physical-file structures, indexing,
Physical
Translation from Conceptual to Logical
LO4: Learn about the trends in spatial data models
(Section 2.3 and 2.4) 33 34
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab

Example Application Domain Example


Database design is for a specific application Spatial application domain
domain A state-park consists of forests.
Often a requirements document is available A forest is a collection of forest-stands of different
Designers discuss requirements with end-users as species
needed State-Park is accessed by roads and has a manager
We will use a simple spatial application domain State-Park has faciltities
to illustrate concepts in conceptual and logical data River runs through state-park and supplies water to
models the facilities
to illustrate translation of conceptual DM to logical DM

35 36
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab
Conceptual DM: The ER Model (1) Conceptual DM: The ER Model (2)
Three basic concepts Comparison with Object model of spatial
Entities have an independent conceptual or physical information
existence. Entities, like objects, are collections of attributes
Examples: Forest, Road, Manager, ... ER model does not permit general user defined
Entities are characterized by Attributes operations
Example: Forest has attributes of name, elevation, etc. Relationships are not directly supported in Object
An entity interacts with another entity through model
relationships. but may be simulated via operations
Road allow access to Forest interiors.
This relationship may be name Accesses
37 38
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab

Relationship Types Exercise


Relationships can be categorized by Identify type of cardinality constraint for following:
cardinality constraints Many facilities belong to a forest. Each facility belong to one forest.
other properties, e.g. number of participating entities A manager manages 1 forest. Each forest has 1 manager.
Binary relationship: two entities participate A river supplies water to many facilities. A facility gets water from many
Types of cardinality constraints for binary rivers.
relationships
One-One: An instance of an entity relates to a unique
instance of other entity.
Many-One: Many instances of an entity relate to an
instance of an other.
Many-Many: Many instances of one entity relate to
multiple instances of another.

39 40
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab

ER Diagrams Graphical Notations ER Diagram for State-Park


ER Diagrams are graphic representation of ER Volume
Length

Lineid Name NumofLanes


Name Lineid

models
M M N
supplies_water_to River Crosses Road
Several different graphic notations are used M
N
Name Accesses
We use a simple notation summarized below Within
Elevation N Polygonid
Polygonid

M 1

1 1 1 M
Concept Symbol Facility belongs_to Forest part_of Forest-Stand

Entities 1
1
Lineid Species
Attributes Name M monitors manages

1
Stand-id
Multi-valued Attributes
Name Fire-Station Manager
Relationships
Cardinality of Relationship 1:1, M:1, M:N Gender
Age
Pointid Name
41 42
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab
Exercise The Relational Model
According to the ER diagram Relational model is based on set theory
List the entities, attributes, relationships in this ER Main concepts
diagram Domain: a set of values for a simple attribute
Identify cardinality constraint for each relationship. Relation: cross-product of a set of domains
Represents a table, i.e. homogeneous collection of rows (tuples)
How many roads Accesses a Forest_stand? The set of columns (i.e. attributes) are same for each row
(one or many) Comparison to concepts in conceptual data model
Relations are similar to but not identical to entities
Domains are similar to attributes
Translation rules establishing exact correspondence are discussed in
2.2.3
43 44
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab

Relational Schema (1) Relational Schema (2)


Schema of a Relation Relational schema of a database
Enumerates columns, identifies primary key and foreign collection of schemas of all relations in the database
keys. Example: Figure 2.5 (next slide)
Ablue print summary drawing of the database table structures
Primary Key :
Allows analysis of storage costs, data redundancy, querying capabilities
one or more attributes uniquely identify each row within a table
Some databases were designed as relational schema in 1980s
Foreign keys
Nowadays, databases are designed as ER models and relational schema
Rs attributes which form primary key of another relation S is generated via CASE tools
Value of a foreign key in any tuple of R match values in some row
of S

45 46
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab

Relational Schema Example Spatial Tables


Forest-Stand Fstand-Geom

Stand-id

(Integer)
Species

(varchar)
Forest-name

(varchar)
Stand-id

(Integer)
Polygonid

(Integer)
Relational model restricts attribute domains
Exercise: River River-Geom
simple atomic values, e.g. a number
Name Length Name Lineid

Identify relations with


(varchar) (Real) (Integer) (Integer)
Disallows complex values (e.g. polygons) for columns
Road Road-Geom

primary keys Name NumofLanes Rname Lineid


Complex values need to be decomposed into simpler domains
(varchar) (Integer) (varchar) (Integer)
foreign keys A polygon may be decomposed into edges and vertices (Fig. 2.5)
Facility Facility-Geom
other attributes Name Forest-name Forest-name-2 Name Pointid

Compare with ER diagram (varchar) (varchar) (varchar) (varchar) (Integer)

Forest Forest-Geom
Polygon Line
Figure 2.4, pp. 37 Name Name Polygonid
(varchar) (varchar) (Integer) Polygonid Seq-no Pointid Lineid Seq-no Pointid
Fire-Station Fstation-Geom
(Integer) (Integer) (Integer) (Integer) (Integer) (Integer)
Name ForName Name Pointid
(varchar) (varchar) (varchar) (Integer)
Point Elevation
Supplies_Water_To Road-Access-Forest

FacName RivName Volume RoadName ForName Pointid Latitude Longitude Forest-name Pointid (F.K.) Elevation
(varchar) (varchar) (Real) (varchar) (varchar)
(Integer) (Real) (Real) (varchar) (Integer) (Real)
Manager

Name Age Gender ForName

(varchar) (Integer) (varchar) (varchar) 47 48


Fig 2.5 Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab
More on Relational Model (1) More on Relational Model (2)
Integrity Constraints Normal Forms (NF) for Relational schema
Key: Every relation has a primary key. Reduce data redundancy and facilitate querying
Entity Integrity: Value of primary key in a row is never undefined 1st NF: Each column in a relation contains an atomic value.
Referential Integrity: Value of an attribute of a Foreign Key must 2nd and 3rd NF: Values of non-key attributes are fully determined by
appear as a value in the primary key of another relationship or must be the values of the primary key, only the primary key, and nothing but the
null. primary key.
Other normal forms exists but are seldom used
Translating a well-designed ER model yields a relational schema in 3rd
NF
satisfying definition of 1st, 2nd and 3rd normal forms

49 50
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab

Mapping ER to Relational Learning Objectives


Highlights of translation rules (section 2.2.3) Learning Objectives (LO)
Entity becomes Relation
LO1: Understand concept of data models
Attributes become columns in the relation
Multi-valued attributes become a new relation LO2: Understand the models of spatial information
includes foreign key to link to relation for the entity
(Section 2.1)
Relationships (1:1, 1:N) become foreign keys
M:N Relationships become a relation LO3: Understand the 3-step design of databases
containing foreign keys or relations from participating entities (Section 2.2)
Example and Exercise
Compare Fig. 2.4 and Fig. 2.5
LO4: Learn about the trends in spatial data models
Identify the relational schema components for (Section 2.3 and 2.4)
entity Facility, its attributes and its relationships Pictograms in conceptual models
Note an empty relation box in Fig. 2.5. Fill in its schema.
UML class diagrams
51 52
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab

Extending ER with Spatial


Concepts ER Diagram with Pictograms
Motivation
ER Model is based on discrete sets with no implicit relationships Fig 2.7
Spatial data comes from a continuous set with implicit relationships
Any pair of spatial entities has relationships like distance, direction,
Explicitly drawing all spatial relationship
clutters ER diagram
generates additional tables in relational schema
Misses implicit constraints in spatial relationships (e.g. partition)
Pictograms
Label spatial entities along with their spatial data types
Allows inference of spatial relationships and constraints
Reduces clutter in ER diagram and relational schema
Example: Fig. 2.7 (next slide) is simpler than Fig. 2.4

53 54
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab
Specifying Pictograms Basic Shapes and Collections
Grammar based approach  Basic Shape 
Rewrite rule  Pictogram   Shape 
like English syntax diagrams
Classes of pictograms !
Point Line Polygon
Entity pictograms
basic: point, line, polygon Grammar (for Pictogram) Grammar (for Basic Shape) Pictograms for Basic Shapes
collection of basic  Cardinality  0, 1
...
Relationship pictograms 1
 Shape   Basic Shape 
partition, network
 Multi-Shape  1, n
n 0, n
 Derived Shape  0, n

 Alternate Shape  n
Part_of(Network) Part_of(Partition)
Grammar (for Shape) Pictograms Multishapes
Pictograms for Relationships 55 Grammar (for Cardinality) (using cardinality) 56
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab

Conceptual Data Modeling with


Derived and Alternate Shapes
UML
Derived shape example is city center point from boundary polygon
Motivation
Alternate shape example: A road is represented as a polygon for construction
ER Model does not allow user defined operations
or as a line for navigation
Object oriented software development uses UML
 Derived Shape   Basic Shape  UML stands for Unified Modeling Language
It is a standard consisting of several diagrams
Grammar (for Derived Shape) Pictograms for Derived Shapes class diagrams are most relevant for data modeling

 Alternate Shape   Basic Shape   Derived Shape 


UML class diagrams concepts
Attributes are simple or composite properties
 Basic Shape   Basic Shape 
Methods represent operations, functions and procedures
Grammar (for Alternate Shape) Class is a collection of attributes and methods
Relationship relate classes
Example UML class diagram: Figure 2.8
Pictograms for Alternate Shapes
57 58
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab

UML Class Diagram with Comparing UML Class


Pictograms Diagrams to ER Diagrams
Exercise: Identify classes, attributes, methods, relationships in Fig. 2.8.
Compare Fig. 2.8 with corresponding ER diagram in Fig. 2.7. Concepts in UML class diagram vs. those in ER
River Road diagrams
Supplies-Water-To  Name  Name
 Volume * 

Length
GetName()


NumofLanes
GetName() Class without methods is an Entity
 GetLength()  GetNumofLanes()
supplies_water_to

Attributes are common in both models


*
LEGEND

Strong
UML does not have key attributes and integrity constraints
Facility * Forest Aggregation
 Name  Name
 Elevation Weak
ERD does not have methods
 GetName() 1 .. * belongs_to 1 *
accesses Aggregation
 GetName()
1  GetElevation():
Point
1 * .. * Cardinality Relationships properties are richer in ERDs
1..*
manages
Entities in ER diagram relate to datasets, but UML class
monitor

Fire-Station
1..*
Forest-Stand Manager
1
diagram
 Name  SpecieName  Name
 GetName()
1 .. * 

Age
Gender
can contain classes which have little to do with data
 GetSpecieName()
 GetName()
 GetAge()
 GetGender()
59 60
Mobile Computing & Software Engineering Lab Mobile Computing & Software Engineering Lab
Summary Summary
Spatial Information modeling can be classed A data model is a high level description of the
into Field based and Object based data
it can help in early analysis of storage cost, data
Field based for modeling smoothly varying
quality
entities, like rainfall
There are two popular models of spatial
Object based for modeling discrete entities, information
like country Field based and Object based
Database are designed in 3-steps
Conceptual, Logical and Physical
61
Pictograms can simplify Conceptual data 62
Mobile Computing & Software Engineering Lab models Mobile Computing & Software Engineering Lab

Das könnte Ihnen auch gefallen