Download presentation
Presentation is loading. Please wait.
Published byPhilip Atkinson Modified over 9 years ago
1
1 Presentation by Irina Kogan. November 27, 2000. Presentation by Irina Kogan. November 27, 2000.
2
2 Background 4 Business Object Notation (BON) –object-oriented modeling language (classes and objects) –inheritance, association, aggregation, constraints expressed in class invariants –two notations: textual and graphical 4 Relational Databases –What does a relation consist of? relational instance (table) relational schema describing the column heads for the table –Entity-Relationship (ER) diagrams and SQL structural constraints, check constraints, assertions, triggers
3
3 Motivation 4 Objects have identity, state, and behaviour in addition to data. 4 A relational database stores data only. 4 In spite of these differences, a relational database as well as BON have strong mechanisms for expressing semantic constraints. 4 As the importance of databases and people’s reliance on them have grown, a mapping strategy built on a solid understanding of the similarities and differences of these models is more needed than ever.
4
4 Inheritance (BON -> ER) : :
5
5 Association (BON -> ER) 4 3 possibilities for mapping associations: many-to-many many-to-one one-to-one relationships 4 Example:..
6
6 Mapping class invariants to check constraints 4 Example (uses the association diagrams on the previous slide): –Specify the following constraints (in BON and in SQL): a sailor’s rating must be an integer in the range 1 to 10 no sailor can reserve a green boat
7
7 Mapping class invariants to check constraints (cont’d) CREATE TABLE Reserves (sid INTEGER, bid INTEGER, day DATE, PRIMARY KEY (sid, bid), FOREIGN KEY (sid) REFERENCES Sailors, FOREIGN KEY(bid) REFERENCES Boats, CONSTRAINT NoGreenBoats CHECK (‘green’ <> (SELECT B.color FROM Boats B WHERE B.bid = Reserves.bid))) CREATE TABLE Reserves (sid INTEGER, bid INTEGER, day DATE, PRIMARY KEY (sid, bid), FOREIGN KEY (sid) REFERENCES Sailors, FOREIGN KEY(bid) REFERENCES Boats, CONSTRAINT NoGreenBoats CHECK (‘green’ <> (SELECT B.color FROM Boats B WHERE B.bid = Reserves.bid))) Simple check constraints : CREATE TABLE Sailors (sid INTEGER, name CHAR(15), rating INTEGER, PRIMARY KEY(sid), CHECK (rating >= 1 and rating <= 10)) CREATE TABLE Sailors (sid INTEGER, name CHAR(15), rating INTEGER, PRIMARY KEY(sid), CHECK (rating >= 1 and rating <= 10)) Check constraints involving queries : Many-to-many relationship => 1 class -> 2 tables
8
8 Additional mapping strategies 4 Aggregation -> weak entities 4 Clusters -> aggregation in ER-diagrams (no direct correspondence in all cases) 4 Specifying state change: use of the keyword old in BON, use of triggers in SQL 4 Mapping was also successful for: bidirectional links self references 4 Note: use object ids (OIDs) for primary keys tables are persistent objects void is similar to null (except for void references) message passing can be modelled via triggers in some cases
9
9 Summary 4 Many people believe that relational databases will evolve in time and that the vast majority of organizations will start mapping objects to relational databases. 4 This research has proven that most of semantic constraints expressed in BON can be successfully mapped to those in relational databases. The additional work described in the literature read on the subject has shown that objects themselves can be mapped successfully.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.