5 ms·
Is three ok? Using my limited experience playing with Datomic: A functional DB replaces a "row" that only holds the current state of the world with a list of t
by enoch_r 13y ago
Is three ok? Using my limited experience playing with Datomic:
A functional DB replaces a "row" that only holds the current state of the world with a list of timestamped "facts" that can represent either the present or any point in the past.
Instead of simply recording "Bob's favorite food is pizza," we record that "'Bob's favorite food is pizza' was added at Time X." If Bob decides his favorite food is now ice cream, we record that "'Bob's favorite food is ice cream' was added at Time Y." At any time, we can query Datomic to get the current state of the world--"Bob's favorite food is ice cream." But note that we can also query Datomic to get any past state of the world. If our query is "what was Bob's favorite food 10 minutes before Time Y?" the response will be "pizza."
A regular database is like a sheet of paper that is continually erased and drawn over with a new world-state. Datomic, as a "functional database," is like a flipbook with an updated state on every page.
- TheLoneWolfling 13y agoDoesn't that mean that the database continually grows in size?
- jeremiep 13y agoIt does the same way a git repository does, by accreting deltas with enough metadata to reconstruct the full data at any point in time.
- ExpiredLink 13y ago> A functional DB replaces a "row" that only holds the current state of the world with a list of timestamped "facts" that can represent either the present or any point in the past. ... which isn't 'functional' in any sense. It seems that Hickey just reinvented time series and tries to sell those as database.
- enoch_r 13y ago> ... which isn't 'functional' in any sense. Functional programming is very closely tied to the notion of immutable data. "Don't modify data in place" is one of the pillars of the functional model. > It seems that Hickey just reinvented time series and tries to sell those as database. Datomic is much more than a time-series, although that's the aspect that arguably makes it "functional." For example, it provides a datalog query interface and has a pretty fascinating and unique architecture that provides extremely high scalability for queries. If you don't like Datomic, or if it doesn't suit your purposes, or if you think it's overpriced for its value-added (I do), that's cool, but don't dismiss it based on a malformed understanding of what it is.
- ExpiredLink 13y ago> Functional programming is very closely tied to the notion of immutable data. "Don't modify data in place" is one of the pillars of the functional model. I don't think the Lisp fans here at HN agree. > Datomic is much more than a time-series, although that's the aspect that arguably makes it "functional." Not really. Time-series are not 'functional' by any stretch of the imagination. BTW, an add-on to Hibernate, the (in)famous OR-mapper, tries to do something similar: http://docs.jboss.org/envers/docs/index.html http://docs.jboss.org/envers/docs/index.html
- cmoscoso 13y agoIt's a functional database since it allows you to create database applications using functional programming.
- pron 13y agoNot quite. A time series' purpose is to record the change in value of some quantity over time, while this ties with the notion of persistent data structures and Hickey's philosophy of value and state which is at the heart of Clojure. The purpose is not to follow a changing quantity, but to formalize state and value. The idea is that any entity's state, at any given moment in time, is an immutable value. You can query the state at time t0, get a value, and examine it or process it for as long as you like. You can then query it again at time t1, and get another, immutable value. I guess this is a dual way of looking at time series data, with a different emphasis. The time series is intended to help with processing change, while a persistent data structure is intended to help working with a snapshot of the world as it existed in a specific instant.
- nawitus 13y agoOkay, so it's a database with version control. I was actually looking for a feature like this a while back in normal databases.
- jacques_chester 13y agoIn the database world, we call it temporal databases, because it introduces the concept of time as a first-class part of the conceptual/logical model. Every production database I've ever seen goes through some version of the same evolutionary lifecycle: 1. "We only need the current state". The database acts as a snapshot of the current world. Updates cause the loss of historical data. The database is like a state machine. 2. "Oops, actually, we need point-in-time reports". The database is hacked with date_from and date_until fields (which introduce interesting anomalies and impose programming overhead on every query written). 2a. "This is a mess, let's clean it up". The database schema is refactored so that the central model is logs of transactions. Point-in-time snapshots are derived at query time. Note that this both replicates the underlying logic of database design (much as network protocol layers are fractal). Note also that it recreates the way basic accounting works, which was the inspiration for database transactions. 3. "Oh crap, the regulations/laws/reporting standards changed". Now you need yet another layer to represent changes in the domain, not just in the data. Your point-in-time reports become even hairier as you must now write different queries depending on the time period being accounted for; and sometimes you must write queries that span both periods and include logic to combine them. The concept of a temporal database is to make points-in-time a universal, cross-cutting part of everything that happens to the database, either in the schema or the data. Rich has correctly identified the correspondence with functional immutability, where instead of modelling things as having mutable state, you model changes as a series of successor models, each of which is by itself immutable. I think it's a good idea. The world would be very different if proper temporal logic had been baked into SQL in the first place.
- SigmundA 13y agoRight the term functional is just confusing. Temporal database theory is relatively mature and even part of the SQL standard for which IBM implements in DB2. Any database that uses a append only log can potentially be temporal so long as it retains the log and exposes the information in the log (which most don't). Even say PostgreSQL uses a form short term temporal querying in order to provide MVCC, to bad they haven't taken it further to allow fully temporal standards.