Department of Geoinformation Science Technische Universität Berlin WS 2006/07 Geoinformation Technology: lecture 3 Mapping of OO Models onto Tables Prof. Dr. Thomas H. Kolbe Institute for Geodesy and Geoinformation Science Technische Universität Berlin Credits: This material is mostly an english translation of the course module no. 2 (‘Geoobjekte und ihre Modellierung‘) of the open e-content platform www.geoinformation.net .
34
Embed
Geoinformation Technology: lecture 3 Mapping of OO Models onto Tables
Geoinformation Technology: lecture 3 Mapping of OO Models onto Tables. Prof. Dr. Thomas H. Kolbe Institute for Geodesy and Geoinformation Science Technische Universität Berlin. - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Department of Geoinformation Science
Technische Universität Berlin
WS 2006/07
Geoinformation Technology: lecture 3
Mapping of OO Models onto Tables
Prof. Dr. Thomas H. Kolbe
Institute for Geodesy and Geoinformation ScienceTechnische Universität Berlin
Credits: This material is mostly an english translation of the course module no. 2 (‘Geoobjekte und ihre Modellierung‘) of the open e-content platform www.geoinformation.net.
WS 2006/072 T. H. Kolbe – Geoinformation Technology: lecture 3
Department of Geoinformation Science
Mapping onto Tables
WS 2006/073 T. H. Kolbe – Geoinformation Technology: lecture 3
Department of Geoinformation Science
Mapping onto Tables: Overview
Motivation of the relational data model
From objects to tables
Mapping of objects
Keys
Mapping of relationships
Referential integrity
Special cases: aggregation and generalization,
Queries to databases
Further simplification
Structures of ESRI ArcMap
WS 2006/074 T. H. Kolbe – Geoinformation Technology: lecture 3
Department of Geoinformation Science
Relational Data Model: Motivation
until now . . .
Mapping of reality onto structures and processes of an
information system
Description of the logical structure of the data, its properties,
its behavior and its interrelationships
now...
How are the data mapepd onto the structures of a concrete
database system?
Relational data model
WS 2006/075 T. H. Kolbe – Geoinformation Technology: lecture 3
Department of Geoinformation Science
Mapping: From Objects to Tables
state district municipalityn - name: string
- inhabitants: number - area: number
+ getname( ): string+ getinhabitants( ):number+ getarea( ): number
- name: string - inhabitants: number - area: number
+ getname( ): string+ getinhabitants( ):number+ getarea( ): number
- name: string - inhabitants: number - area: number
+ getname( ): string+ getinhabitants( ):number+ getarea( ): number
n
Classes and associations are represented by tables, i.e. relations
WS 2006/076 T. H. Kolbe – Geoinformation Technology: lecture 3
Department of Geoinformation Science
Mapping: Terms and Concepts
A relational database consists of one or more tables (relations)
The columns of a table are called attributes and are typed wrt. a value domain
The rows of a table are called tuples
Each relation is identified by a relation name
The set of attributes together with the relation name determine the structure of a table, the relational schema
name A1 . . . . . . AN
. . . . . . . . . . . .
. . .
Relational schema attribute
tuple
attribute value
WS 2006/077 T. H. Kolbe – Geoinformation Technology: lecture 3
Department of Geoinformation Science
Mapping: Rules for Objects
Every class corresponds (at least) to one table
The name of the table corresponds to the name of the class
Each object attribute corresponds to a table attribute (only for scalar valued attributes)
Typically an „identifier" is introduced as an additional table attribute representing the identity of the object
The identifier forms the primary key of the table
Methods are not taken into account
Representation of the relational schema:
NAME (identifier, attribute 1,..., attribute n)
class
attribute 1attribute 2. . .attribute n
WS 2006/078 T. H. Kolbe – Geoinformation Technology: lecture 3
- name: string - inhabitants: number - area: number
+ getname( ): string+ getinhabitants( ):number+ getarea( ): number
river
- name: string - length: number
+ getname( ): string+ getlength( ):number
m
n
flows through
WS 2006/0713 T. H. Kolbe – Geoinformation Technology: lecture 3
Department of Geoinformation Science
Mapping: Referential Integrity
Integrity assumption: existence of the associated tuples ("referential integrity"): For attributes of a relationship table there exist identifiers in the relations of the involved classes
Error case: A "pointer" to an object that leads into the void ("Dangling Pointer")
WS 2006/0714 T. H. Kolbe – Geoinformation Technology: lecture 3
Department of Geoinformation Science
Example for a Dangling Pointer
flows_through riverId countryId
11…20
11 (=Rheinland-Pfalz)10 (=NRW)
2 (=Bayern)
river riverId name
12…1921…
RheinDonau
…Elbe
Weser
length
1.3202.850
…1.165440
?
WS 2006/0715 T. H. Kolbe – Geoinformation Technology: lecture 3
Department of Geoinformation Science
Mapping: Special Case 1:n Relationship
Refinement / simplification of the general mapping schema for n:m associations
Aggregation and composition usually are 1:n relationships an object of class 1 (aggregate class) is in relation with n
objects of class 2 (component class) Relational schema: NAME(aggregateClassId, componentClassId) Question: Why is the key of the component class key of the
relationship table? Integration / elimination of relations
The relationship is added as a further attribute to the component class (see example on next slide)
Please note: This is an integration of relations having the same key!
Advantage: Saving of an additional table
WS 2006/0716 T. H. Kolbe – Geoinformation Technology: lecture 3
WS 2006/0719 T. H. Kolbe – Geoinformation Technology: lecture 3
Department of Geoinformation Science
Mapping of the Generalization Association
Generalization is a 1:1 relationship (between tables!)
There is no explicit relationship that is representable as a relation (table) – there exists only a hierarchy of classes
Two options for modelling generalization associations
Option 1: Extend the relations (tables) representing the superclass and all subclasses by an additional attribute objectId, which realizes the connection between superclass and subclass
- or adopt the primary key of the top most superclass (transitively) in any subclass
Option 2: Extend all tables representing the subclasses by the attributes of the superclass
WS 2006/0720 T. H. Kolbe – Geoinformation Technology: lecture 3
Department of Geoinformation Science
Generalization Example – Option 1
geomFigure(objectId, centerpoint, visible)
triangle(objectId, a,b,c)
geomFigure
-centerpoint: point-visible: boolean
+display()+delete()+move()
circle
-radius: number
+display()+delete()
rectangle
-a: number-b: number
+display()+delete()
triangle
-a: number-b: number-c: number
+display()+delete()
In order to get the full information about a triangle, the relations geomFigure and triangle must be joined.
WS 2006/0721 T. H. Kolbe – Geoinformation Technology: lecture 3
Department of Geoinformation Science
Generalization Example – Option 2
triangle(objectId, centerpoint, visible, a,b,c)
geomFigure
-centerpoint: point-visible: boolean
+display()+delete()+move()
circle
-radius: number
+display()+delete()
rectangle
-a: number-b: number
+display()+delete()
triangle
-a: number-b: number-c: number
+display()+delete()
• There are only specialized relations.
• The inheritance is no longer visible.
• No instances of geomFigure possible
WS 2006/0722 T. H. Kolbe – Geoinformation Technology: lecture 3