On this page:
1.1 RDF Glossary
1.2 Examples

1 Introduction🔗ℹ

The RDF Data Model, or Abstract Syntax [RDF11CAS], is fundamentally very simple.

Figure 1 is a representation of the data model, extended to include common elements beyond the core described above. Elements in the darker shading are the core types of the RDF data model, those in lighter shading are extensions to the core types, while those with no shading represent data types.

The RDF Data Model

The kernel of the Data Model is the statement, or triple, as shown in the example below.

,---------+-----------+--------,

| subject | predicate | object |

'---------+-----------+--------'

This very simple structure allows multiple statements to be seen as a directed graph where subjects and objects may act as pointers between statement. For example in the following example we can see that the first three sentences on the left share a common subject, they are all statements about the thing with IRI <S1>. The last two sentences are similarly related in that they are both statements about the thing with IRI <S2>. The last statement is interesting because it’s object, <S1> is the identifier of an existing thing, allowing us to interpret a subset of the statements below as "a thing with name ’Steve’ knows a thing with the name ’Simon’". Now if we look at the two statements in the middle we see that they again share object/subject but the identity of this thing is not an IRI but is anonymous, interpreted as "a thing with name ’Simon’ has a job, which has a title ’Nerd’".

,---------+-----------+---------,

| <S1>    | is-a      | Person  |

'---------+-----------+---------'

,---------+-----------+---------,

| <S1>    | name      | "Simon" |

'---------+-----------+---------'

,---------+-----------+---------,    ,---------+-----------+--------,

| <S1>    | job       | [?]     |    | [?]     | title     | "Nerd" |

'---------+-----------+---------'    '---------+-----------+--------'

,---------+-----------+---------,

| <S2>    | name      | "Steve" |

'---------+-----------+---------'

,---------+-----------+---------,

| <S2>    | knows     | <S1>    |

'---------+-----------+---------'

A set of statements is termed a graph to denote this linking behavior. We can therefore draw the list of statements in a more graph-like form as follows. This representation clearly shows how a set of statements can easily model very complex structures.

,---------,

| <S1>    |<-----------------------------------------------,

'--|------'                                                |

   |        ,-----------+---------,                        |

   |------->| is-a      | Person  |                        |

   |        '-----------+---------'                        |

   |        ,-----------+---------,                        |

   |------->| name      | "Simon" |                        |

   |        '-----------+---------'                        |

   |        ,-----------+---------,                        |

   '------->| job       | <?>     |                        |

            '-----------+--|------'                        |

                           |        ,-----------+--------, |

                           '------->| title     | "Nerd" | |

                                    '-----------+--------' |

,---------,                                                |

| <S2>    |                                                |

'--|------'                                                |

   |        ,-----------+---------,                        |

   |------->| name      | "Steve" |                        |

   |        '-----------+---------'                        |

   |        ,-----------+---------,                        |

   '------->| knows     | <S1> ----------------------------'

            '-----------+---------'

1.1 RDF Glossary🔗ℹ

Blank Node

  

A type that allows anonymous subjects and objects where grouping is desired but there is no need for a separate and addressable resource.

Dataset

  

A collection of named graphs at most one unnamed graph refered to as the default graph. The dataset itself may also be named with an IRI.

Datatype

  

See [RDF11CAS], section 5, Datatypes (Normative).

Graph

  

A set of statements, which may be relaxed to become a list of statements allowing duplicates.

IRI

  

An Internationalized Resource Identifiers [RFC3987].

Language Tag

  

See [RFC5646] (BCP-47).

Literal

  

This represents a single, scalar, value usually corresponding to one of the data types in [XMLXSD2].

Local Name

  

A ...

Named Graph

  

A graph with an associated name, this name is an IRI.

Namespace

  

A resources containing some representation of an RDF vocabulary.

Namespace Map

  

A mapping between prefix names and namespaces, with at most one unnamed namespace.

Object

  

The value of a property, or target of a relation, between a subject and an object. A subject may be either a resource, blank node, or literal.

Predicate

  

The name of a property of, or relation between, a subject and an object.

Representation

  

A particular serialization form of a resource. In general it is assumed that if a resource may have multiple representations, each representation is isomorphic.

Resource

  

Some thing identified by one or more IRIs and which is avilable in one or more representations.

Prefix Name

  

A ...

Schema

  

A ... [RDF11SCHEMA], [OWL2].

Statement

  

A triple comprising subject, predicate, and object. In predicate logic this would be written as (predicate subject object).

Subject

  

The thing about which a statement is made. A subject may be either a resource or blank node.

Triple

  

Another term for a statement.

Vocabulary

  

A ...

1.2 Examples🔗ℹ

