sparql

Working with graphs

Introduction#

What is a Named Graph?

An internal database document identifier (name) used by a SQL-compliant RDBMS to partition storage of relations represented as RDF sentence/statement graphs.

Why are Named Graphs Important?

A Named Graph is like a page in a book (the database) that contains a collection of paragraphs (sentence collections). Thus, it provides a powerful mechanism for query scoping that negates the need to scope all database queries to the entire database.

Storing Data in a Named Graph

PREFIX    rdf: <https://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX    owl: <https://www.w3.org/2002/07/owl#> 
PREFIX schema: <https://schema.org/> 
PREFIX   foaf: <https://xmlns.com/foaf/0.1/>
   
WITH <urn:this:database:doc>
INSERT { <#relatedTo> a                     rdf:Property, owl:ObjectProperty ;
                      rdfs:label            "relatedTo"                      ;
                      rdfs:domain           rdfs:Resource                    ;
                      rdfs:range            xsd:anyURI                       .
         foaf:knows rdfs:subPropertyOf      <#relatedTo>                     ;
                    owl:equivalentProperty  schema:knows                     . 
         <#this>    a                       foaf:Person                      ; 
                    schema:name             "John Doe"                . 
         <#that>    a                       foaf:Person                      ; 
                    schema:name             "Jane Doe"                  . 
       }

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow