150 likes | 310 Views
OODB, Object-Oriented Mappings. By: Blake Peters. OODB. OODB- Object Oriented Database An OODB is a database management system in which information is represented in the form of objects as used in object oriented programming.
E N D
OODB, Object-Oriented Mappings By: Blake Peters
OODB • OODB- Object Oriented Database • An OODB is a database management system in which information is represented in the form of objects as used in object oriented programming. • OODBs are different from relational databases which are table oriented.
OODB • OODBs combine database capabilities with object-oriented programming language capabilities. • Allow object-oriented programmers to develop the product, store them as objects, and replicate or modify existing objects to make new objects.
OODB • Like relational databases use SQL to query tables, OODBs use OQL (Object Query Language) to query objects • Objects can be retrieved directly without a search, by following pointers. • Allows faster access to data because joins are often not needed.
OQL • Object Query Language syntax: • SELECT * FROM [ INSTANCEOF ] <class name> [ WHERE <filter-expression> ]
Object-Relational Mapping • Object-relational mapping (ORM) is a programming technique for converting data between incompatible type systems in object-oriented programming languages. • This creates a “virtual database” that can be used from within the programming language
ORM • Compared to traditional techniques of exchange between an object-oriented language and a relational database, ORM often reduces the amount of code that needs to be written
ORM • Using ORM in OODBs eliminates the need for converting data to and from its SQL form, as the data is stored in its original object representation and relationships are directly represented, rather than requiring join tables/operations.
Example • Consider an address book entry that represents a single person along with zero or more phone numbers and zero or more addresses • Using and OODB with ORM a “Person object” could be implemented with attributes/fields to hold each data item that the entry comprises: person’s name, list of phone numbers, and list of addresses.
Example con’t • The list of phone numbers whould itself contain “PhoneNumber objects” and so on • The address book entry is treated as a single object by the programming language (it can be referenced by a single variable containing a pointer to the object) • Methods could be written to return the desired phone number, address, etc
Example con’t • Without the use of these object mappings, retrieving data is more difficult using SQL • SQL DBMS can only store and manipulate scalar values such as integers and strings organized within tables. • The programmer must either convert the object values into groups of simpler values for storage in the database, or only use simple scalar values within the program.
Example con’t • This causes more coding for retrieval of values, and slower data access times