Chapter_2_Object_DB_Standard_Language_Design
Chapter_2_Object_DB_Standard_Language_Design
interface Date:Object {
enum weekday{sun,mon,tue,wed,thu,fri,sat};
enum Month{jan,feb,mar,…,dec};
unsigned short year();
unsigned short month();
unsigned short day();
…
boolean is_equal(in Date other_date);
};
Built-in Interfaces for
Collection Objects
◼ A collection object inherits the basic
collection interface, for example:
◼ cardinality()
◼ is_empty()
◼ insert_element()
◼ remove_element()
◼ contains_element()
◼ create_iterator()
Collection Types
◼ Collection objects are further specialized into
types like a set, list, bag, array, and dictionary
◼ Each collection type may provide additional
interfaces, for example, a set provides:
◼ create_union()
◼ create_difference()
◼ is_subset_of()
◼ is_superset_of()
◼ is_proper_subset_of()
Object Inheritance Hierarchy
Atomic Objects
◼ Atomic objects are user-defined objects and are defined
via keyword class
◼ An example:
class Employee (extent all_emplyees key ssn) {
attribute string name;
attribute string ssn;
attribute short age;
relationship Dept works_for;
void reassign(in string new_name);
}
Class Extents
◼ An ODMG object can have an extent defined
via a class declaration
◼ Each extent is given a name and will contain all
persistent objects of that class
◼ For Employee class, for example, the extent is
called all_employees
◼ This is similar to creating an object of type
Set<Employee> and making it persistent
Class Key
◼ A class key consists of one or more unique
attributes
◼ For the Employee class, the key is ssn
◼ Thus each employee is expected to have a unique
ssn
◼ Keys can be composite, e.g.,
◼ (key dnumber, dname)
Object Factory
◼ An object factory is used to generate individual
objects via its operations
◼ An example:
interface ObjectFactory {
Object new ();
};
◼ new() returns new objects with an object_id