38
Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint work with Christine PARENT & Christelle VANGENOT http://lbd.epfl.ch

From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

  • View
    213

  • Download
    0

Embed Size (px)

Citation preview

Page 1: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

From Reality to Databases:

a One-to-Many Relationship

Stefano SpaccapietraDatabase Laboratory Swiss Federal Institute of Technology Lausanne (EPFL)

joint work with

Christine PARENT & Christelle VANGENOT

http://lbd.epfl.ch

Page 2: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

2

Outline

Database design essentials

Multiple representation

Design alternatives

Page 3: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

3

Database Terminology

Database design (data modeling) is the activity to elaborate a formal representation of relevant information about some subset of the real world that is of interest for users (applications) of the data.

The outcome of the database design process is the schema of the database.

The formalism used to express the schema is a data model.

Database design essentials

Page 4: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

4

Data Model

A data model is a set of concepts and rules.

Relational data model: table/relation, attribute/column, tuple/row, primary key, foreign key, …

Entity-Relationship data model: entity, entity type, relationship, relationship type, attribute, role, cardinality, identifier, …

Object-oriented data model: object, class, attribute, reference attribute, is-a hierarchy, inheritance, …

Database design essentials

Page 5: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

5

SpatioTemporal

Evolution of Data Models

Expressive power

Data Models

Codasyl

Relational

ObjectOriented

ER

Extended ER

UMLODMG

Multi-representation

Database design essentials

Page 6: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

6

Database Design: the Analysis Phase

recognitionstructuring

A database is a representation of that part of reality we are interested in.

perception

Real World

Database design essentials

Page 7: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

7

Database Design : the Definition Phase

description

Jean is a young man. He is married to Arlette, and owns a green Honda CRV.

Database design essentials

Page 8: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

8

Fundamental Abstraction: Classification

Object class:Personproperties: - family name,

- first name - age, ...

From reality to representation:

Abstracting from details to think in more generic terms, e.g. in terms of object classes rather than individual objects.

Lisa Fred ….Dylan Anne ...Zoë

Database design essentials

Page 9: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

9

The Database Schema

A schema is a collection of types.

The database will store instances of these types.

An instance is a set of values taken by the properties attached to the type.

Person CarOwns

Married-to

Database design essentials

Page 10: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

10

Schema and Instances

Person HouseOwns0:n 1:1

Database design essentials

Page 11: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

11

Attributes of an Object Type

atomic,

mandatory,

monovalued

complex, optional, multivalued

Employee

Emp# Ename telephones academic-achievements positions

degree year title start-date end-date salaries

date amount

year month

Database design essentials

Page 12: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

12

Example of an ER schema

Department Item

Employee SupplierBoss-of

boss

subord.

Dname floor quantity Iname type

name salary Sname address

quantity R

E

Database design essentials

Assigned-to

Sells

Delivery

Page 13: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

13

Non-determinism in Database Design A database design is about choosing a representation

The outcome is a partial subjective unfaithful

description

How do we introduce flexibility to support different ways of abstracting a representation from reality ?

Database design essentials

Page 14: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

14

Multiple Classification

Car

Vintage Car

Collectible

Transport Mean

Vehicle

Land Vehicle

Ford

Imported GoodMovie Accessory

Multiple representation

Page 15: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

15

Multiple Viewpoints

ROADCartographer

viewpoint

Multiple representation

Construction engineerviewpoint

Traffic managerviewpoint

Page 16: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

16

Multiple Spatial Resolution

1:25'000 scale 1:50'000 scale

Page 17: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

17

Multidimensional Representation Space

Classification

Space granularity

Viewpoint

TimeTime granularity……

two representations of the same object in the same viewpoint at two different resolution levels

Multiple representation

Page 18: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

18

A Snapshot Database

Classification

Time

Viewpoint

Multiple representation

Page 19: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

19

A Map

Classification

Space granularity

Viewpoint

Road Network

1:100'000 resolution

Multiple representation

Page 20: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

20

Classification Dimension

students

facultiespersons

technicians

secretaries

• Current Status: refinement hierarchies

Person

Faculty TechnicianSecretary

StudentEmployee

faculties

technicians

secretaries

Is-a

Multiple representation

Page 21: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

21

Limitation: Roles

car-owners companiespersons

Person Car-owner Company

Person-with-car Company-with-carintersectionclasses

partition constraint

Car-owner = Person-with-carCompany-with-car

Person-with-car Company-with-car = Ø

Multiple representation

Page 22: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

22

A More Direct Representation

Car-owner

OR IS-ACar-owner CompanyPerson

MAY-BE-A MAY-BE-A

+ partition constraint

Intersection link

Multiple representation

Page 23: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

23

Viewpoint Dimension

