No history yet

Introduction to RDF

Making Statements About Things

Before we can ask questions about data, we need a standard way to represent it. That's where the Resource Description Framework, or RDF, comes in. At its heart, RDF is a simple, powerful model for making statements about resources. Think of a resource as any thing you can talk about: a person, a city, a book, a scientific concept.

The core idea of RDF is to break down information into simple, three-part sentences. These sentences are called triples.

The Anatomy of a Triple

Every statement in RDF is a triple, composed of a subject, a predicate, and an object. It's just like a basic sentence in English.

Subject → Predicate → Object

Let's break that down:

  • Subject: The thing the statement is about.
  • Predicate: What you're saying about the subject. It describes a property or a relationship.
  • Object: The value of that property or the thing the subject is related to.

Consider the statement: "Marie Curie was born in Warsaw."

  • The subject is Marie Curie.
  • The predicate is was born in.
  • The object is Warsaw.

In RDF, we need to be precise. To avoid ambiguity, we don't just use text like "Marie Curie." We use unique identifiers, typically web links called IRIs (Internationalized Resource Identifiers, a more general version of URIs). This ensures that when we say "Marie Curie," we mean the famous scientist and not someone else with the same name. Predicates and many objects also use IRIs.

Writing It Down

RDF is a model, not a file format. To actually write and share RDF data, we use a specific syntax, called a serialization format. There are several, but we'll look at two common ones: Turtle and JSON-LD.

Turtle (.ttl)

Turtle is designed to be easy for humans to read and write. It's clean and concise. Here’s how you'd write our Marie Curie triple in Turtle.

# Prefixes make the IRIs shorter and more readable.
@prefix wd: <http://www.wikidata.org/entity/> .
@prefix wdt: <http://www.wikidata.org/prop/direct/> .

# The triple: Subject Predicate Object .
wd:Q7186 wdt:P19 wd:Q270 .

It might look strange at first, but it follows the same pattern: subject (wd:Q7186), predicate (wdt:P19), and object (wd:Q270), followed by a period. The @prefix lines are just shortcuts so we don't have to write out the full IRI every time.

JSON-LD (.jsonld)

JSON-LD stands for JSON for Linked Data. It embeds RDF statements within the familiar structure of JSON, which is very common in web development.

{
  "@context": {
    "@vocab": "http://www.wikidata.org/entity/",
    "bornIn": "http://www.wikidata.org/prop/direct/P19"
  },
  "@id": "Q7186",
  "bornIn": {
    "@id": "Q270"
  }
}

This format is more verbose but is easily processed by web applications. The @context part explains what the short terms like bornIn mean, and the rest of the structure defines the subject and its properties.

Understanding this simple Subject-Predicate-Object structure is the key. It’s the foundation that allows vast, interconnected datasets to be built and queried.