Declarative Objectivity (DO) Language : Getting Started With DO
Getting Started With DO
What is DO?
DO is a database language for working with the contents of an Objectivity/DB federated database, which is the distributed graph data store provided with ThingSpan. With DO, you can create, query, update, and delete the classes that describe your data, and the class instances that represent your data in storage.
A typical DO statement looks like this:
SELECT phoneNumber, lastName FROM Person WHERE YEAR(birthdate) < 1930;
This statement is a DO query that retrieves the phone numbers and last names of persons born before 1930.
DO shares many features with industry-standard database languages, such as SQL and Cypher. For example, if you are familiar with SQL, you may recognize some of the clauses, expressions, and keywords in the preceding sample statement.
If you are familiar with Cypher, you will see that DO also supports statements that match patterns within graphs of interconnected data. For example, the following statement uses a path pattern to describe persons who talked for at least 10 minutes to persons born before 1930. If data is found that matches this pattern, the statement returns the last name of each caller:
MATCH (caller:Person)-->(pc:PhoneCall {duration >= 10})-->(called:Person {YEAR(birthdate) < 1930}) RETURN caller.lastName;
Like both SQL and Cypher, DO is a declarative language, in that its statements describe a desired outcome without specifying how that outcome is to be achieved. So, for example, the SELECT statement above simply states the goal of the search (persons of a certain age group), without specifying any details about the search itself. We don’t know, for example, in which order the persons are inspected, nor do we need to. DO automatically handles any optimizations required to make its searches more efficient.
DO offers a number of significant advantages. One of these is its XPath-style syntax for specifying indirect values. For example, here’s one way you can find out who received calls from persons living in a certain postal-code area:
SELECT madeCalls.recipient.lastName FROM Person WHERE livesAt.postalCode == '40061';
You do not need to perform a JOIN operation between persons, addresses, and phone calls. Rather, you can use DO’s “dot” operator to return values from related objects.
Note:Although DO is similar to SQL and Cypher in substantial ways, it is not completely identical to either language. You should think of DO as a “subset extension” of each language.
How to Run a DO Query
If DO looks reasonably familiar to you, and you already have some data in a federated database, you may want to try out some queries.
You can submit DO statements to a federated database in several ways. Choose the tool or interface that is most convenient for you.
Tool or interface
objy DO <options>
Command-line tool called the DO runner, for submitting DO statements at a command prompt, through a file, or in an interactive interpreter. Writes results to the prompt window or to a file.
Objectivity REST
REST API for submitting DO statements to a query resource.
Entering statements at a command prompt
Here’s a DO runner command that evaluates an individual DO statement against the data in a federated database called phoneCalls.
objy DO -statement "SELECT phoneNumber, lastName FROM Person WHERE YEAR(birthdate) < 1930;" -bootFile phoneCalls.boot 
Entering statements through a file
Here’s a DO runner command that executes any number of DO statements that were previously saved in a text file called Each statement is evaluated in succession against the data in a federated database called phoneCalls.
objy DO -inFile -bootFile phoneCalls.boot 
Entering statements interactively
Here’s a DO runner command that starts the DO runner in interactive mode, which is an interpreter with its own prompt. In this mode, you can run DO statements without repeating the DO command options. Notice that you can break long statements over multiple lines. /EXIT terminates the interactive DO session.
objy DO -bootFile phoneCalls.boot
DO> SELECT phoneNumber, lastName FROM Person WHERE YEAR(birthdate) < 1930;
DO> ...
DO> MATCH (caller:Person)-->
       (pc:PhoneCall {duration > 10})-->
       (called:Person {YEAR(birthdate) < 1930}) 
        RETURN caller.lastName; 
DO> ...
Learn More
You can obtain a brief overview of DO capabilities by continuing with the following topics:
A Quick Tour
You can learn about DO concepts and practices by reading the topics in:
Querying for Data
Working With Data
You can learn about specific syntactic elements of the DO language by reading the topics in:
Data Statements and Data Clauses
Expressions and Operator Expressions
Schema Statements, Schema Clauses, and Attribute Structures