Querying Syntax

This is a quick note describing the querying syntax I've been working on.
It's a variant of the Guha syntax (and I'm not sure where that came from, or
if he came up with it himself).  The basic idea is set constraints:

query = [selector] setExpr
selector = statements | subjects | properties | objects
setExpr = tupleExpr [conjunction] [setExpr...]
conjunction = AND | OR | XOR | THEN
tupleExpr = (constraint, constraint, constraint)
constraint = null | uri | varExpr
varExpr = "varname" [ : testExpr]
testExpr = "functionName" ( "varName", -value- )

That's just off the top of my head (I guess I need to formalize it :).

1. selector indicates which part of the statement is returned (or the whole
statement).
2. null in constraint matches anything.
3. Variables are carried across tupleExpr.  A variable is assigned a set of
possible values the first time it is used; those values are carried into the
following tuples.
4. There is a basic library of functions (and, or, xor, not, lt, le, eq, ge,
gt, etc...).
5. The default conjunction is THEN.
6. The default selector is statements.
7. THEN means to discard the statements retrieved so far, but keep the
variables.
8. I will create a nicer grammar (probably javacc) that can nest arbitrary
sets of queries.
9. With appropriate participation from an RDF source, good cost-based
optimization can be done.  I use a two phase approach -- figure out the
costs of the various parts, then execute from lowest to highest cost,
refining the solution set as I go.

Queries look like the following.  Note that the use of variables permits us
to navigate through statements very cleanly, supplying one part of a tuple
as another part in successive refinements of the solution set.

Retrieve all statements with "a_uri" as the subject:

("a_uri", null, null)

Find all properties of "a_uri" that are qualified as methods:

properties ("a_uri", x, null)(unique(x), "qualifier", "method")

Find all statements of "a_uri" that have object parts that start with
"hello":

("a_uri", null, x : startsWith(x, "hello"))

Find all statements of "a_uri" with object parts that start with "hello" or
"there".

("a_uri", null, x : startsWith(x, "hello")) OR ("a_uri", null, x :
startsWith(x, "there"))

or it could be:

("a_uri", null, x : or(startsWith(x, "hello"), startsWith(x, "there"))

Ross Judson
Managed Objects
7925 Westpark Drive
McLean, VA  22102
Phone: 703.208.3330
http://www.ManagedObjects.com
mailto:ross@ManagedObjects.com

Received on Wednesday, 11 October 2000 10:43:22 UTC