LPG vs RDF¶
Understanding the differences between Labeled Property Graph (LPG) and Resource Description Framework (RDF) models.
Overview¶
| Aspect | LPG | RDF |
|---|---|---|
| Primary Use | Application databases | Knowledge graphs, Linked Data |
| Query Language | GQL, Cypher | SPARQL |
| Schema | Optional, flexible | Ontologies (OWL, RDFS) |
| Properties | On nodes and edges | Predicates only |
| Identity | Internal IDs | URIs/IRIs |
Data Model Comparison¶
LPG (Labeled Property Graph)¶
Node:
- ID: internal identifier
- Labels: [Person, Employee]
- Properties: {name: "Alix", age: 30}
Edge:
- ID: internal identifier
- Type: KNOWS
- Source: Node1
- Target: Node2
- Properties: {since: 2020}
RDF (Resource Description Framework)¶
Subject-Predicate-Object Triples:
<http://example.org/Alix> <rdf:type> <http://example.org/Person>
<http://example.org/Alix> <foaf:name> "Alix"
<http://example.org/Alix> <foaf:age> "30"^^xsd:integer
<http://example.org/Alix> <foaf:knows> <http://example.org/Gus>
When to Use Each¶
Use LPG When:¶
- Building application databases
- Need rich property support on relationships
- Working with developers familiar with OOP
- Performance is critical
- Schema flexibility is needed
Use RDF When:¶
- Building knowledge graphs for data integration
- Need to link to external datasets (Linked Data)
- Require formal ontologies and reasoning
- Publishing data on the Semantic Web
- Need standardized vocabularies (FOAF, Schema.org)
Feature Comparison¶
Properties on Relationships¶
Multiple Labels¶
Identity¶
Grafeo Approach¶
Grafeo primarily uses the LPG model because:
- Developer Experience - More intuitive for application developers
- Performance - Optimized storage and query execution
- Flexibility - Easy schema evolution
- Rich Relationships - First-class properties on edges
RDF Support Status
Grafeo supports both LPG (default) and RDF (via the rdf feature flag). The LPG model is the primary focus, with RDF available for SPARQL workloads. Enable both rdf and sparql features for full RDF support. See the SPARQL user guide for details.
Converting Between Models¶
LPG to RDF¶
# Conceptual mapping
# Node (id, labels, properties) ->
# Subject-type triples + property triples
# Edge (type, source, target, properties) ->
# Subject-predicate-object + reification for properties
RDF to LPG¶
# Subject -> Node
# Predicate -> Edge type or property key
# Object -> Target node or property value
# rdf:type -> Labels