The example RDF used below is similar to that used in the figures above. It describes a simple five statement graph using a Github profile as the subject. Using different representations of the graph we will see how different aspects if the data model in figure 1 are implemented.

Example 1 – N-Triples

The N-Triple [RDF11NT] representation demonstrates the core elements of the RDF Data Model well as each line contains an individual statement terminated by a "." and newline.

<https://github.com/johnstonskj> <http://www.w3.org/1999/02/22-rdf-syntax-ns#> <http://xmlns.com/foaf/0.1/Person> .

<http://github.com/johnstonskj> <http://xmlns.com/foaf/0.1/name> "Simon Johnston"@en .

<http://github.com/johnstonskj> <http://xmlns.com/foaf/0.1/givenname> "Simon" .

<http://github.com/johnstonskj> <http://xmlns.com/foaf/0.1/family_name> "Johnston" .

<http://github.com/johnstonskj> <http://github.com/rdf/followers> "22"^^<http://www.w3.org/2001/XMLSchema#int> .

As we will see in most representations, IRI values are written between "<" and ">". Literal values are always enclosed in double quotes but come on three forms:

  1. Plain literals are simple strings.

  2. String values may have attached language identifiers to allow for multiple-language variants of a value. The literal value "Simon Johnston"@en has a language tag [RFC5646] after the at-sign.

  3. A literal may be explicitly typed, allowing a parser to understand the string value as some other data type. The literal value "22"^^<...#int> has the explicit XML Schema int datatype.

Example 2 – Turtle

The following example is identical to the N-Triple version, but using the Turtle [RDF11TTL] representation. This representation shows the use of namespace prefixes to shorten IRIs and generally make the representation more readable. The prefix directive creates a mapping between a prefix, a string with a colon ":" suffix, and a namespace IRI. Note that a prefix with no string before the colon is termed the default namespace. Also note that this format uses the semicolon character ";" to allow multiple predicate-object pairs for the same subject, similar to the graph representation above. Each set of statements is still terminated by a "." as in N-Triples.

@prefix : <http://github.com/>

@prefix foaf: <http://xmlns.com/foaf/0.1/> .

@prefix ghub: <http://github.com/rdf/>

 

:johnstonskj

  a foaf:Person ;

  foaf:name "Simon Johnston"@en ;

  foaf:givenname "Simon" ;

  foaf:family_name "Johnston" ;

  ghub:followers "22"^^<http://www.w3.org/2001/XMLSchema#int> .

Any valid set of RDF statements, including the empty set, is a valid RDF graph. Therefore, the resource holding the Turtle example above is a representation of an RDF graph.

Example 3 – TriG

Now we have a graph it is useful to be able to name graphs explicitly and also to document groups of graphs. RDF defines a Dataset, described in the introduction to [RDF11DS] as:

The Resource Description Framework (RDF) version 1.1 defines the concept of RDF datasets, a notion introduced first by the SPARQL specification. An RDF dataset is defined as a collection of RDF graphs where all but one are named graphs associated with an IRI or blank node (the graph name), and the unnamed default graph. Given that RDF is a data model equipped with a formal semantics, it is natural to try and define what the semantics of datasets should be.

Using TriG [RDF11TRIG] representation, a super-set of Turtle, we can see a new structure of the form graph-name {...} which binds a graphs’s name to the set of statements between "{"} and "". A graph name may be either an IRI or a blank-node, in the same way as a statement’s subject.

@prefix : <http://github.com/>

@prefix foaf: <http://xmlns.com/foaf/0.1/> .

@prefix tiny: <https://tinyurl.com/> .

 

_:G1 {

  :johnstonskj

    a foaf:Person ;

    foaf:name "Simon Johnston"@en ;

    foaf:givenname "Simon" ;

    foaf:family_name "Johnston" ;

    ghub:followers "22"^^<http://www.w3.org/2001/XMLSchema#int> .

}

Example 4 – N-Quads

The named graph labeled _:G1 can also be serialized into a format similar to the N-Triples above, N-Quads [RDF11NQ]. The difference is that each line is now comprised of subject, predicate, object, and the graph’s label (IRI or blank node).

<http://github.com/johnstonskj> <http://www.w3.org/1999/02/22-rdf-syntax-ns#> <http://xmlns.com/foaf/0.1/Person> _:G1 .

<http://github.com/johnstonskj> <http://xmlns.com/foaf/0.1/name> "Simon Johnston"@en _:G1 .

<http://github.com/johnstonskj> <http://xmlns.com/foaf/0.1/givenname> "Simon" _:G1 .

<http://github.com/johnstonskj> <http://xmlns.com/foaf/0.1/family_name> "Johnston" _:G1 .

<http://github.com/johnstonskj> <http://github.com/rdf/followers> "22"^^<http://www.w3.org/2001/XMLSchema#int> _:G1 .