I'm new to clojure but I find the approach [1]Arel takes to SQL very useful. It uses relational algebra to make complex SQL statements composed by smaller structures that represent simple SQL statements.
On my current project, we use it as a way to provide the staff will a flexible query builder. They use a fancy UI in the web app to choose the "rules" they want applied to their query and the code then composes the complex statement by "merging" all those "relations" together. It's a really great way to abstract SQL and has done wonders for us in this particular project. [1] https://github.com/nkallen/arel Cheers, Leonardo Borges www.leonardoborges.com On Wed, Oct 26, 2011 at 1:04 PM, Brent Millare <[email protected]>wrote: > In the thread about Rich Hickey's talk on simplicity, people bring up the > point that Rich suggests to *finally*, learn SQL. The idea is to use > declarations to describe your solution, decoupling implementation details. > > However, its arguable that SQL itself is hard. For example, programmers can > often encounter deeply nested SQL statements. One might say the statement is > complex and thus harder to understand. What would help is if the SQL > statement could be broken up into composable pieces. Pig/Pig Latin [1], is > one such example of this, where programmers write imperative (seems more > like functional to me), statements, and you can model your data conceptually > via input and output through named bindings and operators. > > My question is this, is it possible to write composable SQL? Named > expressions might help (binding a query to a name that you can reuse in > another query), but I feel like they may not be enough. > > In core.match, queries are declarative, but one can write functions that > work on query arguments, thus giving composable queries, is this the right > approach? > > Best, > Brent > > > [1] > http://www.google.com/url?sa=t&rct=j&q=pig%20latin%20sigmod%202008&source=web&cd=2&ved=0CCIQFjAB&url=http%3A%2F%2Fciteseerx.ist.psu.edu%2Fviewdoc%2Fdownload%3Fdoi%3D10.1.1.134.9888%26rep%3Drep1%26type%3Dpdf&ei=lWenTquWGqrz0gH7jfW9Dg&usg=AFQjCNGNzB3kdxtWW3r-6q3Ts8CWhYrffg > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to [email protected] > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > [email protected] > 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 post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en
