Graph-Like Data Models
As connections within your data become more complex, modeling them as a graph becomes more natural.
Property Graphs (e.g., Neo4j)
In a property graph:
- Vertices: Have a unique ID, set of incoming/outgoing edges, and key-value properties.
- Edges: Have a unique ID, head/tail vertices, a label, and properties.
Triple-Stores and SPARQL
Information is stored as statements: (subject, predicate, object).
(Jim, likes, bananas)SPARQL is the standard query language for triple-stores.
Datalog: The Foundation
Datalog is a much older language (1980s) that provides the foundation for later graph query languages. It defines rules that tell the database about new predicates derived from facts.
- Fact:
name(namerica, 'North America'). - Rule:
within_recursive(X, Y) :- within(X, Y).Datalog is powerful for complex queries because rules can be combined and reused.
Knowledge Check
Which graph model uses '(subject, predicate, object)' statements?
Property Graphs
Triple-Stores
Relational Tables