Like Tim, I was thinking about the Datomic query language. Before you do that though, remember that there's some basic relational algebra functions in clojure.set <http://richhickey.github.io/clojure/clojure.set-api.html>. Stuart Halloway demonstrates this in an interesting gist<https://gist.github.com/stuarthalloway/3068749>. It's working from a clojure.set baseline, from here<http://www.lshift.net/blog/2010/08/21/some-relational-algebra-with-datatypes-in-clojure-12>. Anyways, make the best choice for your needs. Here's an example<https://gist.github.com/stuarthalloway/2645453>of Datomic queries against regular Clojure collections.
HTH Tim On Wed, Jul 24, 2013 at 3:27 PM, Timothy Baldridge <tbaldri...@gmail.com>wrote: > I think the first hint to an answer is found in your question. You are > dealing with complex data, simplify the data, and querying the data is much > simpler. > > For instance, if you have a tree, you could flatten the tree into a hash > map like this: > > {parent-id {:children [child-id1 child-id2]} > child-id1 {:children [child-id3 child-id4]} > child-id2 ...} > > Now it's very simple to say things like "who are the parents of this child > node?". Cedric is right, once you get a somewhat normalized data structure > it's fairly trivial to query it with core.logic (using hash maps like the > one above). You just have to write some code to get it into a format that > core.logic can consume. > > *However, to be honest, this is where I reach for Datomic. It has a > wicked fast query engine (datalog), you can run it in-memory (no disk > access required), it has an excellent Clojure interface, the free version > should do everything you need, and it has many many other features. For > instance, given a child node in Datomic, you can find it's parents via: > * > (let [parents (:_children child-node)] > ...) > > Not to mention that you can also create Datalog rules that allow you to > create pre-defined queries that simplify your code quite a bit. > > In short, when I hear my self saying "find X where Y" or "I'd like to > query this structure", I reach for Datomic, when that doesn't work for me > (for whatever reason) then I start coding with core.logic. > > Timothy > > > -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.