W3C home > Mailing lists > Public > www-rdf-interest@w3.org > May 2002

RE: Innovation, community and queries

From: Seaborne, Andy <Andy_Seaborne@hplb.hpl.hp.com>
Date: Thu, 23 May 2002 17:38:30 +0100
Message-ID: <5E13A1874524D411A876006008CD059F038D38C4@0-mail-1.hpl.hp.com>
To: "'Patrick Stickler'" <patrick.stickler@nokia.com>, "ext Thomas B. Passin" <tpassin@comcast.net>, RDF Interest <www-rdf-interest@w3.org>
Patrick,

Does REGS allow queries to have variables for properties?  Example: "get all
the properties and their values for a resouirce specified by URI"  I find
myself doing this to extract structured RDF graphlets (e.g. vCards) from
databases where the properties of the vCard might not all be present.

----------------------------------

<thinking out loud>

Starting with:

SELECT ?x
WHERE  (?x, <person:firstName>, "John") ,
       (?x, <person:lastName>, "Doe") ,
       (?x, <person:age>, ?age) ,
	 (?x, <person:spouse>, ?y) , (?y, <person:firstName>, "Jane")
AND
     ?age > 50

It would be nicer to inline the expression:

SELECT ?x
WHERE  (?x, <person:firstName>, "John") ,
       (?x, <person:lastName>, "Doe") ,
       (?x, <person:age>, ?age) , [ ?age > 50 ],
	 (?x, <person:spouse>, ?y) , (?y, <person:firstName>, "Jane")

also better to get rid of that intermediate variable ?y:

SELECT ?x
WHERE  (?x, <person:firstName>, "John") ,
       (?x, <person:lastName>, "Doe") ,
       (?x, <person:age>, ?age) , [ ?age > 50 ],
	 (?x, <person:spouse>, <person:firstName>, "Jane")

and that SELECT is unnecessasry so is that WHERE.  And the list commas are a
nuisance when building a query:

 (?x, <person:firstName>, "John")
 (?x, <person:lastName>, "Doe")
 (?x, <person:age>, ?age) [ ?age > 50 ]
 (?x, <person:spouse>, <person:firstName>, "Jane")

Better.  Beginning to look like XPath for RDF.  Or an N-triples derived
query format.  Its more than QEL-1 but only part of QEL-2.  A set of
conditions (graph patterns and expessions) that must be fulfilled.

But lets get all the person:* properties for the thing we find (so return a
collection of RDF graphs or one big graph depending on choice of caller):

 (?x, <person:firstName>, "John")
 (?x, <person:lastName>, "Doe")
 (?x, <person:age>, ?age) [ ?age > 50 ]
 (?x, <person:spouse>, <person:firstName>, "Jane")
 (?x, <<person:*>>, ?z)

where <<>> is a URI expression.

And also an optional item to extract:

 (?x, <person:firstName>, "John")
 (?x, <person:lastName>, "Doe")
 (?x, <person:age>, ?age) [ ?age > 50 ]
 (?x, <<person:*>>, ?z)
 (?x, <person:spouse>, <person:firstName>, "Jane")
 (?x, <person:spouse>, <person:age>, ?spouseAge) ?

Trailing ? makes the pattern match if present but not to fail the whole
query if it does not.  Maybe not the best syntax ever for that - kind of
gets lost.

-----------

</thinking out loud>

	Andy

-----Original Message-----
From: Patrick Stickler [mailto:patrick.stickler@nokia.com] 
Sent: 23 May 2002 14:44
To: ext Thomas B. Passin; RDF Interest
Subject: Re: Innovation, community and queries


On 2002-05-23 9:03, "ext Thomas B. Passin" <tpassin@comcast.net> wrote:


> I think that it will become increasingly important to be able to deal
> with patterns of statements rather than single statements or single 
> types of statements.  Think of 5-way joins in a relational database, 
> for example.  Or a simple case would be to retrieve statements where 
> there is a specific predicate and the object is also the subject of a 
> statement whose predicate is a label and whose value is specified.
> 
> I think of stereotyped structures of statements like these as idioms.
> There will be a great many idioms, and applications may well be 
> specialized for specific ones.  A reified statement could be 
> considered a kind of simple idiom.
> 
> A query language will be needed that can effectively work with idioms.
> Simple idioms, with little depth, can be handled already by some query 
> langaguages (I think, but haven't tried any of them), but I think more 
> support for stereotyped structures will be necessary.

I agree, and if those idioms are expressed in RDF, then why not also the QL?


Property values may be recursively defined by anonymous node, e.g.

Target must have a dc:creator which has a first name of "John", a last name
of "Doe" and have an age that is greater than 50 and a spouse who's first
name is "Jane":

<regs:Query>
   <dc:creator>
      <rdf:Description>
         <person:firstName>John</person:firstName>
         <person:lastName>Doe</person:lastName>
         <person:age>
            <regs:QValue>
               <regs:gt>50</regs:gt>
            </regs:QValue>
         </person:age>
         <person:spouse>
            <rdf:Description>
               <person:firstName>Jane</person:firstName>
            </rdf:Description>
         </person:spouse>
      </rdf:Description>
   </dc:creator> 
</regs:Query>

Such a QL could support idioms of arbitrary depth, where
the query is simply a template to match against the RDF graph.

And folks who already know RDF can easily learn and use the ontology to
express such queries without having to learn yet-another-language -- not to
mention the benefits of being able to use RDF and XML tools to express/view
their queries.

Cheers,

Patrick

--
               
Patrick Stickler              Phone: +358 50 483 9453
Senior Research Scientist     Fax:   +358 7180 35409
Nokia Research Center         Email: patrick.stickler@nokia.com
Received on Thursday, 23 May 2002 12:38:52 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 7 December 2009 10:51:54 GMT