280 likes | 1.01k Views
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.
E N D
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 …”, 6th Ed.” by Elmasri and Navathe (Chapter 11 of “Fundamentals of Database Systems” 6th Ed. by Elmasri and Navathe)
Objectives • 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 • Many experimental ODBMS prototypes created: • Orion system by MCC, OpenOODB by Texas Instruments, Iris system by Hewlett-Packard laboratories, Ode system by AT&T Bell Labs, ENCORE/ObServer project at Brown University, etc. • Many Commercial ODBMS are available: • GemStone Object Server of GemStone Systems, ONTOS DB of Ontos, Objectivity/DB of Objectivity Inc., Versant Object Database and FastObjects by Versant Corporation, ObjectStore of Object Design, and Ardent Database of Ardent, etc. • Because of the popularity of relational and object-relational systems, ODMS did not find widespread use.
The ODMG Object Model (cont’d.) • 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-oriented programming languages.
The ODMG Terminology • 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.) • Object has five aspects: • Identifier • a unique system-wide identifier (Object_id) • every object must have an object identifier • Name • 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.) • Lifetime • 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 • 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 user-defined type, such as Employee or Department
The ODMG Terminology (cont’d.) • Structure (cont’d.) • 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 • 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.) • 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 • 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 user-defined structured literals defined as needed by each application • Collection literals specify a literal value that is a collection of objects or values. The collection itself does not have an Object_id
The ODMG Terminology (cont’d.) • 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.) • Class • Specifies both state (attributes) and behavior (operations) of an object type • Instantiable(objects can be created) • objects are typically created based on the user-specified class declarations that form a database schema
Interface and Class Definitions in ODMG • interface Object { • ... • booleansame_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(); • ... • booleanis_equal(in Date other_date); ... };
Interface and Class Definitions in ODMG (cont’d.) interface Collection : Object { ... exception ElementNotFound{ Object element; }; unsigned long cardinality(); booleanis_empty(); ... booleancontains_element(in Object element); void insert_element(in Object element); void remove_element(in Object element) raises(ElementNotFound); iteratorcreate_iterator(in boolean stable); ... }; interface set : Collection { set create_union(in set other_set); ... booleanis_subset_of(in set other_set); ... };
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 by keyword extends • Inherit both state and behavior strictly among classes • Multiple inheritance via extends not permitted
Built-in Interfaces and Classes in the Object Model • Collection objects • Inherit the basic Collection interface • I = O.create_iterator() • Creates an iteratorobject Ifor the collection object O • Collection objects further specialized into: • set, list, bag, array, and dictionary
Built-in Interfaces and Classes in the Object Model (cont’d.)
Atomic (User-Defined) Objects • 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
Atomic (User-Defined) Objects (cont’d.) class EMPLOYEE ( extent ALL_EMPLOYEES key Ssn ) { attribute string Name; attribute string Ssn; attribute date Birth_date; attribute enum Gender{M, F} Sex; attribute short Age; relationship DEPARTMENT Works_for inverse DEPARTMENT::Has_emps; void reassign_emp(in string New_dname) raises(dname_not_valid); }; class DEPARTMENT ( extent ALL_DEPARTMENTS key Dname, Dnumber ) { attribute string Dname; attribute short Dnumber; attribute structDept_mgr {EMPLOYEE Manager, date Start_date} Mgr; attribute set<string> Locations; attribute structProjs {string Proj_name, time Weekly_hours) Projs; 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 • 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 • By inheriting this interface, users can create their own factory interfaces for each user-defined (atomic) object type, and can implement the operation new differently for each type of object interface ObjectFactory { Object new(); }; interface SetFactory : ObjectFactory { Set new_of_size(in long size); }; interface ListFactory : ObjectFactory { List new_of_size(in long size); }; interface ArrayFactory : ObjectFactory { Array new_of_size(in long size); };
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
Summary • 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)