Schema Design for an OODBMS

The schema is a set of class definitions in the ODL (Object Definition Language) of the ODMG standard. A class has attributes, relationships (references with inverses, which keep both directions consistent) and operations. Design steps: identify classes from the entities, define inheritance hierarchies, model 1:N and M:N links as reference or set of references with inverse, and add the methods that the application needs.

OQL (Object Query Language)

OQL is the query language of the ODMG standard and looks like SQL with path expressions:

  • select s.name from Students s where s.address.city = "Delhi";
  • select struct(n: c.title, t: c.teacher.name) from Courses c;

Features: dot notation to follow references (no explicit joins), calling methods inside queries, collections in the from clause, and operators such as exists, for all, count, avg, group by and order by.

OODBMS Architecture and Storage Issues

An OODBMS has a client-server structure: the object manager on the client caches objects and the server stores them in pages or segments. Issues are:

  • Clustering: objects used together (a part and its sub-parts) are stored on the same page to cut disk I/O.
  • Pointer swizzling: converting a stored OID into a direct memory address once the object is loaded, for fast navigation.
  • Large objects: images and documents are stored as separate segments.
  • Indexing of attributes, path expressions and methods; schema evolution when a class changes; and object caching and garbage collection.

Transactions and Concurrency Control

OODBMS applications often have long transactions (a design session of hours) in which locks held for so long are a problem. Methods are locking on objects, pages or classes with multiple granularity, optimistic control, versions and check-out and check-in of objects between a public and a private workspace. A schedule is conflict serializable if its precedence graph has no cycle; two operations conflict when they are from different transactions, on the same object, and at least one is a write.

Definition: OQL. The Object Query Language of the ODMG standard, a declarative query language for object databases that uses path expressions to follow references.

Table 1.4: OODBMS design topics

Topic Idea Benefit
Clustering Store related objects together Fewer disk reads
Swizzling OID to memory pointer Fast navigation
Check-out Private copy of object Long transactions
Versions Keep earlier states Design history

Example 1.4: Testing serializability

Problem: Two transactions give the schedule r1(A) w1(A) r2(A) w2(A) r2(B) w2(B) r1(B) w1(B). Is it conflict serializable?

Solution:

  1. On A, w1(A) comes before r2(A) and w2(A), so there is an edge T1 → T2.
  2. On B, r2(B) and w2(B) come before r1(B) and w1(B), so there is an edge T2 → T1.
  3. The precedence graph has the cycle T1 → T2 → T1.

Result: The schedule is not conflict serializable; it equals neither T1 then T2 nor T2 then T1.

sched = [(1, "r", "A"), (1, "w", "A"), (2, "r", "A"), (2, "w", "A"),
         (2, "r", "B"), (2, "w", "B"), (1, "r", "B"), (1, "w", "B")]
edges = set()
for i, (t1, o1, x1) in enumerate(sched):
    for t2, o2, x2 in sched[i + 1:]:
        if t1 != t2 and x1 == x2 and "w" in (o1, o2):
            edges.add((t1, t2))
print("Edges:", sorted(edges))
cycle = any((b, a) in edges for a, b in edges)
print("Cycle:", cycle)
print("Conflict serializable:", not cycle)

Output

Edges: [(1, 2), (2, 1)]
Cycle: True
Conflict serializable: False

Common mistakes

  • Writing joins in OQL where a path expression is enough.
  • Holding locks for the whole of a long design session.
  • Forgetting the inverse relationship, so the two directions become inconsistent.
  • Storing related objects far apart on disk.

Key takeaways

  • ODL defines the schema; OQL queries it with path expressions.
  • Clustering and pointer swizzling speed up access.
  • Long transactions use check-out and check-in, versions or optimistic control.
  • Acyclic precedence graph means conflict serializable.

Practice questions

  1. What is a path expression?
  2. What is pointer swizzling?
  3. When is a schedule conflict serializable?

Answers to the practice questions

  1. A chain of references joined by dots, such as s.address.city.
  2. Converting an OID into a memory address when the object is loaded.
  3. When its precedence graph has no cycle.

Sources

  • Official BCA syllabus Advanced Database Systems, course code 25BCA406DS04, Unit I