%META:TOPICPARENT{name="VirtTipsAndTricksGuide"}% ---+Understanding Relationship semantics and reasoning %TOC% ---++What? Using relationship semantics, reasoning, and inference to facilitate a data merge across disparate ontologies. In this case, we are building a derivative ontology from schema.org and schema.rdfs.org that addresses: * entity name (denotation) disambiguation * optional distinction of 'description' and 'definition' semantics (in our world view, a 'definition' is very precise 'description' while a 'description' is a somewhat lossy 'definition') . ---++Why? Unambiguous entity naming via de-referencable URIs, structured data, and entity relationship semantics enable extremely flexible data integration that supports alternative worldviews for different data consumers. For instance, merging schema.org, schema.rdfs.org, and our own mapping ontology occurs in frictionless manner that leaves everyone to work with views that best serve there usecase specific needs. ---++How? Import the schema.org, schema.rdfs.org ontologies into a Virtuoso instance. Then use SPARQL 1.1 Update commands to generate new triples in our specific named graph. Once the records are in place, add additional an addition triple (a magic triple, so to speak) that resolves potential conflicts between the 'description' and 'definition' properties that propagates across the entire quad store without actually materializing new triples per occurrence. Basically, this is about backward-chained (materialized temporarily at evaluation time) as opposed to forward-chained (materialized triples) form of inference. ---+++Example Let's takes as an example the [[http://schema.rdfs.org/all.ttl][schema.rdfs.org ontology]] resource file where there are definitions for Classes such as: @prefix schema: . .... schema:Book a rdfs:Class; rdfs:label "Book"@en; rdfs:comment "A book."@en; rdfs:subClassOf schema:CreativeWork; rdfs:isDefinedBy . i.e. we have the following triple: @prefix rdfs: . rdfs:isDefinedBy . ---++++Unambiguous Entity Naming and Web oriented Linked Data To aid inference and reasoning, the following must be reflected in the Virtuoso quad store: * Every class is defined by an ontology * Every property is defined by an ontology * Every ontology, class, and property is described by a document * Every ontology, its classes, and its properties must be distinctively denoted (named) using a de-referencable URI * Every Web document that describes the above must also have distinct URI. As a cost-effective best practice, for scenarios such as this, you can disambiguate the Web document and an Ontology (an abstract entity) by appending a "#" to the Web document URL. Net effect is two distinct identifiers for the Web Document and the Ontology represented by its content. Once URIs are in place for the web document and the ontology, we need to create a relations, via a new triple, that expresses the relationship between these two entities. This relationship is expressed as: << Resume From Here >> Applied to the triple from above, it would look like: @prefix rdfs: . rdfs:isDefinedBy . Since the class Book is defined by the <http://schema.rdfs.org/all.ttl#> ontology, then this triple needs to be added: @prefix rdfs: . rdfs:isDefinedby Let view it with the Virtuoso Sponger by accessing the URL: http://host:port/describe/?url=http://schema.org/Book%23this %BR%%BR%%BR%%BR% ---++++Good Reasoning ---+++++First Magic Triple For good reasoning, our mapping is still not enough for the "rdfs:isDefinedby" representation. First magic-triple-add fix is: # INSERT the Magic Triple: SPARQL PREFIX rdf: PREFIX rdfs: PREFIX wdrs: INSERT INTO { rdfs:isDefinedBy rdfs:subPropertyOf wdrs:describedby . }; Let's see what the reasoner will shown for describedby by accessing the following URL: http://host:port/describe/?url=http://www.w3.org/2007/05/powder-s%23describedby %BR%%BR%%BR%%BR% The magic triple is presented as "is subPropertyOf" "IsDefinedBy". ---+++++Second Magic Triple In our example [[http://schema.rdfs.org/all.ttl][schema.rdfs.org ontology]] resource file there are definitions for Classes such as: @prefix schema: . .... schema:Book a rdfs:Class; rdfs:label "Book"@en; rdfs:comment "A book."@en; rdfs:subClassOf schema:CreativeWork; rdfs:isDefinedBy . Also suppose as per above, the mapping ontology we are using is < http://schema.rdfs.org/all# > As a Class/Property cannot be defined by itself, then this triple: a owl:Ontology . ... schema:Book rdfs:isDefinedBy in our mapping should look like: . And to save costly creation of new triples, a 2nd magic-triple-add fix should be added: owl:sameAs . So finally the mapping should look like: . owl:sameAs . The achieved effect will be that all < http://schema.rdfs.org/all > can be seen as < http://schema.rdfs.org/all# > by the reasoner. Let's see what the reasoner will shown for by accessing the following URL: http://host:port/describe/?url=http://schema.org/Book %BR%%BR%%BR%%BR% Follow for "isDefinedBy" the "The schema.org terms in RDFS+OWL" link http://host:port/describe/?url=http%3A%2F%2Fschema.rdfs.org%2Fall: %BR%%BR%%BR%%BR% The magic triple is presented as "sameAs" "http://schema.rdfs.org/all#" . ---+++++Third Magic Triple Let's take a look at the initial example document from above, where we have an ontology, classes and properties: a owl:Ontology; dct:title "The schema.org terms in RDFS+OWL"@en; dct:description "This is a conversion of the terms defined at schema.org to RDFS and OWL."@en; foaf:page ; rdfs:seeAlso ; rdfs:seeAlso ; dct:hasFormat ; dct:hasFormat ; dct:hasFormat ; -- Classes schema:Book a rdfs:Class; rdfs:label "Book"@en; rdfs:comment "A book."@en; rdfs:subClassOf schema:CreativeWork; rdfs:isDefinedBy ; .... -- Properties schema:about a rdf:Property; rdfs:label "About"@en; rdfs:comment "The subject matter of the content."@en; rdfs:domain schema:CreativeWork; rdfs:range schema:Thing; rdfs:isDefinedBy ; .... In the beginning the ontology is described, then each class, property is described too. However are missing triples for description of how the document in question is in a relation with the ontology, the classes and the properties. So an Ontology is a document. The characteristics of a document will not contradict those of an Ontology so a 3td-magic-triple-add fix can be added: owl:Ontology rdfs:subClassOf foaf:Document, bibo:Document . The reasoning will be complete! Let's see what the reasoner will show by accessing the following URL: http://host:port/describe/?url=http%3A%2F%2Fschema.rdfs.org%2Fall %BR%%BR%%BR%%BR% Follow the attribute "type" value link "Ontology". %BR%%BR%%BR%%BR% The magic triple is presented as attribute "subClassOf" with two values "Document", respectively: -- FOAF http://kidehen.idehen.net/describe/?url=http%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2FDocument %BR%%BR%%BR%%BR% and -- Bibo http://localhost:8890/describe/?url=http%3A%2F%2Fpurl.org%2Fontology%2Fbibo%2FDocument %BR%%BR%%BR%%BR% See our [[http://wiki.usnet.private/dataspace/dav/wiki/Main/VirtSchemaOWL][detailed Guide]] for How to Convert http://schema.rdfs.org/all.ttl to our schema definition. ---++Related * [[VirtTipsAndTricksGuide][Virtuoso Tips and Tricks Collection]] * [[http://docs.openlinksw.com/virtuoso/rdfsparql.html][Virtuoso Documentation]] * [[VirtFacetBrowserInstallConfig][Install and Configure Virtuoso Faceted Browser]] * [[VirtuosoFacetsWebService][VirtuosoFacetsWebService]] * [[VirtuosoLODSampleTutorial][Use Faceted Navigation to Explore Virtuoso hosted Linked Data]]