What Is RDF? A Data Model Built on Triples
#rdf#semantic-web#ontology#knowledge-graph#data-model
Contents
A security device records one detection. Stored in a table, it looks like this.
| id | type | source IP | score |
|---|---|---|---|
| 42 | ransomware | 192.0.2.10 | 0.92 |
Expressed in RDF (Resource Description Framework), that one row becomes three lines.
Below is the result in N-Triples, one of the RDF file formats (# lines are explanatory comments).
# Detection 42 is a ransomware detection
<http://example.org/detection/42> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/RansomwareDetection> .
# The source IP of detection 42 is 192.0.2.10
<http://example.org/detection/42> <http://example.org/sourceIp> <http://example.org/ip/192.0.2.10> .
# The score of detection 42 is 0.92
<http://example.org/detection/42> <http://example.org/score> "0.92"^^<http://www.w3.org/2001/XMLSchema#decimal> .
The id became the first element of every line, and each remaining column became a line of its own.
Each line states what, through which property, connects to what, in that order.
1. What RDF Stands For
RDF is short for Resource Description Framework.
1.1 Resource
Not only things that exist, such as detection 42, an IP address or a host, but also a concept like “ransomware detection” is a resource.
1.2 Description
A property such as “the score is 0.92” and a relation such as “the source IP is 192.0.2.10” are described in RDF with sentences of the same shape; RDF does not treat them differently.
1.3 Framework
RDF is a framework that standardizes both the graph structure that holds data and the file formats for storing it (serialization formats).
| Word | Meaning | In RDF |
|---|---|---|
| Resource | a thing | anything that can be given a name |
| Description | describing | properties of resources and relations between them |
| Framework | structure | a graph with directed, named edges, plus its file formats |
2. The RDF Data Model: Triples
RDF expresses data with three elements: subject, predicate and object.
A line made of these three elements is called a triple.
| Subject | Predicate | Object |
|---|---|---|
| detection 42 | has type | ransomware detection |
| detection 42 | has source IP | 192.0.2.10 |
| detection 42 | has score | 0.92 |
| 192.0.2.10 | belongs to host | web-01 |
To link an owner to a detection in a relational database, you first change the schema by adding a column or a table.
In RDF, you add one triple with an owner predicate.
Drawn as a picture, the subject and object of a triple are nodes and the predicate is the arrow between them.
Arrows connect at nodes that appear in several triples, such as detection 42, and together they form a graph.
An RDF graph is a set of triples.
Adding the same triple twice still leaves one triple in the graph.
3. IRIs: Why Names Look Like URLs
Resources are named with IRIs (Internationalized Resource Identifiers).
An IRI is a global identifier that looks like http://example.org/detection/42, and it identifies one thing uniquely.
- Names do not collide. Even if companies A and B both define
Host, their IRIs differ. - The same IRI is one node. When data from different sources is merged, identical IRIs become one node.
An IRI is only an identifier; it does not have to be an address you can open.
4. What Goes into a Triple
The RDF 1.1 specification defines three kinds of values in a triple: IRIs, literals and blank nodes.
| Kind | Allowed position | Example |
|---|---|---|
| IRI | subject, predicate, object | <http://example.org/ip/192.0.2.10> |
| Literal (value) | object | "0.92"^^xsd:decimal, "ransomware"@en |
| Blank node (unnamed node) | subject, object | _:b0 |
A literal is a lexical form plus a datatype IRI.
"0.92"^^xsd:decimal is the decimal 0.92, while a plain quoted "0.92" is a string (xsd:string).
A language tag gives names per language, as in "랜섬웨어"@ko and "ransomware"@en.
A blank node is an intermediate node that needs no name of its own.
It groups several values together, as in “address = [city Seoul, postal code 04524]”.
A label such as _:b0 is local to one file, so _:b0 in another document is a different node.
5. Shortening IRIs with Prefixes
Formats such as Turtle shorten the common beginning of IRIs with a short prefix.
@prefix ex: <http://example.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
After these declarations, ex:sourceIp means <http://example.org/sourceIp> and xsd:decimal means <http://www.w3.org/2001/XMLSchema#decimal>.
A prefix only shortens the notation; the stored IRI is the same.
The common rdf:type can be written as just a in Turtle.
6. Serialization Formats: Turtle, N-Triples and Others
RDF is a data model, and there are several formats for storing it in a file (serialization formats).
The detection record from the introduction looks like this in Turtle and in N-Triples.
# Turtle: prefixes and ; avoid repeating the subject, so it is easy to read and write
@prefix ex: <http://example.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<http://example.org/detection/42> a ex:RansomwareDetection ;
ex:sourceIp <http://example.org/ip/192.0.2.10> ;
ex:score "0.92"^^xsd:decimal .
# N-Triples: one triple per line, nothing abbreviated, easy to process line by line
<http://example.org/detection/42> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/RansomwareDetection> .
<http://example.org/detection/42> <http://example.org/sourceIp> <http://example.org/ip/192.0.2.10> .
<http://example.org/detection/42> <http://example.org/score> "0.92"^^<http://www.w3.org/2001/XMLSchema#decimal> .
| Format | Characteristics | Typical use |
|---|---|---|
| Turtle | prefixes and abbreviations, easy to read | writing ontologies and mappings |
| N-Triples | one triple per line, no abbreviation | large outputs, streaming, line-by-line comparison |
| N-Quads | N-Triples plus a fourth element (graph name) | output with named graphs |
| TriG | Turtle plus graph blocks | writing named graphs by hand |
| JSON-LD | RDF in JSON form | structured data in web pages, API responses |
| RDF/XML | the oldest, XML-based format | exchange with older tools |
Changing the format does not change the graph.
7. Merging Graphs from Different Sources
If different systems name the same thing with the same IRI, their graphs can be merged as they are.
When both the detection system and the asset inventory use ex:ip/192.0.2.10, the merged graph connects detection 42 all the way to host web-01.
If one side stored the IP as a string literal or used a different IRI, the identifiers have to be aligned first.
8. Named Graphs and Datasets
To separate triples by source or by collection batch, use named graphs.
A graph name is added to each triple to show which graph it belongs to.
A default graph plus any number of named graphs is called a dataset.
<http://example.org/detection/42> <http://example.org/sourceIp> <http://example.org/ip/192.0.2.10> <http://example.org/graph/edr> .
<http://example.org/ip/192.0.2.10> <http://example.org/host> <http://example.org/host/web-01> <http://example.org/graph/cmdb> .
In N-Quads, the last element is the graph name.
Separating EDR data and asset inventory data by graph lets you query only one graph or reload one collection batch.
| Named graphs | Formats |
|---|---|
| Supported | N-Quads, TriG, JSON-LD |
| Not supported | N-Triples, Turtle, RDF/XML |
9. Adding Properties and Relations to a Triple
Suppose there is a triple “the source of detection 42 is 192.0.2.10”.
Trying to add “engine v3 made this decision, with confidence 0.8” to it runs into a problem.
The engine and the confidence belong to the triple itself, not to detection 42 or the IP, yet the subject of a triple can only be an IRI or a blank node.
RDF 1.1 offers two ways to add properties and relations to a triple.
- Reification: create a description node (
rdf:Statement) that points back to the original triple throughrdf:subject,rdf:predicateandrdf:object. Describing one triple takes four more triples, and the description is not automatically linked to the original triple. - Separate node: turn the relation itself into a node (a source observation,
obs42) and attach the IP, the engine and the confidence to it. The structure is simple, but the direct relationdetection42 sourceIp ip/192.0.2.10disappears and queries change shape.
10. Schemas Are Defined in RDF Too
RDF itself does not say that RansomwareDetection is a kind of MalwareDetection, or that the value of sourceIp is an IP.
Classes and properties are defined with schema languages such as RDFS and OWL, and the definitions are themselves RDF triples.
@prefix ex: <http://example.org/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
ex:RansomwareDetection rdfs:subClassOf ex:MalwareDetection .
ex:sourceIp rdfs:domain ex:Detection ; rdfs:range ex:IPAddress .
| Standard | What it defines |
|---|---|
| RDFS | classes, subclasses, and the classes a property connects |
| OWL | classes and properties defined with logical conditions; a reasoner infers new facts from them |
| SKOS | term systems: broader and narrower terms, synonyms, mappings to other systems |
| SHACL | the shape data must have, e.g. “a detection must have exactly one score” |
RDF is a data model, and an ontology is a model that defines the meaning of concepts and relations.
RDFS and OWL ontologies are expressed in RDF as well.
SHACL is for validating data, a different job from OWL reasoning.
11. How RDF Differs from Property Graphs (Neo4j)
The model Neo4j uses is the property graph (labeled property graph).
In 2024, GQL, a query language for property graphs, became an ISO standard.
| RDF | Property graph | |
|---|---|---|
| Names | resources identified by IRIs | mostly internal IDs; external IDs can be stored as properties |
| Values on edges | turn the relation into a separate node, or use reification | properties directly on the edge |
| Schema | RDFS and OWL schemas, SHACL validation rules | product-specific schema and constraint features |
| Query language | SPARQL | Cypher, GQL |
| Strengths | integrating data from different sources, reusing standard schemas, reasoning | exploring relations within one application, intuitive modeling |
Property graphs are convenient for quickly modeling relations inside one service and working with edge properties.
RDF fits better when systems need to share identifiers and schemas.
12. Ways to Create RDF Data
| Method | Description | Example |
|---|---|---|
| Writing it directly | write triples in a format such as Turtle | ontologies, small reference data |
| Converting existing data | convert databases, JSON or CSV with mapping rules | R2RML for relational databases, RML for JSON, CSV and XML as well |
| Embedding in web pages | embed JSON-LD in HTML | structured data for search engines (schema.org) |
Whichever method you use, check three things.
- A graph is a set. Generating the same triple several times leaves one triple in the graph. Whether duplicate lines actually disappear from an output file depends on the tool.
- Formats hold different information. To keep named graphs, store data as N-Quads or TriG.
- A literal is a lexical form plus a datatype. When converting database values to literals, keep datatypes and lexical forms consistent so other systems can compare them. The same number written differently can become a different literal.
Common Misconceptions
- ❌ RDF is XML.
✅ RDF/XML is one serialization format. Turtle, N-Triples and JSON-LD exist too. - ❌ RDF is an ontology.
✅ RDF is a data model; an ontology is a conceptual model defined with RDFS or OWL. - ❌ An IRI must be a web address you can open.
✅ An IRI is an identifier. Making it return a description when opened (a dereferenceable IRI) is a Linked Data principle, not a requirement of the RDF standard. - ❌ The same triple twice means two facts.
✅ A graph is a set, so it is one. - ❌ A triple store and a graph database are the same thing.
✅ They name things differently and attach values to edges differently.
Summary
- RDF expresses relations as triples of subject, predicate and object, and adds new relations by adding triples.
- Data from different systems connects into one graph just by merging, as long as it uses the same IRIs.
- A graph is a set of triples. Named graphs separate triples by graph, and properties and relations on a triple are expressed with reification or a separate node.
- Serialization formats hold different information. Use N-Quads or TriG when you need named graphs.
- Schemas and ontologies are defined with RDFS, OWL and SKOS, and data shapes are validated with SHACL.