Skip to content

Latest commit

 

History

History
181 lines (147 loc) · 3.79 KB

introexample.md

File metadata and controls

181 lines (147 loc) · 3.79 KB

Introduction by Example

The following examples aim to provide a quick introduction into the user facing mechanics of Nested Named Graphs.

The Basic Syntax

A nested graph, named by a blank node:

[] {:Alice :buys :Car}

A nested graph with an explicitly given name:

:X {:Alice :buys :Car}

Two (different) nested graphs, named by (different) blank nodes:

[] {:Alice :buys :Car}
[] {:Alice :buys :Car}

Some nested nested graphs, all with different names (they are tokens, not types):

:NG_1 {
    []{
        :Alice :buys :Car .
        []{:Alice :buys :Car}
        :Y {:Alice :buys :Car}
    }
}

Every triple in every nested graph is asserted and referentially transparent

The semantics of nested named graphs is that of middle of the road RDF. This:

:Y {:Alice :buys :Car} :says :Denis .

is just syntactic sugar for this:

:Y {:Alice :buys :Car}
:Y :says :Denis .

Some proposals have hacked the Turtle syntax to achieve the same goal:

:Alice :buys :Car                   # :Z
:Z :says :Denis . 

Others provide statement identifiers additionally to graph identifiers.

Nesting via Transclusion

[TODO]

A simplistic application of a nested graph

A bit like property graphs:

[]{:Alice :buys :Car} 
    :age 20 ;                               # who is 20 years old ?
    :color :black ;                         # who is black ?
    :payment :Cash ;                        # seems clear
    :purpose :JoyRiding ;                   # ditto
    :model :Coupe ;                         # ditto
    :source :Denis .                        # ditto ... or did Denis sell the car?

Targeting fragments, verbosely

:X {:Alice :buys :Car} .
:X nng:subject [
    :age 20
]
:X nng:predicate [
    :payment :Cash ;
    :purpose :JoyRiding                     # ambivalence, could also be object property
]
:X nng:object [
    :color :black ;
    :model :Coupe
]
:X nng:triple [
    ex:void ex:void                         # forEach semantics, not needed here
]
:X nng:graph [
    :source :Denis
]

A mapping to RDF a la singleton properties

:Alice :buys_1 :Car .
:buys_1 
    rdfs:subPropertyOf :buys ;
    :payment :Cash ;
    :purpose :JoyRiding ;
    :nestedIn :X ;
    rdfs:domain [
        :age 20
    ];
    rdfs:range [
        :color :black ;
        :model :Coupe
    ];
    nng:triple [
        :source :Denis
    ]

Two other mappings - fluents and n-ary relations - are provided in the section on mappings

A compact and less pedantic version

Explicit, but tedious disambiguation doesn't need to become the new religion. The target of :payment, :purpose and :source is in most cases clear enough to make explicit disambiguation unnecessary.

:X {
    :Alice :buys :Car .
} 
    nng:subject [ :age 20 ] ;
    nng:object [ :color :black ;
                 :model :Coupe ] ;
    :payment :Cash ;
    :purpose :JoyRiding ;
    :source :Denis .