Graph triples
, 2 min read
Triples are a fundamental concept in knowledge graphs, especially those based on the Resource Description Framework (RDF).
What a triple is
A triple is a data structure with three components:
- Subject: the entity or resource being described.
- Predicate: the attribute or relationship of the subject.
- Object: the value, or another entity, that the subject is related to.
Together, these three parts form a statement about the data, often likened to a simple sentence with a subject, verb and object. For example:
| Subject | Predicate | Object |
|---|---|---|
| "Alice" | "knows" | "Bob" |
This triple can be represented as:
<Alice> <knows> <Bob>
Triples in RDF
In RDF, triples make assertions about resources as subject–predicate–object expressions. They can be stored in an RDF graph, where each subject and object is a node and each predicate is an edge connecting two nodes.
Example triples in RDF format
<http://example.org/Alice> <http://example.org/knows> <http://example.org/Bob> .
<http://example.org/Alice> <http://example.org/age> "30" .
<http://example.org/Bob> <http://example.org/age> "25" .
In this example:
- The first triple states that Alice knows Bob.
- The second triple states that Alice's age is 30.
- The third triple states that Bob's age is 25.
Usage in knowledge graphs
Triples are the building blocks of RDF-based knowledge graphs. They represent complex information in a structured form that machines can easily parse and query. This enables powerful querying and the ability to infer new information from existing triples.
Knowledge graphs often use query languages such as SPARQL to query these triples and extract meaningful information from the interconnected data.
Summary
Triples are essential for representing data in RDF and knowledge graphs. They allow a structured, flexible and semantically rich representation of information.