Object Query Language (OQL)

OQL is a superset of the part of standard SQL that deals with database queries. Thus, any select SQL sentence which runs on relational tables, works with the same syntax and semantics on collections of ODMG objects. Extensions concern object-oriented notions, like complex objects, object identity, path expression, polymorphism, operation invocation, late binding, etc.

OQL provides high-level primitives to deal with sets of objects but is not restricted to this collection construct. It also provides primitives to deal with structures, lists, arrays, and treats such constructs with the same efficiency.

OQL is a functional language where operators can freely be composed, as long as the operands respect the type system. This is a consequence of the fact that the result of any query has a type which belongs to the ODMG type model, and thus can be queried again.

OQL is not computationally complete. It is a simple-to-use query language which provides easy access to an ODBMS.

Based on the same type system, OQL can be invoked from within programming languages for which an ODMG binding is defined. Conversely, OQL can invoke operations programmed in these languages.

OQL does not provide explicit update operators but rather invokes operations defined on objects for that purpose, and thus does not breach the semantics of an ODBMS which, by definition, is managed by the “methods” defined on the objects.

OQL provides declarative access to objects. Thus OQL queries can be easily optimized by virtue of this declarative nature.

The formal semantics of OQL can easily be defined.

Examples of OQL:
select distinct x.age from Persons x where x.name = “Intekhab”
>This selects the set of ages of all persons named Intekhab, returning a literal of type set.

select distinct struct(a:x.age, s: x.sex) from Persons x where x.name = “Intekhab”;
>This does about the same, but for each person, it builds a structure containing age and sex. It returns a literal of type set.

select c.address
from Persons p, p.children c
where p.address.street = “Banani” and count(p.children) >= 2 and c.address.city != p.address.city
>The example is self explanatory.

select max(select c.age from p.children c)
from Persons p
where p.name = “Intekhab”
>An example of method invocation such as “max”.

The explanation and the example given above is not even the tip of the ice berg when it comes to giving an introduction to OQL. It will only give you an essence of what sort of query language it is. I found it interesting, but thats just me.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s