Coral++: Adding Object-Orientation to a Logic Database Language

Divesh Srivastava, Raghu Ramakrishnan, Praveen Seshadri, S. SudarshanVLDB 1993

Introduction

Published in 1993, Coral++ represents a significant milestone in the evolution of database systems, specifically at the intersection of logic programming and object-oriented design. During this era, researchers faced a "paradigm split" in database technology. Object-Oriented (OO) databases were excellent at modeling complex data through inheritance, encapsulation, and methods, but they often lacked powerful, declarative query languages. Conversely, deductive databases featured powerful languages capable of complex recursion—essential for tasks like bill-of-materials or network analysis—but relied on structural data models that were too simplistic for modern applications.

Coral++ was developed to eliminate the "impedance mismatch," the friction caused by moving data between a rich application language (like C++) and a simpler database language (like SQL). The goal was a unified system capable of handling both complex objects and complex recursive logic in a single framework.

The Coral++ Architecture

Coral++ integrates the existing Coral deductive system with the C++ type system. Rather than inventing a new object model, the authors chose to use C++ classes directly. This allows the system to benefit from C++'s established support for inheritance, polymorphism, and encapsulation without reinventing the wheel.

Key Technical Features

  • Orthogonal Extents: In many OO databases, the system automatically tracks every instance of a class (an "extent"). Coral++ makes this optional. Users can explicitly define "extents" as database relations, which avoids the overhead of tracking every transient object and allows for more efficient memory management.
  • Hybrid Rule Syntax: Coral++ extends standard logic rules (Horn clauses) to allow C++ expressions. For example, a rule can check an object's state by calling a method directly within the logic: working(P) :- part(P), P->tested() == 1.
  • Implementation via Preprocessing: To maintain practicality, the system uses a preprocessor that translates Coral++ rules into C++ code. This code handles method invocations and attribute access, which is then compiled by a standard C++ compiler and linked to the Coral runtime. This clever design delegates class handling to the C++ compiler, avoiding the need for a complex, custom type-inference engine.
  • Imperative Sub-language: Recognizing that updates and deletions are inherently operational rather than declarative, the authors added an imperative rule-based language for modifying the database. This keeps the logic engine's semantics clean while providing the side effects necessary for real-world applications.

Application Scenarios

While the paper does not utilize the standardized benchmark datasets common in modern systems research, it evaluates the language through several complex motivating scenarios:

  1. University Database: Modeling students, employees, and departments using inheritance hierarchies.
  2. Engineering and Manufacturing: Solving "bill-of-materials" problems that require recursive queries to identify all sub-components of a given part.
  3. Stock Market Data: Utilizing array-based relations to efficiently query and analyze time-series data.

Key Insights and Results

The authors demonstrate that Coral++ can express queries that are impossible in standard SQL or even most OO-extensions of SQL, particularly those involving complex recursion over object hierarchies. A major insight was the use of "extents as relations"; by treating a collection of objects as a standard database relation, Coral++ can apply decades of logic optimization research—such as "Magic Sets" rewriting—to object-oriented data without modification.

Furthermore, for updates, Coral++ employs "deferred semantics." The system calculates all changes first and then applies them, preventing the order of updates from accidentally changing the result of a query mid-execution. This ensures a seamless integration where programmers can use declarative rules where they are most concise and imperative C++ code where it is most appropriate.

Limitations and Future Work

Despite its expressive power, Coral++ has several limitations. To avoid complex type inference at compile-time, the system requires users to explicitly cast (coerce) variables to the correct C++ type before calling methods in a rule. Additionally, declarative rules cannot create new C++ objects. This was a deliberate choice to avoid the "identity crisis"—the difficulty of assigning unique IDs to objects generated by logic rules.

Finally, while the language supports path expressions (e.g., D->head->name), the authors noted that native support for these could lead to better set-oriented performance optimizations. Physical storage issues, such as object clustering on disk, were also left as problems to be solved by the underlying storage engine rather than the language itself.

Conclusion

Coral++ successfully merged the recursive query power of deductive databases with the rich data modeling of object-oriented systems. By allowing C++ objects and method calls directly within logic rules, it provided a powerful environment for the complex engineering and multimedia applications of its time.

Summary updated

BibTeX
@inproceedings{srivastava1993coral,
  author = {Divesh Srivastava and Raghu Ramakrishnan and Praveen Seshadri and S. Sudarshan},
  title = {{Coral++: Adding Object-Orientation to a Logic Database Language}},
  booktitle = {VLDB},
  year = {1993},
}
Figure