ADVANCED DATABASES ODMG Object Model Object Definition Language

ADVANCED DATABASES ODMG Object Model, Object Definition Language (ODL) Khawaja Mohiuddin Assistant Professor Department of Computer Sciences Bahria University (Karachi Campus) Khawaja. mohiuddin@bimcs. edu. pk https: //sites. google. com/site/khawajamcs Contents for this lecture are taken from: Chapter 10 of “Database Systems: Models, Languages …”, 6 th Ed. ” by Elmasri and Navathe (Chapter 11 of “Fundamentals of Database Systems” 6 th Ed. by Elmasri and Navathe)

Objectives 2 § § § § To get to know how Object Data Management Group (ODMG) was formed To understand the ODMG modeling terminology To learn how Interfaces and Classes are defined in ODMG object model To learn how Objects are inherited To know the built-in Interfaces and Classes in ODMG object model To understand the Object Definition Language (ODL) To learn the graphical notations used in ODL

The ODMG Object Model 3 Many experimental ODBMS prototypes created: Many Commercial ODBMS are available: Orion system by MCC, Open. OODB by Texas Instruments, Iris system by Hewlett-Packard laboratories, Ode system by AT&T Bell Labs, ENCORE/Ob. Server project at Brown University, etc. Gem. Stone Object Server of Gem. Stone Systems, ONTOS DB of Ontos, Objectivity/DB of Objectivity Inc. , Versant Object Database and Fast. Objects by Versant Corporation, Object. Store of Object Design, and Ardent Database of Ardent, etc. Because of the popularity of relational and objectrelational systems, ODMS did not find widespread

The ODMG Object Model (cont’d. ) 4 The lack of a standard for ODMS for several years may also have caused some potential users to shy away from converting to this new technology. Need for a standard model and language was recognized. A consortium of object DBMS vendors and users, called Object Data Management Group(ODMG), proposed a standard whose current specification is known as the ODMG 3. 0 standard. The standard includes the object model, the object definition language (ODL), the object query language (OQL), and the bindings to object-

The ODMG Terminology 5 ODMG object model is meant to provide a standard data model for object databases, just as relational model describes a standard data model for relational databases Objects and Literals Basic building blocks of the object model Object has both object identifier and state (current value) literal has a state (value) but no object identifier Object’s state changes, literal’s does not

The ODMG Terminology (cont’d. ) 6 Object has five aspects: Identifier 1. a unique system-wide identifier (Object_id) every object must have an object identifier Name 2. an object may be given a unique name not all individual objects will have names mainly objects that hold collections of objects (extents) will have a name. these names are used as entry points to the database the user can then locate other objects that are referenced from these objects it is possible to give more than one name to an object all names within a particular ODMS must be unique

The ODMG Terminology (cont’d. ) 7 Lifetime 3. specifies whether persistent object or transient object persistent object is a database object transient object is an object in an executing program that disappears after the program terminates lifetimes are independent of types (some may be transient whereas others may be persistent for same type) Structure 4. specifies how object is constructed by using type constructors specifies whether an object is atomic or not atomic object refers to a single object that follows a userdefined type, such as Employee or Department

The ODMG Terminology (cont’d. ) 8 Structure (cont’d. ) 4. if not atomic, then object will be composed of other objects. Example: collection object atomic object is different from atom constructor covered in Section 11. 1. 3, which referred to all values of built-in data types Creation 5. refers to the manner in which an object can be created typically accomplished via an operation new for a special Object_Factory interface (Will cover in more detail later)

The ODMG Terminology (cont’d. ) 9 Literal Value that does not have an object identifier value may have a simple or complex structure Three types of literals: atomic, structured, and collection 1. 2. Atomic literals correspond to the values of predefined, basic data types. Example: long, short, float, boolean, char, string, etc. Structured literals correspond roughly to values constructed using tuple constructor, include built-in structured literals like Date, Interval, Time, etc. and userdefined structured literals defined as needed by each application

The ODMG Terminology (cont’d. ) 10 Behavior refers to operations State refers to properties (attributes and relationships) Interface Specifies only behavior of an object type Typically noninstantiable (no objects are created corresponding to an interface) May have state properties (attributes and relationships), but these cannot be inherited Serves to define operations that can be inherited by other interfaces and classes

