Learn / Ontologies & KGs / Module 01

Ontologies & KGs · Module 01

What Is an RDF Triple? (Reading & Writing Turtle)

Represent facts as subject–predicate–object graphs in Turtle so both humans and machines share the exact same model.

12 min Foundations Updated 2026-12-03 RDFTurtleKnowledge Graphs
Silent visual walkthrough. Read the lesson.

<!-- Thompson Axiomata LLC — Brent Alexander Thompson -->

Why graphs instead of another spreadsheet?

Spreadsheets and relational tables are great until two teams call the same thing by different column names—module_id, panel_sn, assetCode—or want to connect data across five files without fragile VLOOKUP chains.

RDF (Resource Description Framework) solves that by breaking every fact down to the smallest possible statement: a triple.

text
Subject  ──  Predicate  ──▶  Object

For example:

SubjectPredicateObject
ex:Module_042rdf:typeex:PhotovoltaicModule
ex:Module_042ex:hasManufacturerex:SunLab
ex:Module_042ex:ratedPowerWatts410 (integer)

Reading Turtle (.ttl) in 60 seconds

Turtle is the most human-readable way to write RDF. Instead of repeating long URLs (called IRIs) on every line, you declare short @prefix shortcuts at the top.

turtle
@prefix ex:   <https://example.org/pv/> .
@prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd:  <http://www.w3.org/2001/XMLSchema#> .

ex:Module_042
    a ex:PhotovoltaicModule ;
    rdfs:label "Field Test Module 042"@en ;
    ex:hasManufacturer ex:SunLab ;
    ex:ratedPowerWatts "410"^^xsd:integer ;
    ex:installedOn "2026-03-14"^^xsd:date .

Four tiny punctuation rules unlock 95% of every Turtle file you will ever read:

  1. a is shorthand for rdf:type ("is an instance of").
  2. Semicolon (;) keeps the same subject and starts a new predicate–object pair.
  3. Comma (,) keeps the same subject and predicate and lists multiple objects.
  4. Period (.) ends the statement.

IRIs vs. literals

Every object in RDF is either:

  • Another node (an IRI) like ex:SunLab — which lets you keep traversing links (ex:SunLab ex:locatedIn ex:Florida .).
  • A literal value like "410"^^xsd:integer or "Field Test Module 042"@en — a concrete string, number, boolean, or date.

Try it in Python with RDFLib

You can parse and inspect a Turtle snippet locally in five lines of Python:

python
from rdflib import Graph

ttl = """
@prefix ex: <https://example.org/pv/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

ex:Module_042 a ex:PhotovoltaicModule ;
    ex:ratedPowerWatts "410"^^xsd:integer .
"""

g = Graph().parse(data=ttl, format="turtle")
for s, p, o in g:
    print(s.n3(g.namespace_manager), p.n3(g.namespace_manager), o)

<!-- Thompson Axiomata LLC — Brent Alexander Thompson -->

Finished this module?

Mark it complete to update your browser-local progress bar for Ontologies & KGs.