Hypergraphs and the Relational Model
Recently, I came across this post by Guyren Howe: https://lydb.xyz/relations-are-the-natural-way-to-organise-data/. It resonated with me, as it reinforced the idea that many of us believe there’s still room for significant improvement in how we model data. Broadly speaking, I have a growing hunch that we should move toward:
- A hypergraph database model, where first-class citizens are tuples (i.e. hyperedges). In this model, a relation represents an entity as an unordered set of tuples, and hypernodes can hold either atomic values or more complex data types—such as quantities, time, coordinates, or enumerated values.
- Building on this foundation, the natural query language for such a paradigm would be Datalog, as it supports n-ary relations (Prolog, CozoDB) rather than being restricted to triplets (Datomic DB and other Clojure DBs).
Essentially, I believe time has come to revisit and extend Codd’s relational model to better accommodate the needs of modern graph databases and applications based on them. In this extended model, Datalog could emerge as a superior and more intuitive alternative to SQL, incorporating key capabilities such as:
- Domain integrity to ensure values fall within acceptable ranges or sets.
- Entity integrity to guarantee the uniqueness and existence of entity identifiers.
- Referential integrity to maintain valid and consistent references between entities.
- Business rule integrity to enforce user-defined constraints that reflect real-world rules.
- Full ACID-compliant transactions to ensure reliable and consistent multi-operation processing.
- Temporal auditing to retain a complete point-in-time history of all data changes.
- Reification support to allow statements or relationships themselves to be treated as entities.
- Rule-based inference to derive new knowledge from existing data using logical rules.
I’d be very interested to hear your thoughts on this direction.
References: https://logica.dev/ https://www.cozodb.org/ https://docs.xtdb.com/xtql/tutorials/introducing-xtql.html https://docs.datomic.com/query/query-data-reference.html https://docs.relational.ai/rel/concepts/relational-knowledge-graphs/elements-rkg https://typedb.com/ https://github.com/Roenbaeck/bareclad https://www.geldata.com/ https://surrealdb.com/ https://www.ultipa.com/
Hacker News Discussion https://news.ycombinator.com/item?id=37391333
