Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Datalog patterns for changing data

I am considering using datalog as a database backend for an application I am writing, because I see potential to allow me to switch between representations easily without having to sacrifice my collected data or write a cumbersome migration.

However, I can't foresee how I would deal with changing data -- e.g. something as simple as a user-changeable password. I had an idea to tag rows with a date:

changepassword(<user>, <passhash>, <date>)

and then use the latest, but there does not seem to be a way to get the latest, without returning all rows and filtering them on the application side.

How are datalog applications designed to handle changing data?

like image 775
luqui Avatar asked Aug 19 '13 14:08

luqui


1 Answers

If you look at http://c2.com/cgi/wiki?QueryLanguageComparison you'll see that Datalog doesn't have the capability to perform aggregation, min, max, top N and such, due to the transitive relationships and recursive queries.

Essentially you'd have to do any aggregation etc in the application layer, which is far from ideal.

However, there is at least one product (which I must admit I haven't used or looked into detail) which extends the Datalog syntax for these cases: Datomic, look up the section "Aggregates Returning a Single Value".

like image 98
Andrew not the Saint Avatar answered Sep 30 '22 13:09

Andrew not the Saint