Home | | Database Management Systems | Overview of the C++ Language Binding in the ODMG Standard

Chapter: Fundamentals of Database Systems : Object, Object-Relational, and XML: Concepts, Models, Languages, and Standards : Object and Object-Relational Databases

Overview of the C++ Language Binding in the ODMG Standard

The C++ language binding specifies how ODL constructs are mapped to C++ con-structs.

Overview of the C++ Language Binding in the ODMG Standard

 

The C++ language binding specifies how ODL constructs are mapped to C++ con-structs. This is done via a C++ class library that provides classes and operations that implement the ODL constructs. An object manipulation language (OML) is needed to specify how database objects are retrieved and manipulated within a C++ pro-gram, and this is based on the C++ programming language syntax and semantics. In addition to the ODL/OML bindings, a set of constructs called physical pragmas are defined to allow the programmer some control over physical storage issues, such as clustering of objects, utilizing indexes, and memory management.

 

The class library added to C++ for the ODMG standard uses the prefix d_ for class declarations that deal with database concepts.46 The goal is that the programmer should think that only one language is being used, not two separate languages. For the programmer to refer to database objects in a program, a class D_Ref<T> is defined for each database class T in the schema. Hence, program variables of type D_Ref<T> can refer to both persistent and transient objects of class T.

 

In order to utilize the various built-in types in the ODMG object model such as collection types, various template classes are specified in the library. For example, an abstract class D_Object<T> specifies the operations to be inherited by all objects. Similarly, an abstract class D_Collection<T> specifies the operations of collections. These classes are not instantiable, but only specify the operations that can be inher-ited by all objects and by collection objects, respectively. A template class is specified for each type of collection; these include D_Set<T>, D_List<T>, D_Bag<T>, D_Varray<T>, and D_Dictionary<T>, and correspond to the collection types in the object model (see Section 11.3.1). Hence, the programmer can create classes of types such as D_Set<D_Ref<STUDENT>> whose instances would be sets of refer-ences to STUDENT objects, or D_Set<string> whose instances would be sets of strings. Additionally, a class d_Iterator corresponds to the Iterator class of the object model.

 

The C++ ODL allows a user to specify the classes of a database schema using the constructs of C++ as well as the constructs provided by the object database library. For specifying the data types of attributes,47 basic types such as d_Short (short integer), d_Ushort (unsigned short integer), d_Long (long integer), and d_Float (floating point number) are provided. In addition to the basic data types, several structured literal types are provided to correspond to the structured literal types of the ODMG object model. These include d_String, d_Interval, d_Date, d_Time, and d_Timestamp (see Figure 11.5(b)).

To specify relationships, the keyword rel_ is used within the prefix of type names; for example, by writing

 

d_Rel_Ref <DEPARTMENT, Has_majors> Majors_in;

 

in the STUDENT class, and

 

d_Rel_Set<STUDENT, Majors_in> Has_majors;

 

in the DEPARTMENT class, we are declaring that Majors_in and Has_majors are relationship properties that are inverses of one another and hence represent a 1:N binary relationship between DEPARTMENT and STUDENT.

 

For the OML, the binding overloads the operation new so that it can be used to create either persistent or transient objects. To create persistent objects, one must provide the database name and the persistent name of the object. For example, by writing

 

D_Ref<STUDENT> S = new(DB1, ‘John_Smith’) STUDENT;

 

the programmer creates a named persistent object of type STUDENT in database DB1 with persistent name John_Smith. Another operation, delete_object() can be used to delete objects. Object modification is done by the operations (methods) defined in each class by the programmer.

 

The C++ binding also allows the creation of extents by using the library class d_Extent. For example, by writing

 

D_Extent<PERSON> ALL_PERSONS(DB1);

 

the programmer would create a named collection object ALL_PERSONS—whose type would be D_Set<PERSON>—in the database DB1 that would hold persistent objects of type PERSON. However, key constraints are not supported in the C++ binding, and any key checks must be programmed in the class methods. Also, the C++ binding does not support persistence via reachability; the object must be stati-cally declared to be persistent at the time it is created.


Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
Fundamentals of Database Systems : Object, Object-Relational, and XML: Concepts, Models, Languages, and Standards : Object and Object-Relational Databases : Overview of the C++ Language Binding in the ODMG Standard |


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2024 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.