1. How are objects stored in a database?
Code (that implements methods) should be stored in the database as part of the schema, along with type definitions, but many implementations store them outside of the database, to avoid having to integrate system software such as compilers with the database system.
Data: stored individually for each object.
2. How to find the objects?
(a) Give names to objects like we give names to files: works only for small sets of objects.
(b) Expose object identifiers or persistent pointers to the objects:
(c) Store the collections of object and allow programs to iterate over the collections to find required objects.
The collections can be modeled as objects of a collection type. A special case of a collection is a class extent, which is a collection of all objects belonging to the class.Most OODB systems support all three ways of accessing persistent objects. All objects have object identifiers.
Names are typically given only to class extents and other collection objects, and perhaps to other selected objects, but most objects are not given names. Class extents are usually maintained for all classed that can have persistent objects, but in many implementations, they contain only persistent objects of the class.
class Person: public Persistence Object {
public:
String name;
String address;
}
class Customer: public Person {
public:
Date member from;
int customer id;
Ref hBranch ihome branch;
Set hRef hAccount iiaccounts inverse Account: owners;
}
class Account: public Persistent_Object {
private:
int balance;
public:
int number;
Set hRef hCustomer iiowners inverse Customer: accounts;
int find balance();
int update balance(int delta);
}
Figure 8.7: Example of ODMG C++ Object De nition Language
