Register your product to gain access to bonus material or receive a coupon.
David Jordan was appointed a Distinguished Member of Technical Staff at Bell Laboratories for his pioneering work in applying C++ with network, relational and object databases. He holds five patents in composite object concurrency control. He is a columnist with 101 Communications, covering database technologies for objects in C++ Report and Java Report.
David Jordan is currently Director of Java Technologies at Trifolium, Inc. where he provides consulting services and custom application development in the areas of transparent object persistence. Details on his work and contact information can be found at http://www.trifolium.com/consulting/jordan
In 1991, the Object Database Management Group (ODMG) was formed to define standard interfaces for object databases. This standardization has since been achieved, and the popularity of object databases is on the rise. Similar to using SQL to access a relational database, the ODMG provides a corresponding standard for object databases. This book, technically reviewed by ODMG members, provides a comprehensive description of C++ object databases, including the C++ and Object Query Language (OQL) interfaces of the ODMG standard.
C++ Object Databases is the indispensable guide and reference to programming with C++ object databases. With this book, you will gain a thorough knowledge of the underlying modeling concepts, interfaces, and architectures. To ease the transition to object database programming, comparisons with relational databases and SQL are provided, including contrasts with the object facilities planned for SQL3.
Object databases uniquely support an object-oriented data model that is shared by the database and the application, and their tight integration with an object programming language allows developers to realize increased productivity. OQL provides excellent declarative query access to objects, supporting the same object model used by the application. C++ is currently the dominant language supported by object databases and therefore is the basis for this book.
As most object database vendors now support ODMG interfaces in their products, a working knowledge of the topics herein is essential to object database programmers. The author is uniquely qualified to present this material. He serves as the ODMG C++ Editor and has been co-editor of three ODMG books, covering releases 1.1, 1.2, and 2.0.
I. OBJECT DATABASE MODELING.
1. An Introduction.An Example Application.
ODMG: Object Database Standardization.
2. Databases, Transactions, and Exception Handling.Database Access.
Transactions.
The d_Transaction Class. Two-Phase Commit. Thread Operations.
Exceptions: Handling Failures.
A Complete Application Transaction.
3. An Overview of Object Database Modeling.The Entity-Relationship Data Model.
ER Modeling Primitives. Similarities among Database Models.
Type Categories.
Entities. Domains. Collections. Composite Entities.
Aggregation, Abstraction, and Atomicity.
4. Domains.Domains in Other Database Technologies.
Domain Categories.
Primitive Literal Types. Composite Types. Abstract Data Types.
ODMG Domain Types.
The d_String Class. The d_Interval Class. The d_Date Class. The d_Time Class. The d_Timestamp Class.
Restrictions on Using Some Types.
Unions. Bit Fields. C++ Pointers and References.
Closing Comments about Domains.
5. Persistent Entities.The Entity Abstraction.
Making a Class Persistent.
The d_Object Base Class. Instances.
Properties.
Data Attributes. Operations.
Creation.
Creating Transient Instances. Creating Persistent Instances. Clustering Instances.
Initialization at Creation.
Deletion.
Activation and Deactivation.
The d_activate and d_deactivate Functions. Activation Implementation Issues.
Instance Modification.
Concurrency Control.
Other Operations.
Assignment. Equality. Comparison.
Some Comparisons with Relational Databases.
6. Object Identification.Object Identifier.
Initialization and Assignment. Null References. Dereference Operations. Copying a Reference. Equality. Transparent Access. Representation and Implementation.
Object Naming.
Identification Based on Attribute Values.
Keys. Indexes.
Summary and Comparison with Other Databases.
7. Collections.ODMG Collections and Iterators.
Sets. Bags. Lists. Arrays. Dictionaries. ODMG Collection Element Types.
Common Collection Operations.
Maintaining the Elements of a Collection. Collection Copy and Assignment. Collection Equality.
Iteration.
Operations Specific to the Collection Type.
Subsets and Supersets. Set Operations. d_List and d_Varray Operations.
Named Collections and Extents.
Named Collections. Extents.
Other Collection Operations and Considerations.
Access of Referenced Objects. Closure Access. The Cardinality Magnitude. Stand-alone versus Embedded Collections. Collection Modifications. Collection Optimizations. Collection Indexes. Cursors.
Implementing Collections in Relational Databases.
Schema Representation. Indexes. Application Representation.
Collection Summary.
8. Relationships.Definition and Purpose of Relationships.
The Sides of a Relationship. The Degree of a Relationship. Cardinality. Unidirectional and Bidirectional Relationships. Recursive Relationships.
Relationship Interfaces. ODMG Unidirectional Relationship Declarations. ODMG Relationship Objects.
Referential Integrity Maintenance.
One-to-One Relationship Scenario. One-to-Many Relationship Scenario. Many-to-Many Relationship Scenario.
Relationship Traversal and Path Expressions.
9. Composite Objects.Composite Object Examples.
Subobjects. References to Objects That Are Not Subobjects. Composite Base Object.
Physical Organization.
Operations.
In Closing.
II. THE OBJECT QUERY LANGUAGE.
10. An Introduction to the Object Query Language.The Goals of OQL.
OQL Is a Functional Query Language.
11. OQL Expressions and Operators.Object Access.
Named Objects. Attribute Access and Relationship Traversal. Dereferencing. Null Object References. Invoking Operations on Objects. Typing an Object Expression. Construction of Objects and Structures.
Atomic Literal Expressions.
Primitive Domain Types. Arithmetic Expressions. Comparison Operators. Boolean Operators. String Expressions.
Collections.
Construction of Collection Literals. Operations on All Collections. Operations Specific to Sets and Bags. Operations Specific to Indexed Collections (list and array). Dictionary Operations. Collection Conversions.
Equality.
Functions.
Operator Precedence.
12. Predicates and Collection Queries.Iterator Variables.
Predicates.
Universal Quantification. Existential Quantification. Composite Predicates.
select ... from ... where ...
The from Clause. The where Clause. The select Clause.
The group by and having Clauses.
The order by Clause.
Joins.
Named Query Definition.
Subqueries.
Scope Rules for Names.
Iterator Variable Names. Partition Names. Name Lookup.
Summary.
13. OQL Execution Environments.Collection Queries in C++.
Queries on d_Extent.
Database Queries in C++.
Query Engine Architectural Decisions.
Query Processing Location. Execution of Operations.
III. ARCHITECTURE.
14. Object Database Architectures.Components.
Database Organization.
Logical Organization and Access. Physical Storage. Mapping of Logical to Physical Organization.
Client-Server Architecture.
Database Cache and Server Process. Client Application Cache and Process. Cache Coherency.
Closing Comments on Architecture.
15. Performance.Database Architecture.
Effective Cache Use. Disk Transfer Costs. Client-Server Transfers. Concurrency.
Performance Measurement and Benchmarks.
Generic Benchmarks. Application-specific Benchmarks. Categories of Access. Factors Affecting Performance. Application Access. Query Access.
Application Object Model and Access Patterns.
16. Database Schemas.Schema Acquisition.
Schema Access.
Name Scopes. Modules. Operations. Domains. References. Collections. Properties. Attributes. Structures. Classes. Relationships. Inheritance. Enumerations. Type Aliases.
Schema Modifications.
Class-level Modifications. Inheritance Changes. Collections. Operations. Multistep Changes.
Instance Migration.
Conversions.
Database Migration.
Immediate Conversion. Deferred Conversion. Indexes and Clustering.
IV. RETROSPECTIVE.
17. Some Comparisons between Object and Relational Database Technology.Models, Type Systems, and Languages.
The Relational Model and Environment. An Application in a Relational Environment. Object Support. The Object Implementation Language. In Contrast: C++ Object Databases. Normalization.
Data Access.
Execution.
SQL3 Support for Objects.
Abstract Data Types for Column Domains. SQL Persistent Stored Modules. Named Row Types and Reference Types. Assessment of SQL3.
18. In Closing.Type Categories.
Dual Interfaces.
Paradigm Shifts.
Standardization.
Object and Relational Databases.
Future Directions.
Java.
Appendix A. Example Schema.Preprocessor Symbols.
All Classes.
d_Bag.
d_Collection.
d_Database.
d_Date.
d_Dictionary<K,V>.
d_Error.
d_Extent.
d_Interval.
d_Iterator.
d_List.
d_Object.
d_OQL_Query.
d_Ref.
d_Ref_Any.
d_Rel_List<T, MT>.
d_Rel_Ref<T, MT>.
d_Rel_Set<T, MT>.
d_Set.
d_String.
d_Time.
d_Timestamp.
d_Transaction.
d_Varray.
STL.
Appendix C. ODMG Metaclasses.Iterators.
d_Access_Kind.
d_Alias_Type.
d_Attribute.
d_Class.
d_Collection_Type.
d_Constant.
d_Enumeration_Type.
d_Exception.
d_Inheritance.
d_Keyed_Collection_Type.
d_Meta_Object.
d_Module.
d_Operation.
d_Parameter.
d_Primitive_Type.
d_Property.
d_Ref_Type.
d_Relationship.
d_Scope.
d_Structure_Type.
d_Type.
References.It seems I was destined from the beginning of my career to be involved in object database technology. My academic advisers unintentionally led me toward the technology. Mike Warren, my undergraduate psychology professor, got me interested in both semantic network modeling and computer science. Upon graduation in 1979 I took a job with NCR Corporation in Dayton, Ohio, and pursued my M.S. in computer science at Wright State University. At NCR I worked with network model databases and was on a team that ported UNIX to an NCR machine. Along with my adviser at Wright State, Bob Dixon, I became interested in object technology when Smalltalk-80 was introduced; we worked on several object-based projects.
When I completed my master's degree in 1983, I took a job with AT&T Bell Laboratories in the UNIX System Development Laboratories at Murray Hill, New Jersey. I was very fortunate to have Tom Cargill as my mentor. Tom was developing a debugger called pi (process inspector) in a new programming language being designed by Bjarne Stroustrup. Knowing C and wanting to use object technology, I began learning C++ in 1984.
Early in 1985 I transferred to the Bell Labs site in Columbus, Ohio, where I still reside. My project developed a factory engineering application for managing circuit pack designs and the processes used to manufacture the packs. I was responsible for the database schema design and also served as the C++/OOD facilitator on the project. I began reading about a new technology called object databases. CAD/CAM was one of the original application domains to use object databases. The technology appealed to me, because it combined my interests in objects and databases, and was applicable to the project I was working on. Just a handful of commercial products were available, and they were based on special-purpose proprietary languages that integrated database functionality. It seemed that the technology would not gain very much market acceptance unless a more mainstream, general-purpose programming language was used.
At OOPSLA '85 I met Tim Andrews of Ontologic, which had a commercial object database product called Vbase. The company had its own object language called COP, which was C with object and database extensions. I encouraged Tim and others at Ontologic to abandon COP and use C++ instead. We considered establishing a joint business relationship between Bell Labs and Ontologic to jointly develop a C++ object database product, but Bell Labs wasn't interested. Ontologic developed the C++ product anyway, and I served as a member of its Technical Advisory Board. Ontologic released the first commercial C++ object database product in 1987. I tried to convince my project management and others at Bell Labs to use the technology, but they were reluctant because of a lack of standards and the absence of major players in the marketplace.
In 1992 I learned that Rick Cattell had organized a consortium of object database vendors, called the Object Database Management Group (ODMG) to define standards for object databases to be adopted by all the vendors. At last! A standard interface supported by all the vendors would lead to market acceptance. Each vendor had selected several people to serve as reviewers of the standard. Joshua Duhl, the Ontologic ODMG representative, selected me to be a reviewer. In 1993 Rick Cattell invited me to become the ODMG C++ editor. I was ecstatic. Rick had offered me an incredible opportunity. The ODMG had just released its 1.0 specification. I joined the ODMG and have served as its C++ editor for releases 1.1, 1.2, and 2.0. Implementations of the standard are now available from many of the vendors.
This book describes object databases using the ODMG C++ and Object Query Language (OQL) interfaces. It can serve as an introduction to object database technology and as a reference for anyone using an implementation of the ODMG standard.
This book is targeted toward software developers who are knowledgeable about object design and C++ and want to learn about object databases. Managers are encouraged to read the book Object Databases: The Essentials, by Mary Loomis. Other books are available that cover more technical details of object database implementations. Rick Cattell's book Object Data Management is an excellent reference.
By design, this book does not directly discuss any particular vendor or implementation. Aspects of implementations change over time as architectures adapt to advancements in computer environments and the demands of users. Other books that discuss implementation aspects of object databases have become outdated as the technology has advanced and matured.
I chose not to compare the vendors directly. As ODMG C++ editor, I need to maintain a good relationship with the vendors. If I had compared the vendors directly I would probably have gotten every vendor upset with me. People tend to react more to negative statements than to positive ones. Every implementation design decision has both positive and negative side effects. Application developers have biases based on their system requirements that guide their choice of the best architecture for their needs. Readers who want to understand the feature differences among the vendors should obtain a copy of The Object Database Handbook: How to Select, Implement, and Use Object-Oriented Databases by Doug Barry.
This book is divided into four parts. Part I covers object database modeling. The first chapter provides an introductory example to give you a feel for what it is like to develop a complete application with a C++ object database. Chapter 2 shows how to open a database, begin transactions, and commit transactions. The object modeling facilities found in an object database environment are covered in Chapters 3-9. The ODMG 2.0 standard is described. No vendor-specific interfaces are covered, although some aspects of various implementations are discussed.
Part II covers the Object Query Language (OQL), which has been adopted by the ODMG as the standard query language for object databases. It is assumed that you are not already familiar with OQL, so the OQL chapters read like a language reference manual. Object databases have historically been weak in their query language support, especially compared with relational databases. Some object database vendors have implemented their own variations of SQL access; each vendor maps the object model to SQL differently, resulting in a loss of application portability despite the use of the same query language. OQL is a powerful query language for objects, and its implementation by all the vendors will greatly enhance the acceptance of object databases. Those vendors who have not yet implemented OQL yet are driven by market demand for SQL support. If developers want query language standardization for object databases, they should insist that vendors support OQL.
Part III discusses the various architectures used by object databases. Rather than rewrite their systems from scratch, most ODMG implementers place an ODMG interface on their existing architectures. There are many differences among the vendor architectures, something that can affect the suitability of a vendor's product for a particular application. Understanding these differences is important when you're deciding among the product offerings. Performance is also covered here because the performance characteristics of an object database are often derived from its underlying architecture. Part III concludes with a discussion of the schema representation.
Part IV examines relational and object-relational databases, contrasting them with object databases. There is also a discussion of object support in the 1996 draft version of the ANSI SQL3 document as well as some musings about the future of each of these technologies with respect to Java.
The appendices have a different style from that of the body of the book. Appendix A contains the declarations of classes used by the book's examples. Appendix B and C are a complete reference to the ODMG 2.0 C++ interface. Because implementations available in the marketplace were still based on the ODMG-93 1.2 interface, I have noted the differences between the releases so that you can use this book with either release. Appendix C is devoted to the metaclasses introduced in ODMG 2.0. These classes are used by an application to access a description of a database's schema. An overview of these classes appears in Chapter 16.
I would like to thank those who provided me with software used in the writing of the examples. FranAois Bancilhon of O2 Technology and Dirk Bartels of Poet Software contributed their implementations of the ODMG-93 release 1.2 standard. Richard Patterson of Microsoft provided me with a Visual C++ 4.0 compiler, and Chris Tarr of ObjectSpace provided an STL implementation.
I gratefully acknowledge the time and effort of those who reviewed drafts of this book, including Donna Autrey, Sophie Gamerman, Carter Glass, Howard Lee Harkness, Richard Jensen, Tina Jordan, Brian Kernighan, Raymond Lai, Ed Schiebel, Olaf Schadow, Ken Sinclair, and Kathy Stark. Very special thanks goes to my friend Dennis Leinbaugh, who not only provided extensive editorial comments but also served as a professional colleague to bounce ideas off of. I would also like to thank the team at Addison-Wesley, including Katie Duffy, Marina Lang, Pamela Yee, and Jacqui Young. A special thanks also goes to Betsy Hardinger who served as copy editor, this book and future writings will benefit greatly from the things I learned from her editorial comments. Finally, I would like to extend my sincere appreciation to Mike Hendrickson and John Wait of Addison-Wesley for giving me the opportunity to publish this book.