Data and Process Modelling - Lab 3. Relational Mapping in...

17
Data and Process Modelling Lab 3. Relational Mapping in NORMA Marco Montali KRDB Research Centre for Knowledge and Data Faculty of Computer Science Free University of Bozen-Bolzano A.Y. 2014/2015 Marco Montali (unibz) DPM - Lab3.RMap A.Y. 2014/2015 1 / 14

Transcript of Data and Process Modelling - Lab 3. Relational Mapping in...

Page 1: Data and Process Modelling - Lab 3. Relational Mapping in NORMAmontali/teaching/1415/dpm/slides/lab3.pdf · 2015-04-13 · DataandProcessModelling Lab3. RelationalMappinginNORMA MarcoMontali

Data and Process ModellingLab 3. Relational Mapping in NORMA

Marco Montali

KRDB Research Centre for Knowledge and DataFaculty of Computer Science

Free University of Bozen-Bolzano

A.Y. 2014/2015

Marco Montali (unibz) DPM - Lab3.RMap A.Y. 2014/2015 1 / 14

Page 2: Data and Process Modelling - Lab 3. Relational Mapping in NORMAmontali/teaching/1415/dpm/slides/lab3.pdf · 2015-04-13 · DataandProcessModelling Lab3. RelationalMappinginNORMA MarcoMontali

E-R: Abstract Representation of Data

• Introduced by Peter Chen (1976).• The most widely used approach to data modeling.• Key notions:

I entities, relationships, attributes;I identification and multiplicity constraints.

• Independent from the target software platform.• Lack of dynamic modeling.• Close to relational database schemas → logical relational modeling!• Different notations/dialects:

I Chen, Barker, IE, IDEF1X, EXPRESS . . .Marco Montali (unibz) DPM - Lab3.RMap A.Y. 2014/2015 2 / 14

Page 3: Data and Process Modelling - Lab 3. Relational Mapping in NORMAmontali/teaching/1415/dpm/slides/lab3.pdf · 2015-04-13 · DataandProcessModelling Lab3. RelationalMappinginNORMA MarcoMontali

Barker Notation• Proposed by Richard Barker in 1990.• Used by Oracle in its CASE tools (together with UML).• Entity types represented as rounded rectangles.• Attributes compactly modeled inside the entity types.• Annotations are attached to attributes to model their participation: ∗for mandatory, ◦ for optional, # for stating that the attribute is partof the entity’s PK.

• Relationships restricted to binaries (not the case for all E-R dialects).• Constraints on roles modeled by graphical elements on therelationships.

I Participation: solid half-line for mandatory, dotted half-line for optional.I Cardinality: crow’s foot (fork) for many, absence of crow’s foot for one.

• Verbalization of relationship R between A and B:Each A (must | may) be R (one and only one B | one ormore B-plural-form)

Marco Montali (unibz) DPM - Lab3.RMap A.Y. 2014/2015 3 / 14

Page 4: Data and Process Modelling - Lab 3. Relational Mapping in NORMAmontali/teaching/1415/dpm/slides/lab3.pdf · 2015-04-13 · DataandProcessModelling Lab3. RelationalMappinginNORMA MarcoMontali

Simple Example

RoomEmployeeoccupies / is occupied by

RoomEmployeean occupier of

occupied by

Marco Montali (unibz) DPM - Lab3.RMap A.Y. 2014/2015 4 / 14

Page 5: Data and Process Modelling - Lab 3. Relational Mapping in NORMAmontali/teaching/1415/dpm/slides/lab3.pdf · 2015-04-13 · DataandProcessModelling Lab3. RelationalMappinginNORMA MarcoMontali

Simple Example

RoomEmployeeoccupies / is occupied by

RoomEmployeean occupier of

occupied by

Marco Montali (unibz) DPM - Lab3.RMap A.Y. 2014/2015 4 / 14

Page 6: Data and Process Modelling - Lab 3. Relational Mapping in NORMAmontali/teaching/1415/dpm/slides/lab3.pdf · 2015-04-13 · DataandProcessModelling Lab3. RelationalMappinginNORMA MarcoMontali

ORM-Barker Correspondences

Marco Montali (unibz) DPM - Lab3.RMap A.Y. 2014/2015 5 / 14

Page 7: Data and Process Modelling - Lab 3. Relational Mapping in NORMAmontali/teaching/1415/dpm/slides/lab3.pdf · 2015-04-13 · DataandProcessModelling Lab3. RelationalMappinginNORMA MarcoMontali

ORM-Barker Correspondences

Marco Montali (unibz) DPM - Lab3.RMap A.Y. 2014/2015 6 / 14

Page 8: Data and Process Modelling - Lab 3. Relational Mapping in NORMAmontali/teaching/1415/dpm/slides/lab3.pdf · 2015-04-13 · DataandProcessModelling Lab3. RelationalMappinginNORMA MarcoMontali

Identification Bars

• Used in Barker notation to denote that the relationship is acomponent of the PK for the entity type at that end.

Marco Montali (unibz) DPM - Lab3.RMap A.Y. 2014/2015 7 / 14

Page 9: Data and Process Modelling - Lab 3. Relational Mapping in NORMAmontali/teaching/1415/dpm/slides/lab3.pdf · 2015-04-13 · DataandProcessModelling Lab3. RelationalMappinginNORMA MarcoMontali

Subtyping• Barker notation only supports partitions.• Exclusive subtyping is implicitly supported by adding a furthersubtype to represent “other” cases.

• No support for overlapping subtypes.

