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.
<!-- 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.
Subject ── Predicate ──▶ ObjectFor example:
| Subject | Predicate | Object |
|---|---|---|
ex:Module_042 | rdf:type | ex:PhotovoltaicModule |
ex:Module_042 | ex:hasManufacturer | ex:SunLab |
ex:Module_042 | ex:ratedPowerWatts | 410 (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.
@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:
ais shorthand forrdf:type("is an instance of").- Semicolon (
;) keeps the same subject and starts a new predicate–object pair. - Comma (
,) keeps the same subject and predicate and lists multiple objects. - 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:integeror"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:
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.