The ODMG Terminology (cont’d. ) 11 Class Specifies both state (attributes) and behavior (operations) of an object type Instantiable (objects can be created) objects are typically created based on the userspecified class declarations that form a database schema

12 Interface and Class Definitions in ODMG interface Object {. . . boolean same_as(in object other_object); object copy(); void delete(); }; Class Date : Object { enum Weekday {Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday}; enum Month {January, February, March, April, May, June, July, August, September, October, November, December }; unsigned short year(); unsigned short month(); unsigned short day(); . . . boolean is_equal(in Date other_date); . . . };

13 Interface and Class Definitions in ODMG (cont’d. ) interface Collection : Object {. . . exception Element. Not. Found{ Object element; }; unsigned long cardinality(); boolean is_empty(); . . . boolean contains_element(in Object element); void insert_element(in Object element); void remove_element(in Object element) raises(Element. Not. Found); iterator create_iterator(in boolean stable); . . . }; interface set : Collection { set create_union(in set other_set); . . . boolean is_subset_of(in set other_set); . . . };

14 Inheritance in the Object Model of ODMG Behavior inheritance Also known as IS-A or interface inheritance Specified by the colon (: ) notation Requires the supertype to be an interface Multiple inheritance is allowed EXTENDS inheritance Specified Inherit by keyword extends both state and behavior strictly among classes Multiple inheritance via extends not permitted

15 Built-in Interfaces and Classes in the Object Model Collection objects Inherit the basic Collection interface I = O. create_iterator() Creates an iterator object I for the collection object O Collection objects further specialized into: set, list, bag, array, and dictionary

16 Built-in Interfaces and Classes in the Object Model (cont’d. )

Atomic (User-Defined) Objects 17 Specified using keyword class in ODL Attribute Property; describes some aspect of an object Relationship Two objects in the database are related Only binary relationships are explicitly represented Keyword inverse • Specifies that two properties define a single conceptual relationship in inverse directions Operation signature: Operation name, argument types, return value

18 Atomic (User-Defined) Objects (cont’d. ) class EMPLOYEE class DEPARTMENT ( extent ALL_EMPLOYEES ( extent ALL_DEPARTMENTS key Ssn ) key Dname, Dnumber ) { { attribute string Name; attribute string Dname; attribute string Ssn; attribute short Dnumber; attribute date Birth_date; attribute struct Dept_mgr {EMPLOYEE attribute enum Gender{M, F} Sex; Manager, date Start_date} attribute short Age; Mgr; relationship DEPARTMENT Works_for attribute set<string> Locations; inverse DEPARTMENT: : Has_emps; attribute struct Projs {string void reassign_emp(in string Proj_name, time Weekly_hours) New_dname) Projs; raises(dname_not_valid); relationship set<EMPLOYEE> Has_emps }; inverse EMPLOYEE: : Works_for; void add_emp(in string New_ename) raises(ename_not_valid); void change_manager(in string New_mgr_name; in date Start_date); };

Extents, Keys, and Factory Objects 19 Extent Contains all persistent objects of class Behaves as a set object (see EMPLOYEE class) Key One or more properties whose values are unique for each object in extent A class with an extent can have one or more keys (see DEPARTMENT class) Factory object Used to generate or create individual objects via its operations (provides constructor operations)

More on Factory Objects 20 By inheriting this interface, users can create their own factory interface Object. Factory { Object new(); interfaces for each user- }; defined (atomic) object Set. Factory : Object. Factory { type, and can implement interface Set new_of_size(in long size); the operation new }; differently for each type interface List. Factory : Object. Factory { of object List new_of_size(in long size); }; interface Array. Factory : Object. Factory { Array new_of_size(in long size); };

21 The Object Definition Language ODL Support semantic constructs of ODMG object model Its main use is to create object specifications, i. e. classes and interfaces Independent of any particular programming language

Graphical Notation for ODL 22

23

24

Summary 25 Overview of concepts utilized in ODMG object model Object identity and identifiers; operations; inheritance; complex structure of objects through nesting of type constructors; and how objects are made persistent Description of the ODMG object model and object Definition language (ODL)
- Slides: 25