Marco Montali (unibz) DPM - Lab3.RMap A.Y. 2014/2015 8 / 14

Page 10: Data and Process Modelling - Lab 3. Relational Mapping in NORMAmontali/teaching/1415/dpm/slides/lab3.pdf · 2015-04-13 · DataandProcessModelling Lab3. RelationalMappinginNORMA MarcoMontali

Exclusion ConstraintsModeled in Barker notation by connecting the half-lines of the involvedrelationships.

In case of exclusive-or (exclusion + disjunctive inclusion), then thehalf-lines are depicted as solid lines, and then connected as before.

Marco Montali (unibz) DPM - Lab3.RMap A.Y. 2014/2015 9 / 14

Page 11: Data and Process Modelling - Lab 3. Relational Mapping in NORMAmontali/teaching/1415/dpm/slides/lab3.pdf · 2015-04-13 · DataandProcessModelling Lab3. RelationalMappinginNORMA MarcoMontali

Topics

• Learn how to obtain an E-R representation starting from an ORMconceptual schema.

• Learn how to obtain the vertical layout modeling the relationalschema resulting from the application of Rmap to an ORMconceptual schema(see tutorial 8 on ormfoundation.net for details).

• Learn how to obtain the corresponding SQL code(see tutorial 1 on ormfoundation.net for details).

• Apply these techniques to different examples, possibly withhierarchies.

Marco Montali (unibz) DPM - Lab3.RMap A.Y. 2014/2015 10 / 14

Page 12: Data and Process Modelling - Lab 3. Relational Mapping in NORMAmontali/teaching/1415/dpm/slides/lab3.pdf · 2015-04-13 · DataandProcessModelling Lab3. RelationalMappinginNORMA MarcoMontali

Key Points

• To map an ORM schema to a corresponding E-R diagram in Barkernotation, then just enable the “Barker Notation” view in theextension manager (right click in the main panel).

• Similarly for relational mapping.• Observe that some constraints are “lost” in the translation process.

• To define different strategies for relational mapping of ORMhierarchies, then just click on the subtype and change theAbsorptionChoice property.

Marco Montali (unibz) DPM - Lab3.RMap A.Y. 2014/2015 11 / 14

Page 13: Data and Process Modelling - Lab 3. Relational Mapping in NORMAmontali/teaching/1415/dpm/slides/lab3.pdf · 2015-04-13 · DataandProcessModelling Lab3. RelationalMappinginNORMA MarcoMontali

CD Shop ORM Conceptual Schema

Marco Montali (unibz) DPM - Lab3.RMap A.Y. 2014/2015 12 / 14

Page 14: Data and Process Modelling - Lab 3. Relational Mapping in NORMAmontali/teaching/1415/dpm/slides/lab3.pdf · 2015-04-13 · DataandProcessModelling Lab3. RelationalMappinginNORMA MarcoMontali

Skaters Schema

ProblemBuild a relational schema corresponding to the ORM schema, followingthe Rmap procedure and adopting the partition strategy to deal withhierarchies. For each relation schema, highlight the primary key,alternative keys, mandatory and optional attributes. Furthermore, depictall relevant constraints, paying particular attention to foreign keys.

TaskStart by circling the elements of the schema that collapse into a uniquetable. For each relation schema that you produce, highlight the primarykey, alternative keys, mandatory and optional attributes. Depict allrelevant constraints, paying particular attention to foreign keys.

Marco Montali (unibz) DPM - Lab3.RMap A.Y. 2014/2015 13 / 14

Page 15: Data and Process Modelling - Lab 3. Relational Mapping in NORMAmontali/teaching/1415/dpm/slides/lab3.pdf · 2015-04-13 · DataandProcessModelling Lab3. RelationalMappinginNORMA MarcoMontali

Skaters SchemaProblemBuild a relational schema corresponding to the ORM schema, followingthe Rmap procedure and adopting the partition strategy to deal withhierarchies. For each relation schema, highlight the primary key,alternative keys, mandatory and optional attributes. Furthermore, depictall relevant constraints, paying particular attention to foreign keys.

Marco Montali (unibz) DPM - Lab3.RMap A.Y. 2014/2015 13 / 14

Page 16: Data and Process Modelling - Lab 3. Relational Mapping in NORMAmontali/teaching/1415/dpm/slides/lab3.pdf · 2015-04-13 · DataandProcessModelling Lab3. RelationalMappinginNORMA MarcoMontali

Program Committee Schema

ProblemBuild a relational schema corresponding to the ORM schema, followingthe Rmap procedure and adopting:

• the partition strategy to deal with the PC Member hierarchy;• the absorption strategy to deal with the Paper hierarchy.

TaskStart by circling the elements of the schema that collapse into a uniquetable. For each relation schema that you produce, highlight the primarykey, alternative keys, mandatory and optional attributes. Depict allrelevant constraints, paying particular attention to foreign keys.

Marco Montali (unibz) DPM - Lab3.RMap A.Y. 2014/2015 14 / 14

Page 17: Data and Process Modelling - Lab 3. Relational Mapping in NORMAmontali/teaching/1415/dpm/slides/lab3.pdf · 2015-04-13 · DataandProcessModelling Lab3. RelationalMappinginNORMA MarcoMontali

Program Committee SchemaProblemBuild a relational schema corresponding to the ORM schema, followingthe Rmap procedure and adopting:

• the partition strategy to deal with the PC Member hierarchy;• the absorption strategy to deal with the Paper hierarchy.

Marco Montali (unibz) DPM - Lab3.RMap A.Y. 2014/2015 14 / 14