Download presentation
Presentation is loading. Please wait.
Published byMaría Carmen Domínguez Maidana Modified over 6 years ago
1
Mapping UML to RDB, 14.01.2019 - J.P.Nytun – page 1
Mapping Objects to Relational Databases Mapping UML to RDB, J.P.Nytun – page 1
2
Mapping UML to RDB, 14.01.2019 - J.P.Nytun – page 2
Why This Mapping? Object technology, like Java, is in wide use and relational databases are the preferred approach for storage of persistent information. The relational paradigm is based on mathematical principles: Set theory. The object paradigm has a quite different basis: Inheritance, encapsulation,…. Mapping UML to RDB, J.P.Nytun – page 2
3
Why This Mapping Continues...
In the object paradigm objects are traversed by following links between objects (a link can be an instance of an ordinary association). In the relational paradigm rows in different tables are connected with foreign keys (joining rows in different tables). (Mapping from UML class diagrams to tables and then back to class diagrams will lead to loss of information.) Mapping UML to RDB, J.P.Nytun – page 3
4
UML to Relational Mapping: Class to Table
Class diagram B is a derived attribute. C a : Integer c : Double /b : Integer NB! Not all classes are persistent. Table Table: C A: Integer C: Double Mapping UML to RDB, J.P.Nytun – page 4
5
UML to Relational Mapping: one-to-one associations
X Y x_pkey x_a1 y_pkey y_a1 1 Total participation Class diagram Object diagram X1 Y2 X2 Y3 X3 Y1 x_pkey Tables: Three different solutions x_a1 y_pkey y_a1 Table: XY Table: X and Y Table: Y and X Mapping UML to RDB, J.P.Nytun – page 5
6
UML to Relational Mapping: one-to-many associations
Object diagram X Y x_pkey x_a1 y_pkey y_a1 1 * Class diagram X1 Y2 X2 Y1 Y3 X3 Y4 X4 Tables: One possible solution y_pkey y_a1 x_pkey x_a1 Table: Y Table: X Mapping UML to RDB, J.P.Nytun – page 6
7
UML to Relational Mapping: many-to-many associations
Object diagram X1 Y2 Y3 X2 Y1 X4 Y4 X3 X Y x_pkey x_a1 y_pkey y_a1 * Class diagram Tables: One possible solution y_pkey y_a1 x_a1 Table: Y x_pkey Table: X Table: XY Mapping UML to RDB, J.P.Nytun – page 7
8
Mapping UML to RDB, 14.01.2019 - J.P.Nytun – page 8
Example Type name 1 1 Unit * * Search name Consist word * * description * * * * sequenceNo : int Collection Atom * * url Mapping UML to RDB, J.P.Nytun – page 8
9
Mapping UML to RDB, 14.01.2019 - J.P.Nytun – page 9
Mapping to Tables - 1 Unit typeId name Type unitId name description typeId Type name 1 1 Unit * * Search searchId word Search name word description * * * * UnitSearch unitId searchId Mapping UML to RDB, J.P.Nytun – page 9
10
Mapping to Tables - 2A unitId name description Unit typeId url
Collection Atom Here is only one solution presented ( [2] has four different solutions) Unit name description Collection Atom url Mapping UML to RDB, J.P.Nytun – page 10
11
Mapping to Tables - 2B Using the object relational features of Postgres CREATE TABLE Unit (id INTEGER, name VARCHAR(150), description VARCHAR(500), typeId INTEGER) CREATE TABLE Atom (url VARCHAR(180)) INHERITS (Unit) CREATE TABLE Collection() INHERITS (Unit) Unit name description Collection Atom url Mapping UML to RDB, J.P.Nytun – page 11
12
Mapping UML to RDB, 14.01.2019 - J.P.Nytun – page 12
Mapping to Tables - 3 Unit {ordered} name Consist * * description sequenceNo : int Collection * * unitId collectionId Consist sequenceNo Collection Unit unitId unitId name description typeId Mapping UML to RDB, J.P.Nytun – page 12
13
Mapping UML to RDB, 14.01.2019 - J.P.Nytun – page 13
References [1]Grady Booch, James Rumbaugh, Ivar Jacobson: The Unified Modeling Language User Guide. Addison-Wesley, 1999 [2]Elmasri, Navathe: Fundamentals of database Systems. Addison-Wesley, 2000 [3]Grady Booch, James Rumbaugh, Ivar Jacobson: The Unified Modeling Language Reference Manual. Addison-Wesley, 1999 Mapping UML to RDB, J.P.Nytun – page 13
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.