1 / 32

Personal

Personal. Name: Stephan Karczewski Professor for Computer Science at the University of Applied Sciences in Darmstadt, Germany http://www.fh-darmstadt.de Email: s.karczewski@fbi.fh-darmstadt.de. OO- vs. OR-Databases – What is the better choice?.

gari
Download Presentation

Personal

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Personal Name: Stephan Karczewski Professor for Computer Science at the University of Applied Sciences in Darmstadt, Germanyhttp://www.fh-darmstadt.de Email: s.karczewski@fbi.fh-darmstadt.de Platteville, 2005/10/07-03

  2. OO- vs. OR-Databases – What is the better choice? • Relational Databases are the most used databases in the last 20 years. • Object orientation in programming languages is the common approach of today´s software development. • Object oriented (OO) databases come from the OO approach in programming language and give the possibility to make object persistent (since end of the 1980s). • Object relational databases come from the relational database approach and opens this approach to object orientation (since mid of the 1990s). Platteville, 2005/10/07-03

  3. Object-Orientation in Databases • Object orientation in database means that • eight rules of object orientation and • five rules of data bases • are fullfilled. • What are the rules? Platteville, 2005/10/07-03

  4. Object-Orientation in Databases • Eight rules of object orientation: • Complex objects • Object identity • Encapsulation of data • Types and Classes • Inheritance • Polymorphism • Completeness • Extensibility • Five rules of databases: • Persistence • Large databases • Multi user operation • Recovery • Ad hoc query Platteville, 2005/10/07-03

  5. Object-Orientation in Databases • Some of the OO rules (e.g. encapsulation) don´t fit to the rules of databases (e.g. ad hoc query). • Compromises are needed. The most important of the rules will explained with the next slides. Platteville, 2005/10/07-03

  6. Object-Orientation in Databases • Complex objects: • In relational databases all attributes have to be in first normal form. • That means: each attribute has to be atomar. • The object orientation allows attributes which are • Tuples or • Lists or • Sets. • They don´t fullfil the first normal form. Platteville, 2005/10/07-03

  7. Object identifier (example) OID ArtId Name Prize 267 CB12 Contra bassoon 18.257087 BT38 Bach trumpet 4.802014 K6456 B89 Bassoon 14.980399 QB29 Quart bassoon 6.493046 flugelhorn 120 T46 trumpet 5.490904119 JZ94 Jazz trumpet 6.793 OID is the system key (not changeable). artId is the user defined key. There are objects without user defined key but not without OID. Platteville, 2005/10/07-03

  8. Object-Orientation in Databases Encapsulation of data: One important characteristic of object orientation is that the attributes are encapsulated by the methods. If a value of an attribute has to be changed, an object must send a message to the object and only if a method matches this message The value will be changed. In databases there is a ad-hoc query needed so that the user can make queries to the data direct (with SQL). This is a contradiction to the idea of object orientation. Platteville, 2005/10/07-03

  9. read price read price 259-693 Tenorsax 5.035 711-214 Bassoon 14.980 change price change price ... ... build list build list Encapsulation (example) attributes methods Tenorsax = Tenor-Saxophon Bassoon = Fagott Platteville, 2005/10/07-03

  10. Object-Orientation in Databases Types and Classes: If a database is object oriented it needs the possibility to define types and classes. Types are usefull to define complex structures. Classes are usefull to define one schema for similar objects. Remind: In relational databases a table scheme will be used to define a scheme for similar tuples (rows) in the table. Platteville, 2005/10/07-03

  11. Types and Classes (example) Object types will defined as classes (in the OO database Fast Objects (former POET) The used language is related to C++ DDL from Fast Objects class attributes Constructor Destructor methods Platteville, 2005/10/07-03

  12. Object-Orientation in Databases Inheritance: Inheritance can be used if an hierarchy of classes exist. One class can inherit attributes and methods from another when it is a specialist of the other class. This characteristic is helpful because methods don´t have to be defined more than once in a class from which others inherit. Platteville, 2005/10/07-03

  13. Instrument articleId name prize readPrice changePrice buildList WoodWindInstrument WindInstrument ... buildList Simple inheritance Simple means: The search process from hierarchy to hierarchy is definite. Search for attribute price and method changePrice in higher class WindInstrument found Search for attribute price and method changePrice in class WindInstrument not found Order: Increase price of bassoon 711-214 for 8% Platteville, 2005/10/07-03

  14. WindInstrument HarmonicaInstrument KeyboardInstrument Multiple inheritance 1. 2. 1. Order: number of keys; will be found in KeybordInstrument 2. Order: pressure of wind: will be found in WindInstrument Platteville, 2005/10/07-03

  15. Inheritance (example) Specialisation (example): trader (Händler), forwarding (Spediteur), customer (Kunde), organizer (Veranstalter) are special business partner Platteville, 2005/10/07-03

  16. Different Inheritance structures • disjoint and complete • disjoint and incomplete • overlapping and complete • overlapping and incomplete Platteville, 2005/10/07-03

  17. WindInstrument PercussionInstrument Disjoint and Complete abstract class Instrument {disjoint, complete} There are no instruments which are neither Wind- nor PercussionInstrument. WindInstrument There are no instruments which are simultaneously Wind- and Percussion- Instrument PercussionInstrument Platteville, 2005/10/07-03

  18. WindInstrument PercussionInstrument Disjoint and Incomplete Normal (not abstract) class Instrument {disjoint, incomplete} There are some instruments which are neither Wind- nor PercussionInstrument. WindInstrument There are no instruments which are simultaneously Wind- and Percussion- Instrument PercussionInstrument Platteville, 2005/10/07-03

  19. WindInstrument KeyboardInstrument Overlapping and Complete abstract class Instrument {overlapping, complete} There are no instruments which are neither Wind- nor KeyboardInstrument. WindInstrument KeyboardInstrument There are some instruments which are simultaneously Wind- and Keyboard- Instrument. Platteville, 2005/10/07-03

  20. WindInstrument KeyboardInstrument Overlapping and Incomplete Normal (not abstract) class Instrument {overlapping, incomplete} There are some instruments which are neither Wind- nor KeyboardInstrument. WindInstrument KeyboardInstrument There are some instruments which are simultaneously Wind- and Keyboard- Instrument Platteville, 2005/10/07-03

  21. WindInstrument KeyboardInstrument AccordionInstrument Overlapping and Incomplete Overlapping can be solved by defining a new class. This class contains all elements of the former intersection set. Instrument WindInstrument KeyboardInstrument {disjoint, complete} AccordionInstrument Platteville, 2005/10/07-03

  22. Instrument articleId name prize readPrice changePrice buildList WoodWindInstrument WindInstrument ... buildList Polymorphism and Overriding (example) Overriding means: There are same named methods in a hierarchy. BuildList in WindInstruments overrides buildList in Instrument.The method buildList is polymorph. The method for Instruments will be used. Order from Instrument: Give a list of Instruments The special method for windInstruments will be used. Order from WoodWindInstrument: Give a list of Instruments Platteville, 2005/10/07-03

  23. Transformation of OO components Association (example): Set of references to markets (Markt) (*) Reference to a promoter (Veranstalter) (1) Platteville, 2005/10/07-03

  24. Transformation of OO components Association with association class: Set of references to offer (Angebot) (*) Set of references to offer (Angebot) (*) Reference to product (1) Reference to market (1) Platteville, 2005/10/07-03

  25. Disadvantage of OO Databases OODBS made a revolution in the database world. The systems have not been compatible to the used relational systems. Many companies didn´t use the OODBS because the didn´t like the idea to migrate the mass of data they had. Today OODBS are used only in a niche of the database world. Platteville, 2005/10/07-03

  26. Advantage of OR Databases ORDBS made an evolution in the database world. The systems are upwords compatible to the used relational systems. Today ORDBS come in use more and more because the user does not need to migrate the old data. In the following slides there will be shown some examples which enlarge the possibilities of relational databases with object oriented features. Platteville, 2005/10/07-03

  27. Complex objects in ORDBS (Oracle) product is a structured type participants is a table of products Market is a table with a table (participants) in it Platteville, 2005/10/07-03

  28. Structure of the defined ORDBS table row One row contains two (!) paticipants. Platteville, 2005/10/07-03

  29. Insert command (ORSQL, Oracle) A constructor will used to define a table defined attribute. Platteville, 2005/10/07-03

  30. Update command (ORSQL, Oracle) A subselect is used to select all paticipants which are in a sub table of the market. An alias is used (and needed) to update all sub rows. Platteville, 2005/10/07-03

  31. Select command (ORSQL, Oracle) The name, position and category of the market and the number of paticipants (in a subselect) will be selected in this statement. Platteville, 2005/10/07-03

  32. Select command (ORSQL, Oracle) The number and position of all markets will be selected, in which more than 2 participants (as subselect) are. Platteville, 2005/10/07-03

More Related