* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Relational Databases
Survey
Document related concepts
Transcript
Presentation by Irina Kogan. November 27, 2000. 1 Background Business Object Notation (BON) – object-oriented modeling language (classes and objects) – inheritance, association, aggregation, constraints expressed in class invariants – two notations: textual and graphical 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 2 Motivation Objects have identity, state, and behaviour in addition to data. A relational database stores data only. In spite of these differences, a relational database as well as BON have strong mechanisms for expressing semantic constraints. 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. 3 Inheritance (BON -> ER) : 4 Association (BON -> ER) 3 possibilities for mapping associations: • many-to-many • many-to-one • one-to-one relationships Example: . 5 Mapping class invariants to check constraints 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 6 Mapping class invariants to check constraints (cont’d) Many-to-many relationship => 1 class -> 2 tables Simple check constraints: CREATE TABLE Sailors (sid INTEGER, name CHAR(15), rating INTEGER, PRIMARY KEY(sid), CHECK (rating >= 1 and rating <= 10)) Check constraints involving queries: 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))) 7 Additional mapping strategies Aggregation -> weak entities Clusters -> aggregation in ER-diagrams (no direct correspondence in all cases) Specifying state change: use of the keyword old in BON, use of triggers in SQL Mapping was also successful for: • bidirectional links • self references 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 8 Summary Many people believe that relational databases will evolve in time and that the vast majority of organizations will start mapping objects to relational databases. 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. 9