From: aidotengineer
The concepts of property graphs and RDF (Resource Description Framework) are typically considered two distinct paradigms for working with graphs [00:01:28]. However, these concepts can be leveraged together to combine their benefits and create a versatile approach for working with knowledge graphs [00:01:01] [00:02:12].
The Knowledge Graph Mullet
The “knowledge graph mullet” analogy describes a hybrid approach: “property graph in the front and RDF triples in the back” [00:00:52] [00:00:56]. This approach aims to expose a property graph model for thinking about and querying data, while leveraging the scalability of RDF triples in the knowledge graph [00:02:26] [00:02:33].
Property Graphs
A knowledge graph is often defined as an instance of a property graph [00:02:58]. The property graph model is built upon fundamental elements:
- Nodes Nodes can have one or more labels, which categorize them and are similar to tables in relational databases [00:03:06] [00:03:09] [00:03:19].
- Relationships These connect nodes and have a single type and direction [00:03:24] [00:03:27].
- Properties Arbitrary key-value pair properties can be stored on both nodes and relationships [00:03:30] [00:03:34] [00:03:36].
The semantics of how entities are connected are encoded directly in the data model [00:03:40] [00:03:43]. Instead of simply stating two nodes are related, a property graph specifies the nature of that relationship (e.g., “this talk has a certain topic” or “this talk was presented at a conference”) [00:03:46] [00:03:57]. A core idea is having a canonical representation of “the thing” being modeled [00:04:15] [00:04:17].
In the property graph world, traversal often uses pattern matching with a query language like Cypher [00:01:45] [00:01:48].
RDF Triples
RDF originates from the Semantic Web and linked data world [00:02:05] [00:02:10]. The core concept of RDF is the triple:
- Subject
- Predicate
- Object
These can be thought of as a sentence [00:05:37] [00:05:40] [00:05:43]. In RDF, ontologies are typically used, and the query language is SPARQL [00:01:54] [00:01:58] [00:02:01].
How Dgraph Combines Both
Dgraph is an open-source project that serves as a hybrid graph database [00:02:43] [00:04:57]. It uses the property graph model for data modeling and querying, but internally it uses RDF for data interchange, working with triples as the smallest unit of record [00:05:01] [00:05:05] [00:05:09] [00:05:12].
Modeling Property Graphs as RDF Triples in Dgraph
To model a property graph as an RDF triple in Dgraph:
- Unique ID for Each Node Each node requires a unique ID, which maps to an offset on disk for efficient graph traversal [00:06:12] [00:06:15] [00:06:20] [00:06:24].
- Subject The subject of an RDF triple is always a node, specifically its unique ID, which acts as a pointer to the node [00:06:36] [00:06:40] [00:06:42] [00:06:45] [00:06:47].
- Predicate The predicate can represent either a relationship type or a property [00:06:53] [00:06:58].
- Object
- If the predicate is a relationship, the object is another node’s unique ID [00:07:00] [00:07:03].
- If the predicate is a property, the object is the value of that property [00:07:10].
Dgraph employs a “posting list” optimization, which groups data by predicate and uses a list of unique node IDs connected by that predicate, allowing for efficient graph traversal [00:07:14] [00:07:17] [00:07:21] [00:07:25] [00:07:26] [00:07:30] [00:07:32].
Dgraph’s query language, DQL, is inspired by GraphQL [00:07:41] [00:07:47]. DQL graph traversals start with a defined root criteria (often using an index) and use a nested selection set structure to specify both desired properties and the traversal path [00:08:12] [00:08:16] [00:08:18] [00:08:21] [00:08:29]. Data returned from a DQL query is JSON, matching the selection set structure [00:08:49] [00:08:52].
This hybrid approach makes Dgraph a powerful tool for Graph RAG workflows and other AI applications requiring complex data modeling and scalable graph processing [00:26:26] [00:26:27] [00:26:31].