Chapter 5 C++ Binding Prof. Hyoung-Joo Kim OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ.

Slides:



Advertisements
Similar presentations
Chapter 8: Object-Oriented Databases
Advertisements

Object-Oriented programming in C++ Classes as units of encapsulation Information Hiding Inheritance polymorphism and dynamic dispatching Storage management.
Object Databases Baochuan Lu. outline Concepts for Object Databases Object Database Standards, Languages, and Design Object-Relational and Extended-Relational.
ODMG Standard: Object Model1 OBJECT-ORIENTED DATABASE SYSTEMS ODMG Standard: Object Model Susan D. Urban and Suzanne W. Dietrich Department of Computer.
Chapter 9 Imperative and object-oriented languages 1.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Road Map Introduction to object oriented programming. Classes
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Object-Oriented Standards OMG OMDG. Overview Object Management Group (OMG) International non profit-making consortium founded in 1989 to address object.
Terms and Rules Professor Evan Korth New York University (All rights reserved)
Programs with SQL Host language + Embedded SQL Preprocessor Host Language + function calls Host language compiler Host language program Preprocessor Host.
Object Oriented Databases - Overview
Object-Oriented programming in C++ Classes as units of encapsulation Information Hiding Inheritance polymorphism and dynamic dispatching Storage management.
Abstract Data Types and Encapsulation Concepts
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 11 Object and Object- Relational Databases.
1 Announcements Research Paper due Monday November 22.
Databases Illuminated Chapter 7 The Object-Oriented Model.
Review of C++ Programming Part II Sheng-Fang Huang.
OOP Languages: Java vs C++
Advanced Database CS-426 Week 2 – Logic Query Languages, Object Model.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Programming Languages and Paradigms Object-Oriented Programming.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
Classes Mark Hennessy Dept. Computer Science NUI Maynooth C++ Workshop 18 th – 22 nd Spetember 2006.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 19 Clicker Questions November 3, 2009.
Object Query Language (OQL) and Language Binding
1 Spring 2000 Christophides Vassilis ODMG Object Programming Language Bindings.
Chapter 21 A Object Data Model - Intro Copyright © 2004 Pearson Education, Inc.
Chapter 2: Object Model Prof. Hyoung-Joo Kim OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ.
Programming Languages and Paradigms Object-Oriented Programming (Part II)
Algorithm Programming Bar-Ilan University תשס"ח by Moshe Fresko.
Programming Languages and Paradigms Object-Oriented Programming.
Object oriented databases
Copyright © 2012 Pearson Education, Inc. Chapter 13: Introduction to Classes.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 13: Introduction to Classes.
Learners Support Publications Classes and Objects.
C++ Review (3) Structs, Classes, Data Abstraction.
Chapter 21 Object Database Standards, Languages, and Design Copyright © 2004 Pearson Education, Inc.
©Silberschatz, Korth and Sudarshan1Database System Concepts Lecture 7: Introduction to Database Management Systems - Object-Oriented Databases Lecturer:
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 7 Structured Data and Classes.
Chapter 3 Object Specification Languages Prof. Hyoung-Joo Kim OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ.
1 Advanced Databases (CM036) – Lecture # 12: The ODMG Standard for Object Databases Object Query Language (OQL) & Language Binding Advanced Database Technologies.
OOPSLA LAB. 1 Chapter 4 Object Query Languages Prof. Hyoung-Joo Kim OOPSLA Lab. Dept. of Computer Engineering Seoul National University.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
11-1 CHAPTER 11 Concepts for Object-Oriented Databases.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
© D. Wong Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:
Chapter 8 Class Inheritance and Interfaces F Superclasses and Subclasses  Keywords: super F Overriding methods  The Object Class  Modifiers: protected,
The ODMG Standard for Object Databases
E.Bertino, L.Matino Object-Oriented Database Systems 1 Chapter 9. Systems Seoul National University Department of Computer Engineering OOPSLA Lab.
OOPSLA Lab.1 Chapter 6 Smalltalk Binding Prof. Hyoung-Joo Kim OOPSLA Lab. Dept. of Computer Engineering Seoul National University.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 13: Introduction to Classes.
1 Advanced Databases – Lecture # 12: The ODMG Standard for Object Databases Advanced Databases The ODMG Standard for Object Databases.
Object-Oriented programming in C++ Classes as units of encapsulation Information Hiding Inheritance polymorphism and dynamic dispatching Storage management.
©Silberschatz, Korth and Sudarshan8.1Database System Concepts Chapter 8: Object-Oriented Databases Need for Complex Data Types The Object-Oriented Data.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Chapter 12 Outline Overview of Object Database Concepts Object-Relational Features Object Database.
1 ODMG. 2 Object Database Management Group (ODMG) ODMG has been formed in late 1991 by: ObjectDesign, Ontos, O2 Technology, Versant, Objectivity, Digital.
Object-Oriented Databases (chapter 3/3) ODMG-OQL for querying the database Simple OQL Queries, Retrieving Objects – an example Database Entry Points Retrieving.
OOPSLA Lab1 Chapter 7 Java Binding Prof. Hyoung-Joo Kim OOPSLA Lab. Dept. of Computer Engineering Seoul National University.
Chapter 21 Object Database Standards, Languages, and Design Copyright © 2004 Pearson Education, Inc.
Review: Two Programming Paradigms
Chapter 12 Outline Overview of Object Database Concepts
Dr. Bhargavi Dept of CS CHRIST
Constructors and destructors
Classes and Objects.
Chapter 8: Object-Oriented Databases
SPL – PS3 C++ Classes.
Presentation transcript:

