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: "Alice", 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/Alice> <rdf:type> <http://example.org/Person>
<http://example.org/Alice> <foaf:name> "Alice"
<http://example.org/Alice> <foaf:age> "30"^^xsd:integer
<http://example.org/Alice> <foaf:knows> <http://example.org/Bob>
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 currently focuses on the LPG model. RDF support is planned for future releases. This comparison is provided for users evaluating which data model fits their needs.
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