
The Functional Database [video] - jonase
http://www.infoq.com/presentations/datomic-functional-database
======
sanityinc
Such a shame about InfoQ. Seems like they've got lots of interesting content,
but the user experience is abysmal to the point where I now avoid the site.
Would it be so bad to just let us flick through the slides?

~~~
corysama
When I'm in a rush for a tldr, I want to flick through a few slides and move
on with browsing something else. But, there are a lot of times that I'm not in
a rush. When I'm taking a walk or riding the bus, an MP3 of a presentation is
a great way to have someone slowly explain an idea that I'm interested in -but
not enough to actively concentrate on researching.

Relaxing at home on the couch is another time that I'm not in a rush. I've
largely replaced evening TV time with watching presentations on various
topics. InfoQ is perfect for that. I get to have an expert take an hour to
carefully explain a topic that I'm only tangentially interested in while I
semi-nap on my couch after dinner with a beer. This has become a low-effort
means for me to gain a high-level understanding of a broad range of topics
that I wouldn't otherwise have the time or willpower to sit down and actively
study.

------
willvarfar
Everything Rich says and does is gold!

It surprises and disappoints me that he is not as well known nor revered as
the agile craftsmanship peddlers.

~~~
tazjin
I know very well who Rich is, but I don't know (and don't want to know) any of
the "agile" proponents.

~~~
pasbesoin
Early on in the movement, one of the big names who also had some fairly close
corporate associations came to speak at a user group meeting hosted at my then
BigCo location. I even passed news of the event around so that interested
parties in our local shop could head down after hours and have a listen.

I felt rather bad afterwards for having done so. One of the more useless talks
I've attended. Very superficially prescriptive (you should do X; Y has seen
benefit Z), with no meat to the description (or prescription, as it were).

Agile may well have its place. But its intersection with BigCo life, as
anecdotally exemplified in this fellow, seemed to be just more of the "same
old same old". New words, same shit.

------
nawitus
Can someone provide a one paragraph definition of the functional database?

~~~
enoch_r
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.

~~~
nawitus
Okay, 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
In 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.

~~~
DenisM
I spent years making all kinds of databases, and I approve your message.

I recently noticed that CouchDB with its notion of map-reduce views can be
used as a temporal database - make each change a "document", then make a map-
reduce job to roll up the changes to the present state (or "as of" state", if
you need it). Nice side effect is that you get free multi-master replication
with automatic conflict resolution.

Do you have any other suggestions for a temporal database?

~~~
jacques_chester
To my very great shame I am aware that there is an entire literature on the
topic and I have barely even skimmed the surface of it.

Snodgrass, a leading researcher on temporal databases, wrote a book in 90s
about it which is available for free from his website[1].

It's good because it was written before some temporal extensions were added in
SQL:2003 (I think). The problem is that almost nobody has implemented those
extensions (I believe some versions of DB2 have them), so you are left with
doing things by hand. The Snodgrass book goes into amazing detail as to why
you'd do such a thing and how to do it.

[1]
[http://www.cs.arizona.edu/~rts/tdbbook.pdf](http://www.cs.arizona.edu/~rts/tdbbook.pdf)

------
kriro
Has anyone here used the PostgreSQL package for temporal database support?
Would be interested in thoughts :)

[http://temporal.projects.pgfoundry.org/reference.html](http://temporal.projects.pgfoundry.org/reference.html)

------
juskrey
Video quality sucks hard. Is the source code from presentation available
anywhere?

~~~
616c
InfoQ is a pain in the ass, but if you open an account with their crappy site,
as mentioned by others, you can download the presentation slides at the least.
Not sure if the code mentioned will be clear, or even copy-pasteable. I know
this is probably not what you are looking for, but that is probably the best
you can do.

------
bokchoi
The code in the video is impossible to read. Are there higher-quality versions
of this video anywhere?

------
olmo
FAT -> GIT

SQL -> Datomic?