Chapter 5 C++ Binding Prof. Hyoung-Joo Kim OOPSLA Lab. Dept. of Computer Engineering Seoul National Univ.

SNU OOPSLA Lab 2 Contents Instruction C++ ODL C++ OML C++ OQL Schema Access

SNU OOPSLA Lab 3 Introduction C++ binding: mapping the Object Model into C++ –C++ ODL: a library of classes and functions to implement the concepts defined in the ODMG Object Model –C++ OML: Object Manipulation Language for retrieving objects from database and modifying them –C++ OQL: a subset of OML which supports associative retrieval

SNU OOPSLA Lab 4 Introduction(con’t) Mapping the ODMG Object Model into C++ –Object and Literal: depending on how a C++ class is instantiated –Structure: C++ construct struct or class embedded in a class –Implementation: two parts interface(public part) and implementation(protected and private members and function definitions) –Collection classes: a collection template classes in C++ –Array: d_Varray C++ class –Relationship: instances of specific template classes in a class –Extents: d_Extent class –Keys: not supported by C++ –Names: set_object_name and rename_object methods in C++

SNU OOPSLA Lab 5 C++ ODL attributes relationships operations C++ ODL Declarations ODL Preprocessor C++ Header Files data members member functions ODL Declarations Java ODL Declarations