Relational DBMS support (mostly non-updatable) views, but semantics is poor

Object-oriented DBMS have rich semantics but poor view mechanisms

Object-relational DBMS: ?

Object-oriented expressiveness augmented with intersection links, roles and revised inheritance rules will provide the best solution

Multiple representation

Page 24: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

24

Space Granularity: Multi-resolution Cartographic Generalization is costly:

-> store the result for reuse

How do we express the linksbetween different representations ?-> update propagation

Multiple representation

Page 25: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

25

Resolution Level 1 Resolution Level 2

Multiple Geometries for the Same Object

One possible solution : stamping spatial attributes with the spatial resolution

Spatial integrity constraints : Sinuosity (River.geometry[2]) = Sinuosity (River.geometry[1]) Length (River.geometry[2]) = Length (River.geometry[1])

River described as an area or as a

line

Rivermr geo

M

Multiple representation

Page 26: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

26

Multiple Abstraction Levels:

Reformulation Replacing a group of objects with a new object

Example: a set of buildings close to each other is replaced with a built-up area

Multiple representation

Page 27: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

27

Aggregation

Grouping of objects according to semantic and spatial relationships e.g., a set of buildings and

adjacent fields belonging to the same farmer grouped into a single object Farm

Derivation rules: Farm.geometry= Spatial Union

(Field.geometry,Building.geometry)

Aggregation constraint: the fields and the buildings composing

the same farm must belong to the same farmer and the fields must be adjacent.

Farm

Field Building

Composed

Composed

1,n1,n

Multiple representation

Page 28: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

28

Cartographic Approximation

No 1-1 or n-1 mapping between ground and cartographic buildings

N-m relationship

5 ground buildings (1,2,3,4,5)

represented by

3 cartographic buildings (a,b,c)

A ground building can participate into 0 or 1  typify  relationship

GroundBuildin

g

Cartographic

Buildingtypify

t = ( {1,2,3,4,5} , {a,b,c} )

Multiple representation

Page 29: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

29

Topological Relationships

Level 1

Level 2

At resolution level 1, the road is adjacent to the enbankment.

At resolution level 2, the embankment is no longer represented. The road is seen as adjacent to the building.

Embankment

Road

Near

M

M

M

Multiple representation

Page 30: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

30

Hierarchical value domains

Describe the same property at different abstraction levels Hierarchical value domains for attributes (similar to classification hierarchies for objects)

cultivated area

rose iriscarnation

flower cereal oleaginous

corn barley rape sunflower

Multiple representation

Page 31: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

31

Multidimensional Representation Space

Classification

Space granularity

Viewpoint

Time granularity

How is the representation space - presented to users?- implemented in Ddatabases?

Design alternatives

Page 32: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

32

Possible Design Architectures

One single schema

One schema per (combination of ) coordinate(s) on dimension(s)

One schema per …… with an intrinsic schema

Design alternatives

Page 33: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

33

A Single Schema

owner

landuseParcel

Building M

Cartographicbuilding

owner

landuse Parcel/use

agr/use

Parcel/ownerPlot

Castlecomposed

Typify

Road M along

near

on/under

Bridge

agr/owner

Design alternatives

Page 34: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

34

A multi-resolution schema per viewpoint

Building M

Cartographicbuilding

agr/owner

owner

landuse

landuseParcel/use

agr/use

Parcel/owner

Building MPlot Castlecomposed

Typify

Road M along

near

Parcel

Bridge

on/under

owner

Viewpoint 1

Viewpoint 2

Design alternatives

Page 35: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

35

A Schema Per Viewpoint and Resolution

Viewpoint AResolution 1

Design alternatives

inter-schemacorrespondences

Viewpoint AResolution 2

Viewpoint BResolution 2

Viewpoint BResolution 1

Page 36: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

36

agr/use

A Schema Per Resolution and Viewpoint

Cartographicbuilding

on

Building

Road

Building

Castle

Plot

Bridge

Road

On / under

Parcel/use

near

Parcel Parcel/owneragr/owner

composed

Design alternatives

Page 37: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

37

An Intrinsic Schema

Intrinsic schema : description of real world entities independently of any viewpoint

Intrinsic schema

schema Bschema A

Design alternatives

Page 38: From Reality to Databases: a One-to-Many Relationship Stefano Spaccapietra Database Laboratory Swiss Federal Institute of Technology Lausanne (EPFL) joint

38

Murmur IST Project (2000-2002)

A conceptual data model supporting space, time, and multirepresentation (extension of MADS)

A corresponding query language (multirepresentation algebra)

Two application cases (cartographic, risk assessment)

A schema editor for visual data definition (DDL)

A query editor for visual data manipulation (DML), including intelligent zooming and temporal travelling

Implementation on a commercial GIS