Live data from Hacker News

The Functional Database [video]

infoq.com

11–20 of 37 posts

Re: The Functional Database [video]

#11
post #9
post #3

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

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…

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

Re: The Functional Database [video]

#13

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.

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

Re: The Functional Database [video]

#14
post #9

Earlier quoted context omitted.

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…

Doesn't that mean that the database continually grows in size?

It does the same way a git repository does, by accreting deltas with enough metadata to reconstruct the full data at any point in time.

Re: The Functional Database [video]

#15

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.

That's because agile provides hype to everyone in the company, not just developers. Every single agile consultant I've met was a mediocre programmer at best.

What rich says, on the other hand, is pure gold as you said. But it needs to be understood before its value is seen.

It's hard to sell to the manager who has no clue what all of this means, even harder to compare the tradeoffs with their current approach.

Re: The Functional Database [video]

#16
post #9
post #3

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

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…

Okay, so it's a database with version control. I was actually looking for a feature like this a while back in normal databases.

Re: The Functional Database [video]

#17
post #3

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

It means that you can write pure functions (in the functional programming sense) where one (or more) of the arguments to your function is a _database value_. In haskell the types to a query function would perhaps look like this:

    query :: Query -> DBValue -> Result
instead of

    performQuery :: Query -> IO DBConn -> IO Result

Re: The Functional Database [video]

#18
post #16
post #9

Earlier quoted context omitted.

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…

Okay, so it's a database with version control. I was actually looking for a feature like this a while back in normal databases.

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.

Re: The Functional Database [video]

#19
post #9

Earlier quoted context omitted.

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…

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

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

Re: The Functional Database [video]

#20

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.

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

Actually, he is better known than all those guys selling snake oil.

Post reply on HN