Database Reference
In-Depth Information
http://example.org/NWDW#hasEmployee
http://example.org/NWDW#iri
http://example.org/NWDW#employee1
http://example.org/NWDW#HireDate
http://example.org/NWDW#LastName
http://example.org/NWDW#FirstName
1992-05-01
Nancy
Davolio
Fig. 14.1
An example of an RDF graph
Figure
14.1
depicts an RDF graph representing an employee of the
Northwind company, her first name, last name, and hire date. The following
piece of RDF/XML code describes this graph.
<
xml version
''
1.0
''
encoding=
''
utf8
''
?
>
<
rdf:RDF
xmlns:rdf=
''
http://www.w3.org/1999/02/22-rdf-syntax-ns#
''
xmlns:ex=
''
http://example.org/NWDW#
''
>
<
rdf:Description rdf:about=
''
http://example.org/NWDW#iri
''
>
<
ex:hasEmployee
>
<
rdf:Description rdf:about=
''
http://example.org/NWDW#employee1
''
>
<
ex:FirstName
>
Nancy
<
/ex:FirstName
>
<
ex:LastName
>
Davolio
<
/ex:LastName
>
<
ex:HireDate
>
1992-05-01
<
/ex:HireDate
>
<
/rdf:Description
>
<
/ex:hasEmployee
>
<
/rdf:Description
>
<
/rdf:RDF
>
The first line is the typical XML heading line, and the document starts
with the
RDF
element. The
xmlns
attribute is used to define XML namespaces
composed of a prefix and an IRI, making the text less verbose. The subject
and object of the triple representing the company and its employee are within
Description
elements, where the attribute
rdf:about
indicates the IRIs of the
resources. The
ex
prefix refers to the Northwind data warehouse.
The same triple will be written as follows using Turtle:
@prefix rdf:
<
http://www.w3.org/1999/02/22-rdf-syntax-ns#
>
.
@prefix ex:
<
http://example.org/NWDW#
>
.
ex:iri ex:hasEmployee ex:employee1 .
ex:employee1 rdf:type ex:Employee ; ex:FirstName
''
Nancy
''
;
ex:LastName
''
Davolio
''
;ex:HireDate
''
1992-05-01
''
.
Note that Turtle provides a much simpler, less verbose syntax, compared to
RDF/XML, so we use Turtle in the remainder of the chapter.
Data types are supported in RDF through the XML data type system.
For example, by default
ex:HireDate
would be interpreted as a string value
rather than a date value. To explicitly define the data types for the example
above, we would write in Turtle:
Search WWH ::
Custom Search