Skip to content
SDB
Knowledge Graphs

Chapter 02 · beginner · 20 min

Triples and RDF

The W3C standard for representing linked data on the web

Subhendu Datta BhowmikAI Tutorials

The RDF Data Model

RDF (Resource Description Framework) is the W3C standard for representing knowledge graph data on the web. It defines a formal model for expressing triples — and by extension, entire knowledge graphs.

In RDF, every piece of information is expressed as a triple:

(Subject) — (Predicate) → (Object)

Each component of the triple is a resource, identified by a URI (Uniform Resource Identifier) or represented as a literal value.

The Three Types of RDF Terms

1. URIs (IRI — Internationalized Resource Identifier)

A URI uniquely identifies a resource. In RDF, URIs look like web URLs:

  • http://example.org/alice — identifies the person "Alice"
  • http://xmlns.com/foaf/0.1/knows — the "foaf:knows" predicate
  • http://www.w3.org/1999/02/22-rdf-syntax-ns#type — the "rdf:type" predicate

Subjects must be URIs (or blank nodes). Predicates must always be URIs. Objects can be URIs or literals.

2. Literals

Literals represent concrete values like strings, numbers, and dates:

  • "Alice Smith" — a plain string literal
  • "32"^^xsd:integer — a typed integer literal
  • "1979-03-14"^^xsd:date — a typed date literal
  • "Hello"@en — a language-tagged literal (English)

3. Blank Nodes

Blank nodes (bnodes) are anonymous nodes with no URI. They're used to represent complex structures without needing a global identifier:

  • Useful for intermediate nodes in reification (describing triples with triples)
  • Identified locally as _:b1, _:b2, etc.
Knowledge graph6 nodes · 5 edges

Nodes

  • aliceuri

    URI: http://example.org/alice

  • boburi

    URI: http://example.org/bob

  • Acme Corpuri

    URI: http://example.org/acme

  • "Alice Smith"literal

    Literal string value

  • "32"^^xsd:integerliteral

    Typed literal: integer 32

  • "Acme Corporation"literal

    Literal string value

Edges

  • alicefoaf:knowsbob
  • aliceorg:memberOfacme
  • alicefoaf:namelit_alice_name
  • alicefoaf:agelit_age
  • acmefoaf:namelit_company
An RDF graph showing URI nodes (colored circles) and literal nodes (white rectangles). Predicates are shown as edge labels.

RDF Serialization Formats

RDF triples can be serialized (written to files) in several formats. The most popular are:

FormatExtensionBest for
Turtle.ttlHuman-readable, most common
JSON-LD.jsonldWeb APIs, JavaScript apps
N-Triples.ntMachine processing, streaming
RDF/XML.rdfLegacy systems, verbose

The same data can be expressed in any format — they are all equivalent.

RDF triples

  • ex:alicefoaf:name"Alice Smith"

Turtle: The Human-Readable Format

Turtle (Terse RDF Triple Language) is the most popular RDF format for writing triples by hand. It uses namespace prefixes to shorten URIs:

The same facts expressed in three RDF formats
@prefix ex:   <http://example.org/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix org:  <http://www.w3.org/ns/org#> .
@prefix xsd:  <http://www.w3.org/2001/XMLSchema#> .

ex:alice
    a foaf:Person ;
    foaf:name "Alice Smith" ;
    foaf:age  32 ;
    foaf:knows ex:bob ;
    org:memberOf ex:acme .

ex:acme
    a org:Organization ;
    foaf:name "Acme Corp" .

Summary

In this chapter you learned:

  1. RDF is the W3C standard for representing triples — the atomic units of a knowledge graph
  2. RDF terms are URIs (resources), blank nodes (anonymous), or literals (values)
  3. The same graph can be serialized as Turtle, JSON-LD, or N-Triples
  4. Named graphs add a fourth component for provenance and versioning

Next, we'll look at how to define the meaning of your graph's vocabulary using ontologies and the RDFS/OWL languages.

Knowledge Graphs