W3C home > Mailing lists > Public > semantic-web@w3.org > July 2009

Re: When to use object property vs datatype property

From: Rinke Hoekstra <hoekstra@uva.nl>
Date: Mon, 20 Jul 2009 11:22:02 +0200
Cc: <semantic-web@w3.org>
Message-Id: <75CB87C4-A941-401F-9E86-47BCE883CE2C@uva.nl>
To: <kj@iteegosearch.com>
Hi Kevin,

The following code uses the ARC2 php classes (see [1]) retrieve the  
results of a SPARQL query from a SPARQL endpoint, and creates a select  
block. The variables in the SPARQL query are '?concept' and '?label'.

(this is a literal copy from some of my code, so there's quite a bit  
of clutter. The gist should be clear though).

	function getSelectBlock($sparql_query,$onChange,$name='conceptlist', 
$value_fn='concept',$label_fn='label') {
		// print "<pre>".htmlentities($sparql_query)."</pre>";
		
		$rows = $this->store->query($sparql_query, 'rows');
		
		
		
		if (!$this->store->getErrors()) {
			print "<select multiple size='10' class='conceptList' name='". 
$name."' onchange='".$onChange."'>\n";
			foreach($rows as $row) {
				$label = $row[$label_fn];
				$value = $row[$value_fn];
				print "<option value='".urlencode($value)."'>".$label."</option>\n";
			}		
			print "</select>";
		} else {
			foreach($this->store->getErrors() as $error) {
				print $error."<br/>";
			}
			throw new Exception("Errors! ".$this->store->getErrors());
		}
		
	}

The form that contains the select block will send only the value of  
the selected option, which is the URI of the resource.

Adding statements to the repository is repository-specific... (some  
support SPARQL UPDATE)

Good luck,

Rinke

[1] http://arc.semsol.org/


On 20 jul 2009, at 11:09, Kevin Jenkins wrote:

> Hi Rinke,
>
> Thanks for the very informative reply. It makes a lot of sense.  
> Between your
> and Toby's replies I think I'm making sense of it now. I agree that  
> object
> properties should be used as often as possible to keep all of the  
> objects
> connected and thereby resulting in a much more powerful knowledge  
> based. You
> are correct that all of my individuals are created through web  
> forms. I
> would be very keen on seeing an example of how you create the drop- 
> down list
> you refer to. Do you have an example of php code I could analyze to  
> see if
> that would be a workable solution for me? I really appreciate your  
> help.
> Thanks. kevin
>
> -----Original Message-----
> From: semantic-web-request@w3.org [mailto:semantic-web- 
> request@w3.org] On
> Behalf Of Rinke Hoekstra
> Sent: Monday, July 20, 2009 12:48 AM
> To: Toby A Inkster
> Cc: kj@iteegosearch.com; semantic-web@w3.org
> Subject: Re: When to use object property vs datatype property
>
> Hi Kevin,
>
> I think you are being too strict. Indeed, if individuals are only  
> created
> through some web-form, there must be some way of adding relations  
> between
> them, or between individuals and data.
>
> Why is it so hard to assert an object-property relation between e.g.
> an employee and company in a web-form?
>
> I could easily create a drop-down list of all companies that exist  
> in my
> triple-store. This list will show the names of companies, but when  
> one of
> them is selected, and the form is submitted, is is actually the URI  
> of the
> company resource that is sent back to the form handler.
>
> My rule of thumb is that I always use object properties, unless I  
> don't want
> to say anything more about the value of that property. For instance,  
> if I
> want to specify a 'name' that relates some person or company to a  
> name, I
> can just use a datatype property since I don't really need to say  
> anything
> else about the name.
>
> But relating a company to a product is different, because it may be  
> useful
> for my application to say additional things about the product (e.g.  
> price,
> cost, weight, name, category etc.). I need something to group all  
> these
> additional things together, and therefore represent each product as  
> an OWL
> individual as well. The relation between company and product should  
> then be
> an object property.
>
> (NB: a datatype property for 'has_product' on a company individual  
> with the
> value of the 'name' property of some product individual does not  
> relate the
> company to the product according to the RDF/OWL
> semantics)
>
> Good luck,
>
> 	Rinke
>
>
>
> On 19 jul 2009, at 10:15, Toby A Inkster wrote:
>
>> On 19 Jul 2009, at 07:40, Kevin Jenkins wrote:
>>
>>> It's my understanding that object properties link individuals via a
>>> property and that datatype properties link individuals to data (such
>>> as form input). [...] I have many properties in my ontology such as
>>> has-company-name, has-software-product, is-employee-of etc . my  
>>> guess
>>> is these must be datatype properties because somewhere (I guess a  
>>> web
>>> form) somebody has to name the company, choose the software product
>>> category from a list, indicate who the employer is etc.
>>
>>
>> That's not correct.
>>
>> An object property is a property that takes a resource (an object) as
>> its value. A datatype property is a property that takes a literal
>> (string, number, date/time, boolean, etc) as its value.
>>
>> e.g.
>>
>> <#kj> rdf:type foaf:Person ;
>>     foaf:name "Kevin Jenkins" ;
>>     foaf:mbox <mailto:kj@iteegosearch.com> ;
>>     foaf:mbox_sha1sum "d610935545bb79ad673d5a5e7bd45a11f9b12128" ;
>>     foaf:knows <#alice> .
>>
>> In the above, foaf:mbox and foaf:knows are object properties, while
>> foaf:name and foaf:mbox_sha1sum are datatype properties. (rdf:type is
>> also logically an object property, though I think OWL treats it as a
>> special case.)
>>
>> --
>> Toby A Inkster
>> <mailto:mail@tobyinkster.co.uk>
>> <http://tobyinkster.co.uk>
>>
>>
>>
>
>
>
> ---
> Drs Rinke Hoekstra
>
> Leibniz Center for Law      |  AI Department
> Faculty of Law              |  Faculty of Sciences
> Universiteit van Amsterdam  |  Vrije Universiteit
> Kloveniersburgwal 48        |  De Boelelaan 1081a
> 1012 CX  Amsterdam          |  1081 HV Amsterdam
> +31-(0)20-5253499           |  +31-(0)20-5987752
> hoekstra@uva.nl             |  hoekstra@few.vu.nl
>
> Homepage: http://www.leibnizcenter.org/users/rinke
>
>
>
>
>
>



---
Drs Rinke Hoekstra

Leibniz Center for Law      |  AI Department
Faculty of Law              |  Faculty of Sciences
Universiteit van Amsterdam  |  Vrije Universiteit
Kloveniersburgwal 48        |  De Boelelaan 1081a
1012 CX  Amsterdam          |  1081 HV Amsterdam
+31-(0)20-5253499           |  +31-(0)20-5987752
hoekstra@uva.nl             |  hoekstra@few.vu.nl

Homepage: http://www.leibnizcenter.org/users/rinke
Received on Monday, 20 July 2009 09:22:36 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 1 March 2016 07:42:13 UTC