Upload
sherman-chapman
View
236
Download
0
Embed Size (px)
DESCRIPTION
3 ODMG Object Database Management Group (ODMG) ODMG has been formed in late 1991 by: ObjectDesign, Ontos, O2 Technology, Versant, Objectivity, Digital Equipment, Hewlett-Packard, Itasca, Intellitic, Poet Software, Servio, Texas Instruments R.G.C. Cattell The Object Database Standard : ODMG, Release 1.2, 1996 Object Database Management Group (ODMG) ODMG has been formed in late 1991 by: ObjectDesign, Ontos, O2 Technology, Versant, Objectivity, Digital Equipment, Hewlett-Packard, Itasca, Intellitic, Poet Software, Servio, Texas Instruments R.G.C. Cattell The Object Database Standard : ODMG, Release 1.2, 1996
Citation preview
1
ODMG
2
ODMG• Object Database Management Group
(ODMG)ODMG has been formed in late 1991 by:
ObjectDesign, Ontos, O2 Technology, Versant, Objectivity, Digital Equipment, Hewlett-Packard, Itasca, Intellitic, Poet Software, Servio, Texas Instruments
3
ODMG• Object Database Management Group
(ODMG)ODMG has been formed in late 1991 by:
ObjectDesign, Ontos, O2 Technology, Versant, Objectivity, Digital Equipment, Hewlett-Packard, Itasca, Intellitic, Poet Software, Servio, Texas Instruments
R.G.C. Cattell The Object Database Standard : ODMG, Release 1.2, 1996
4
ODMG• Object Database Management Group
(ODMG)ODMG has been formed in late 1991 by:
ObjectDesign, Ontos, O2 Technology, Versant, Objectivity, Digital Equipment, Hewlett-Packard, Itasca, Intellitic, Poet Software, Servio, Texas Instruments
R.G.C. Cattell The Object Database Standard : ODMG, Release 1.2, 1996
R.G.C. Cattell, D.K. Barry The Object Database Standard: ODMG 2.0, 1997
5
ODMG• Aims
To put forward a set of standards allowing an ODBMS customer to write portable applications, i.e. application that could run on more than one ODBMS
6
ODMG• ODMG versus Relational DBMS
7
ODMG• ODMG versus Relational DBMS
Application Data Structures
Relational Representation
RDBMS
Copy and Translation Transparent
ODBMS Data Transfer
8
ODMG• Architecture
9
ODMG• Architecture
Declarations in ODL or Programming Language ODL
Declaration Preprocessor
metadata
Database
Application Source in extended Programming Language
Programming Language Compiler
Application Binaries
Linker
Running ApplicationData Access
OO DBMS Runtime
Fig. 1 ODMG DBMS Architecture
10
ODMG• Components
11
ODMG• Components
FrameworkA portion of ODMG that is common to all programming languages
12
ODMG• Components
FrameworkA portion of ODMG that is common to all programming languages
Framework consist of:
»Object Model
»Object Definition Language
»Object Query Language
13
ODMG• Components
Bindings
Bindings for each programming language in which ODBMS is used (currently: C++, Smalltalk)
14
ODMG• Basic concepts
15
ODMG• Basic concepts
The model is based on objects with object identifiers
16
ODMG• Basic concepts
The model is based on objects with object identifiers
Objects are categorised into types
17
ODMG• Basic concepts
The model is based on objects with object identifiers
Objects are categorised into types
The behaviour of objects is defined by a set of operations
18
ODMG• Basic concepts
The model is based on objects with object identifiers
Objects are categorised into types
The behaviour of objects is defined by a set of operations
The state of objects is determined by a set of properties (attributes, relationships)
19
ODMG• Basic concepts
Each object may have a unique name
20
ODMG• Basic concepts
Each object may have a unique name
Operations are defined by operation signatures
21
ODMG• Basic concepts
Each object may have a unique name
Operations are defined by operation signatures
Attributes are defined by attribute signatures
22
ODMG• Basic concepts
Each object may have a unique name
Operations are defined by operation signatures
Attributes are defined by attribute signatures
Relationships are specified by relationship signatures
23
ODMG• Basic concepts
Collection types include sets, bags, lists and arrays
24
ODMG• Basic concepts
Collection types include sets, bags, lists and arrays
Object types are related in subtype/supertype graph
25
ODMG• Basic concepts
Collection types include sets, bags, lists and arrays
Object types are related in subtype/supertype graph
An extent set can be declared to contain all instances of a given type
26
ODMG• Basic concepts
Individual instances can be uniquely identified by the value they carry for some property or set of properties (keys)
27
ODMG• Type hierarchy
28
ODMG• Type hierarchy Denotable Object
Object Literal
Atomic Object Structured Object Atomic LiteralStructured Literal
Type
Exception
Iterator
Collection<T>
Structure <e1:T1,..., en:Tn>
Set<T> Bag<T> List<T>Array<T>
String Bit String
IntegerCharacter
BooleanFloat
Immutable Sructure <e1:T1,..., en:Tn>
Immutable Collection<T>
Immutable Set<T>
Immutable List<T>
Immutable String
Immutable Bit String
Immutable Bag<T>
Immutable Array<T>
enumeration
DateTime
Date Time
Interval
Fig. 2 The ODMG type hierarchy
29
ODMG• Object Definition Language
30
ODMG• Object Definition Language
Employee
TeachingAssistant Professor
Section
Student
Course
teaches
is taught by
assists
has TA
has prerequisites
is prerequisite
belongs to
consists of
has
of
31
ODMG• Object Definition Language
interface Course( extent courses
keys name, number )
32
ODMG• Object Definition Language
interface Course( extent courses
keys name, number ){
attribute String name;attribute String number;
33
ODMG• Object Definition Language
interface Course( extent courses
keys name, number ){
attribute String name;attribute String number;relationship List<section> has_sections
inverse Section::is_section_of{ order by Section::number };
34
ODMG• Object Definition Language
interface Course( extent courses
keys name, number ){
attribute String name;attribute String number;relationship List<section> has_sections
inverse Section::is_section_of{ order by Section::number };
relationship Set<Course> has_prerequisitesinverse Course::is_prerequisite_for;
35
ODMG• Object Definition Language
interface Course( extent courses
keys name, number ){
attribute String name;attribute String number;relationship List<section> has_sections
inverse Section::is_section_of{ order by Section::number };
relationship Set<Course> has_prerequisitesinverse Course::is_prerequisite_for;
relationship Set<Course> is_prerequisite_forinverse Course::has_prerequisites;
36
ODMG• Object Definition Language
Boolean offer( in Unsigned Short semester)raises(already_offered);
Boolean drop( in Unsigned Short semester)raises(not_offered);
};
37
ODMG• Object Definition Language
interface Section( extent sections
key (is_section_of, number) )
38
ODMG• Object Definition Language
interface Section( extent sections
key (is_section_of, number) ){ attribute String number;
relationship Professor is_taught_by inverse professor::teaches;
relationship TA has_TA inverse TA::assists;
relationship Course is_section_of inverse Course::has_sections;
relationship Set<Student> is_taken_by inverse Student::takes;
};
39
ODMG• Object Definition Language
interface Employee( extent employees
key (name. id) ){
attribute String name;attribute Short id;attribute Unsigned Short annual_salary;
void hire();void fire() raises (no_such_employee);
};
40
ODMG• Object Definition Language
interface Professor:Employee( extent professors ){ attribute Enum Rank { full, associate, assistant} ;
relationship Set<Section> teachesinverse section::is_taught_by;
Short grant_tenure()raises(ineligible_for tenure);
}interface TA: Employee, Student(){
relationship Section assistsinverse Section::has_TA;
};
41
ODMG• Object Definition Language
interface Student( extent students
keys name, student_id ){ attribute String name;
attribute String student_id;attribute Struct Address
{ String college,String room_number,
} dorm_address;relationship Set<Section> takes
inverse Section::is_taken_by;
42
ODMG• Object Definition Language)
Boolean register_for_course(in Unsigned Short Course,in Unsigned Short Section )
raises(unsatisfied_prerequisites,section_full,course_full );
void drop_course(in Unsigned Short Course )raises( not_registered_for_that_course);
void assign_major(in Unsigned Short Department );
43
ODMG• Object Definition Language
Short transfer( in Unsigned Short old_section,in Unsigned Short new_section );
};
44
ODMG• Programming language (C++) binding
45
ODMG• Programming language (C++) binding
There is single unified type system across the programming language and the database
46
ODMG• Programming language (C++) binding
There is single unified type system across the programming language and the database
The programming language-specific binding for ODL/OML respects the syntax and semantics of the base programming language into which it is being inserted
47
ODMG• Programming language (C++) binding
There is single unified type system across the programming language and the database
The programming language-specific binding for ODL/OML respects the syntax and semantics of the base programming language into which it is being inserted
The binding is structured as a small set of additions to the base programming language
48
ODMG• Programming language (C++) binding
Expressions in OML compose freely with expressions from the base programming language and vice versa
49
ODMG• C++ binding
50
ODMG• C++ binding
Persistent-capable classes
class Professor : public Persistent_Object
51
ODMG• C++ binding
Persistent-capable classes
class Professor : public Persistent_Object{ public: Ref<Department> dept
inverse Department::professors;
52
ODMG• C++ binding
Persistent-capable classes
class Professor : public Persistent_Object{ public: Ref<Department> dept
inverse Department::professors;Set<Ref<Student>> advises
inverse Student::advisor;};
53
ODMG• C++ binding
Ref-based approach
For each persistence-capable class T, an ancillary class Ref<T> is defined
54
ODMG• C++ binding
Ref-based approach
For each persistence-capable class T, an ancillary class Ref<T> is defined
Ref<Professor> profP;Ref<Department> deptRef;profP->grant_tenure();deptRef = profP->dept;
55
ODMG• Mapping ODMG Model into C++
56
ODMG• Mapping ODMG Model into C++
Object type -> C++ class
57
ODMG• Mapping ODMG Model into C++
Object type -> C++ class
Structure -> struct or class
58
ODMG• Mapping ODMG Model into C++
Object type -> C++ class
Structure -> struct or class
Collections -> template classes
59
ODMG• Mapping ODMG Model into C++
Object type -> C++ class
Structure -> struct or class
Collections -> template classes
template<class T> class Set: public Collection<T>{...};class Ship {...};Set<Ref<Ship>> Cunard_Line;
60
ODMG• Mapping ODMG Model into C++
subtype/supertype hierarchy ->hierarchy of classes
61
ODMG• Mapping ODMG Model into C++
subtype/supertype hierarchy ->hierarchy of classes
operations -> C++ functions
62
ODMG• Mapping ODMG Model into C++
subtype/supertype hierarchy ->hierarchy of classes
operations -> C++ functions
relationships -> methods that traverse
relationship
63
ODMG• Mapping ODMG Model into C++
subtype/supertype hierarchy ->hierarchy of classes
operations -> C++ functions
relationships -> methods that traverse
relationship
arrays of objects -> Varray C++ class
64
ODMG• Mapping ODMG Model into C++
keys -> ?
extents -> ?
name -> ?
65
ODMG• C++ ODL
66
ODMG• C++ ODL
Attributesclass Student : public Persistent_Object{ String name;
Date birth_date;Phone_Number dorm_phone;
67
ODMG• C++ ODL
Attributesclass Student : public Persistent_Object{ String name;
Date birth_date;Phone_Number dorm_phone;struct{ int PO_box;
String university;String city;String state;String zip_code;
} university_address;
68
ODMG• C++ ODL
Attributesclass Student : public Persistent_Object{ String name;
Date birth_date;Phone_Number dorm_phone;struct{ int PO_box;
String university;String city;String state;String zip_code;
} university_address;List<String> favorite_friends;
};
69
ODMG• C++ ODL
Relationshipsclass Department : public Persistent_Object{public:
Set<Ref<Professor>> professorsinverse Professor::dept;
};
70
ODMG• C++ ODL
Relationshipsclass Department : public Persistent_Object{public:
Set<Ref<Professor>> professorsinverse Professor::dept;
};
class Professor : public Persistent_Object{
Ref<Department> deptinverse Department::professors;Set<Ref<Student>> adviseesinverse Student::advisor;
};
71
ODMG• C++ ODL
Relationshipsclass Student : public Persistent_Object{ public:
Ref<Professor> advisorinverse Professor::advisees;
Set<Ref<Course>> classesinverse Course::students_enrolled;
};
72
ODMG• C++ ODL
Relationshipsclass Student : public Persistent_Object{ public:
Ref<Professor> advisorinverse Professor::advisees;
Set<Ref<Course>> classesinverse Course::students_enrolled;
};
class Course : public Persistent_Object{public:
Set<Ref<Student>> students_enrolledinverse Student::classes;
};
73
ODMG• C++ ODL
Unidirectional Relationships
struct Responsible{ String dept;
Ref<Employee>e;Date due_date;
};
74
ODMG• C++ ODL
Unidirectional Relationships
struct Responsible{ String dept;
Ref<Employee>e;Date due_date;
};
class Order{ public:
Set<Ref<Client>> who;String what;Responsible contact;
};
75
ODMG• C++ ODL
Object Creationstatic const Database * const Database::transient_memory;
76
ODMG• C++ ODL
Object Creationstatic const Database * const Database::transient_memory;Forms of new operator:(i) void * operator new(
size_t size,const char* typename = 0);
77
ODMG• C++ ODL
Object Creationstatic const Database * const Database::transient_memory;Forms of new operator:(i) void * operator new(
size_t size,const char* typename = 0);
(ii) void * operator new(size_t size,
constRef<Persistent_Object> &clustering,const char* typename =0);
78
ODMG• C++ ODL
Object Creationstatic const Database * const Database::transient_memory;Forms of new operator:(i) void * operator new(
size_t size,const char* typename = 0);
(ii) void * operator new(size_t size,
constRef<Persistent_Object> &clustering,const char* typename =0);
(iii) void * operator new(size_t size,Database * database,const char* typename =0);
79
ODMG• C++ ODL
Object creationDatabase *yourDB, *myDB;
80
ODMG• C++ ODL
Object creationDatabase *yourDB, *myDB;
Ref<Schedule> temp_sched1 =new Schedule;
81
ODMG• C++ ODL
Object creationDatabase *yourDB, *myDB;
Ref<Schedule> temp_sched1 =new Schedule;
Ref<Professor> prof2 =new( yourDB, "Professor") Professor;
82
ODMG• C++ ODL
Object creationDatabase *yourDB, *myDB;
Ref<Schedule> temp_sched1 =new Schedule;
Ref<Professor> prof2 =new( yourDB, "Professor") Professor;
Ref<Student> student1 =new(myDB) Student;
Ref<Student> student2 = new(student1) Student;
Ref<Student> temp_student =new(Database::transient_memory) Student;
83
ODMG• C++ ODL
Object Deletion
Ref<any_Type> obj_ref;// set obj_ref to refer to persistent objectobj_ref.delete_object();
84
ODMG• C++ ODL
Object Deletion
Ref<any_Type> obj_ref;// set obj_ref to refer to persistent objectobj_ref.delete_object();
Object Modification
obj_ref->mark_modified();
85
ODMG• C++ ODL
Object References
– Object references are instances of Ref<T>
86
ODMG• C++ ODL
Object References
– Object references are instances of Ref<T>
– All accesses to persistent objects are made via methods defined on classes Ref, Persistent_Object, Database
87
ODMG• C++ ODL
Object References
– Object references are instances of Ref<T>
– All accesses to persistent objects are made via methods defined on classes Ref, Persistent_Object, Database
– The dereference operator -> is used to access members of the persistent object "addressed" by a given object reference
88
ODMG• C++ ODL
Attributes
prof->id_number = next_id;
cout << prof->id_number;
89
ODMG• C++ ODL
Relationships
1-1class A { Ref<B> inverse B::ra }
class B{ Ref<A> inverse ::rb; }
90
ODMG• C++ ODL
Relationships
1-1class A { Ref<B> inverse B::ra }
class B{ Ref<A> inverse ::rb; }
a.rb = &b; //add relationshipa.rb.clear(); // remove relationshipa.rb = &bb; //modify relationship
91
ODMG• C++ ODL
Relationships
1:Mclass A{ Set<Ref<B>> sb inverse B::ra; }
class B{ Ref<A> ra inverse A::sb; }
92
ODMG• C++ ODL
Relationships
1:Mclass A{ Set<Ref<B>> sb inverse B::ra; }
class B{ Ref<A> ra inverse A::sb; }
a.sb.insert_element(&b); // add relationshipa.sb.remove_element(&b); // remove relationship.
or b.ra.clear();b.ra = &&aa; // modify relationship
93
ODMG• C++ ODL
Relationships
M:Nclass A{ Set<Ref<B>> sb inverse B::sa; }
class B{ Set<Ref<A>> sa inverse A:sb; }
94
ODMG• C++ ODL
Relationships
M:Nclass A{ Set<Ref<B>> sb inverse B::sa; }
class B{ Set<Ref<A>> sa inverse A:sb; }a.sb.insert_element(&b); // add relationshipa.sb.remove_element(&b); // remove relationship
or b.sa.remove_element(&a);a.sb.replace_element_at(&bb, 3); // modify relationship