SNU OOPSLA Lab 6 C++ ODL(con’t) extern const _professors[]; extern const _advisor[]; class Professor : public d_Object { public: //properties d_UShort age; d_UShort id_number; d_String name; d_Rel_Ref dept; d_Rel_Set advisees; //operations void grant_tenure(); voidassign_course(Course &); }; const _professors[] = “professors”; const _advisor[]=“advisor”; e.g.

SNU OOPSLA Lab 7 C++ ODL(con’t) How do we declare attributes, relationships, and operations which comprise C++ ODL? properties-attributes properties-relationships behavior-operations class declaration by C++ ODL d_String, d_Interval, d_Date, d_Time, d_Timestamp d_Rel_Ref, d_Rel_Set, d_Rel_List

SNU OOPSLA Lab 8 C++ ODL: Attribute Declarations Standard C++ syntax and semantics for class definitions are supported. –But, compliant implementations need not support the following data types within persistent classes: unions bit fields references(&) Members within classes in C++ ODL –all primitive data types(e.g., d_String, d_char, etc.), except those noted above –structures and class objects(e.g., atomic objects, structured literal, structured object, etc.)

SNU OOPSLA Lab 9 C++ ODL: Attribute Declarations(con’t) Example class Student : public d_Object { public: d_String name; d_Date birth_date; Phone_Number dorm_phone; University_Address address; d_List favorite_friends; }; struct University_Address { d_UshortPO_box; d_Stringuniversity; d_Stringcity;... };

SNU OOPSLA Lab 10 C++ ODL: Attribute Declarations(con’t) Fixed-Length Types –Unlike the C++ built-in types, the fixed-length types have the same range and interpretation on all environments Type Name Range Description d_Short 16bit signed integer d_Long 32bit signed integer d_UShort 16bit unsigned integer d_Boolean d_True or d_False defines d_True(nonzero) and d_False(Zero)

SNU OOPSLA Lab 11 C++ ODL: Attribute Declarations(con’t) e.g., usage of fixed-length type class Professor : public d_Object { public: //properties d_UShort age;... }; short age; int age; Environment 1 Environment 2 implementation 16bit

SNU OOPSLA Lab 12 C++ ODL: Attribute Declarations(con’t) Refer to p130 - p137 of the text book, ODMG 2.0 –d_String –d_Interval –d_Date –d_Time

SNU OOPSLA Lab 13 C++ ODL: Relationship Declarations A traversal path declaration is an attribute declaration and must be of type –d_Rel_Ref for 1 : 1 relationship –d_Rel_Set for 1 : m relationship –d_Rel_List for 1 : m relationship + ordering Second template argument should be the name of the attribute in the other class for the inverse role in relationship Both classes in a relationship must have a member of one of the upper types The referential integrity of bidirectional relationships is automatically maintained

SNU OOPSLA Lab 14 C++ ODL: Relationship Declarations(con’t) Example Processors Students advisor advisees 1 : m class Professor : public d_Object { public: d_Rel_Set advisees; }; extern const char _advisor[], _advisees[]; class Student : public d_Object { public: d_Rel_Ref advisor; }; extern const char _advisor[]=“advisor”; extern const char _advisees[]=“advisees”; classes definition in C++ ODL

SNU OOPSLA Lab 15 C++ ODL: Operation Declarations Operation declarations are syntactically identical to member function declarations

SNU OOPSLA Lab 16 C++ OML main() { d_Database *myDB; d_Ref prof = new(myDB, “Professor”) Professor; prof->age = 30;... prof->age = 40; prof->delete_object();... } Application by C++ binding Persistent DB What is C++ OML? C++ OML

SNU OOPSLA Lab 17 C++ OML(con’t) A guiding principle in the design of C++ OML –The syntax used to create, delete, reference, and invoke operations on a persistent object should be, as far as possible, not different than used for transient objects –In fact, ODMG 2.0 standard treats persistent and transient objects slightly differently: queries and transactions

SNU OOPSLA Lab 18 C++ OML(con’t) For what standard does C++ OML exist? –In application program Object Creation Object Deletion Object Modification Object References

SNU OOPSLA Lab 19 C++ OML: Object Creation Objects are created in C++ OML using the new operator (1) creation of transient objects (2) creation of persistent objects and placement near clustering object (3) creation of persistent objects in specified database (1) void* operator new(size_t size); (2) void* operator new(size_t size, const d_Ref_Any& clustering, const *typename); (3) void* operator new(size_t size, d_Database *db, const char* typename);

SNU OOPSLA Lab 20 C++ OML: Object Creation(con’t) Example d_Database *myDB, *yourDB; (1) d_Ref sched = new Schedule; (2) d_Ref prof = new(yourDB, “Professor”) Professor; (3) d_Ref stdnt1 = new(myDB, “Student”) Student; (4) d_Ref stdnt2 = new(stdnt1, “Student”) Student; (5) d_Ref temp_stdnt = new(d_Database::transient_memory, “Student”) Student;

SNU OOPSLA Lab 21 C++ OML: Object Deletion Objects can be deleted in C++ OML using the d_Ref::delete_obejct member function Object is removed from memory and, if it is a persistent object, from the database Example d_Ref objRef;... //set objRef to refer to a persistent object objRef.delete_object();

SNU OOPSLA Lab 22 C++ OML: Object Modification The state of an object is modified by updating its properties or by invoking operations on it –Persistent objects which will be modified must communicate to the runtime ODMBS process the fact of “change” –invoking the d_Object::mark_modified member function –As a convenience, the programmer may omit mark_modified function, but for performance improvement this function calls are required

SNU OOPSLA Lab 23 C++ OML: Object Modification(con’t) Example App1 App2 Page buffer Page buffer DB Server “States will change” “You will be blocked” //Application 1 d_Ref prof = new(myDB, “Professor”) Professor; prof->age = 30;... //Application 2 d_Ref prof = myDB.lookup_object(...); prof->mark_modified(); prof->age = 40;...

SNU OOPSLA Lab 24 C++ OML: Object Reference Object referencing –Objects, whether persistent or not, refer to other objects via object references –Object references are instances of template class d_Ref –All accesses to persistent objects are made via methods defined on classes d_Ref, d_Object and d_Database e.g., dereference operator -> –An object can always refer to another object of longer lifetime, but only refer to an object of shorter lifertime as long as the shorter-lived object exists –initialization of values of persistent object’s pointers to transient objects & commitment

SNU OOPSLA Lab 25 C++ OML: Object Reference(con’t) Dereference operation App Page buffer DB Server Page bufferTransient memory point swizzling d_Database *myDB;... d_Ref prof;... prof = myDB.lookup_object(“hjk”);...

SNU OOPSLA Lab 26 C++ OML: Object Names In a database application, other objects are generally accessed by “root” objects, so name facility of root objects needs A single, flat name scope per database, so all names in a particular database are unique Operations for name manipulating are defined in the d_Database class e.g., d_Ref prof1 = new(myDB, “Professor”) Professor; myDB.set_object_name(prof1, “hjk”);.... D_Ref prof2 = myDB.lookup_object(“hjk”);...

SNU OOPSLA Lab 27 C++ OML: Attributes Accessing attributes of persistent objects –C++ OML uses standard C++ for access to attributes –mark_modified call before attribute is modified –Embedded objects(of persistent-capable class) are accessed as attributes. If they be modified, what should be done? Example d_Ref prof;... prof.mark_modified(); prof->TA.name=“kkk”;//TA is an embedded object...//class Professor : public d_Object //{... // //not Ref TA // Student TA; //...};

SNU OOPSLA Lab 28 C++ OML: Relationships Creating, traversing, and breaking relationships are defined in the C++ OML The integrity of relationships is maintained by the ODBMS Both to-one and to-many traversal paths are supported by the OML Template classes for relationships template class d_Rel_Ref : public d_Ref {}; template class d_Rel_Set : public d_Set > {}; template class d_Rel_List : public d_List >{};

SNU OOPSLA Lab 29 C++ OML: Relationships(con’t) 1-1 relationship extern const char _ra[], _rb[]; class A { d_Rel_Ref rb; }; class B { d_Rel_Ref ra; }; const char _ra[] = “ra”; const char _rb[] = “rb”; a.rb = &b; //same effect as b.ra=&a; a.rb.clear(); //same effect as b.ra.clear(); a.rb = &bb; rb a ra b rb a ra b rb a ra bb ra b

SNU OOPSLA Lab 30 C++ OML: Relationships(con’t) 1-m relationship using d_Set extern const char _ra[], _sb[]; class A { d_Rel_Set sb; }; class B { d_Rel_Ref ra; }; const char _ra[] = “ra”; const char _sb[] = “sb”; a.sb.insert_element(&b); b.ra = &aa; sb a ra b sb a aa ra b

SNU OOPSLA Lab 31 C++ OML: Relationships(con’t) 1-m relationship using d_List –same as 1-m relationship using d_Set except positional nature extern const char _ra[], _listb[]; class A { d_Rel_List listb; }; class B { d_Rel_List ra; }; const char _ra[] = “ra”; const char _listb[] = “listb”;

SNU OOPSLA Lab 32 C++ OML: Relationships(con’t) m-m relationship extern const char _la[], _lb[]; class A { d_Rel_List lb; }; class B { d_Rel_Ref la; }; const char _la[] = “la”; const char _lb[] = “lb”; a.sb.replace_element(&bb,2) lb b a.sb.insert_element(&b); lb a la b lb a la bb

SNU OOPSLA Lab 33 C++ OML: Operations Operations(on transient and persistent objects) are defined in the OML as implemented in standard C++ –Overloading, dispatching, function call structure & invocation, member function call structure & invocation, argument passing & resolution, error handling, etc.

SNU OOPSLA Lab 34 C++ OML: d_Object Class Definition Class type definer: whether a class is persistent-capable class My_Class: public d_Object {...}; class d_Object { public: //constructor, copy constructor, destructor voidmark_modified(); //operator new voidoperator delete(void*); virtual void d_activate(); virtual void d_deactivate(); };

SNU OOPSLA Lab 35 C++ OML: d_Object Class(con’t) Misc –delete operator: remove from both application cache and database(same behavior as Ref ::delete_object) –d_activate/d_deactivate: memory allocation/deallocation –constructor: called when a object first created –destructor: called when the object deleted from database (different from d_deactivate)

SNU OOPSLA Lab 36 C++ OML: Reference Classes Objects refer to other objects through reference –A d_Ref is a reference to an instance of type T –Also, d_Ref_Any class provides a generic reference to any type –References guarantees integrity in reference to persistent objects –One anomaly exists between d_Ref and d_Ref_Any e.g. //X and Y are unrelated d_Ref x;//compilation without error d_Ref y(x);//run time error

SNU OOPSLA Lab 37 C++ OML: Reference Classes(con’t) Definition of d_Ref and d_Ref_Any template class d_Ref { public: //constructor, copy constructor, and destructor //assignment operator T*operator->();//dereference operator void delete_object(); d_Booleanoperator!() const;//boolean predicates //friend functions for equal & not-equal (==, !=) }; class d_Ref_Any { //almost same as d_Ref class };

SNU OOPSLA Lab 38 C++ OML: Collection Classes Collection templates support the representation of a collection whose elements are of an arbitrary type d_Collection d_Set d_Dictionary d_Varray d_List d_Bag

SNU OOPSLA Lab 39 C++ OML: Collection Classes(con’t) Copy semantics //Professor class is persistent-capable d_Set s1, s2; s1=s2; d_Set > sr1, sr2; sr1 = sr2; d_Ref > rs1, rs2; rs1 = rs2; d_Ref > > rsr1, rsr2; rsr1 = rsr2; How does copy semantics differs from each other?

SNU OOPSLA Lab 40 C++ OML: Collection Classes(con’t) Collections, Embedded and with d_Ref S L L L R T S T T T S R R R T T T d_Ref d_Set > d_Ref > > d_Set S R R R T T T R

SNU OOPSLA Lab 41 C++ OML: Collection Classes(con’t) d_Collection class –as an abstract class in C++, cannot have instances –definition template class d_Collection: public d_Object { public: //constructor, copy constructor, and destructor //equal & not-equal operator unsigned long cardinality(); d_Booleanis_empty() const; d_Boolean is_ordered() const; //contain, insert, remove, iterator, select, and query operations };

SNU OOPSLA Lab 42 C++ OML: Collection Classes(con’t) d_Set class –an unordered collection with no duplicates –definition template class d_Set: public d_Collection { public: //constructor, copy constructor, and destructor //union(+), intersection(*), difference(-) operations //subset, superset operations, etc. };

SNU OOPSLA Lab 43 C++ OML: Collection Classes(con’t) Example (d_Set class) //creation: d_Database db; d_Ref hjk; d_Ref > > my_profs = new(&db) d_Set >; //insertion: my_profs->insert_element(hjk); //removal: my_profs->remove_element(hjk); //deletion: my_profs.delete_object();

SNU OOPSLA Lab 44 C++ OML: Collection Classes(con’t) d_Bag class –an unordered collection with duplicates –definition template class d_Bag: public d_Collection { public: //constructor, copy constructor, and destructor unsigned longoccurrences_of(const T &element) const; //almost same as d_Set class };

SNU OOPSLA Lab 45 C++ OML: Collection Classes(con’t) d_List class –an ordered collection with duplicates –definition template class d_List: public d_Collection { public: //constructor, copy constructor, and destructor Tretrieve/remove_first/last_element() const; d_Booleanfind_element(element, position) const; Tretrieve_element_at(position) const; voidremove_element_at(position); voidreplace_element_at(element, position); //insert, concatenate operations, etc. };

SNU OOPSLA Lab 46 C++ OML: Collection Classes(con’t) d_Varray & d_Dictionary class –refer to page of the text book, ODMG 2.0

SNU OOPSLA Lab 47 C++ OML: Collection Classes(con’t) d_Iterator class –a consistent protocol for sequentially returning each element from the collection –An iterator is initialized by the create_iterator method –definition template class d_Iterator { public: //constructor, copy constructor, and destructor //assignment, equal, and not-equal operators //increment, decrement operators d_Booleannot_done() const; d_Booleannext(T &objRef); };

SNU OOPSLA Lab 48 C++ OML: Collection Classes(con’t) Example(d_Iterator class) d_Set > profset; d_Iterator > iter = profset.create_iterator(); d_Ref prof; while(iter.next(prof)) { or for( ; iter.not_done(); ++iter) {... prof = iter.get_element(); }... }

SNU OOPSLA Lab 49 C++ OML: Transactions All access, creation, modification, and deletion of persistent objects must be done within a transaction –Transactions are implemented as objects of d_Transaction –definition of class d_Transaction class d_Transaction { public: //constructor, destructor voidbegin(); voidcommit/abort(); voidcheckpoint(); voidjoin/leave();//thread operations d_Booleanis_active() const; static d_Transaction*current(); };

SNU OOPSLA Lab 50 C++ OML: Transactions(con’t) Characteristics of transaction in ODMG –Transaction must be explicitly created and started –begin/commit/abort/checkpoint operations –Transient objects are not subject to transaction semantics –“long transactions” is not defined in ODMG 2.0 –join/leave operations –usage of threads with transactions(three ways) thread transaction

SNU OOPSLA Lab 51 C++ OML: d_Database Class All operations on database are included in (transient) database object of class d_Database –open/close operations –name operations d_Database *myDB; myDB->open(“myDB”); d_Ref prof = new(myDB, “Professor”) Professor; myDB->set_object_name(prof, “hjk”);... d_Ref myprof = myDB->lookup_object(“hjk”);... myDB->close();

SNU OOPSLA Lab 52 C++ OML: d_Database Class(con’t) Definition class d_Database { public: static d_Database* const transient_memory; //constructor void open(dbname, access status); void close(); void set_object_name(const d_Ref_Any &obj, const char* name); void rename_object(oldname, newname); void lookup_object(name) const; private:... };

SNU OOPSLA Lab 53 C++ OML: d_Extent Class Class d_Extent provides an interface to the extent of a persistence-capable –Specifier of database schema definition needs to determine who maintains an extent for each persistent class User as well as ODBMS maintains an extent of persistent class (refer to Section 5.6) –d_Extent is not persistent-capable –d_Extent is semantically equivalent to d_Set –d_Extent supports polymorphism –Every d_Extent must be associated with a database

SNU OOPSLA Lab 54 C++ OML: d_Extent Class(con’t) Definition template class d_Extent { public: d_Extent(const d_Database* base, d_Boolean include_subclasses=d_True); virtual~d_Extent(); //nearly same as the d_Collection class }; polymorphism associated database

SNU OOPSLA Lab 55 C++ OML: Exceptions d_Error class defines state describing the cause of the error –refer to page page 173 of the text book, ODMG 2.0

SNU OOPSLA Lab 56 C++ OQL How are query executed in C++ binding? 1Query method on class Collection(refer to class d_Collection) int query(d_Collection &result, const char* predicate) const; Example: d_Bag > mathematicians; Students->query(mathematicians, “exist s in this.takes: s.section_of.name = \“math\” ”);

SNU OOPSLA Lab 57 C++ OQL(con’t) 2d_oql_execute function –A query gets constructed via an object of type d_OQL_Query template void d_oql_execute(d_OQL_Query &q, T &result); or template void d_oql_execute(d_OQL_Query &q, d_Iterator &result); Example: d_Bag > mathematicians; d_Bag > assisted_profs; double x = ; d_OQL_Query q1(“select t.assists.taught_by from t in TA where t.salary > $1 and t in $2”); q1 << x << mathematicians; d_oql_execute(q1, assisted_profs);

SNU OOPSLA Lab 58 Schema Access The C++ schema definition –Refer to metadata in ODL described in Chapter 2 –Presently the read interface of the schema API are supported –Application parts which take advantage of the schema API Database tool development(e.g., class and object browsers, import/export utilities, Query by Example, etc.) CASE tools Schema management tools CORBA Access control and user authorization

SNU OOPSLA Lab 59 Schema Access(con’t) The ODMG schema access class hierarchy d_Scope d_Meta_Object d_Class d_Ref_Type D_Collection_Type d_Primitive_Type d_Structure_Type d_Alias_Type d_Relationship d_Attribute d_Module d_Constant d_Parameter d_Exception d_Operation d_Property d_Type d_Inheritance Schema access interface –refer to p181 - p194 of the text book, ODMG 2.0