On Feb 18, 3:51 pm, Jeffrey Straszheim <straszheimjeff...@gmail.com>
wrote:
> Yes. I've been thinking about a database layer that would support indexing,
> constraints, and so on. One step at a time.
Maybe I wasn't clear, I'm talking about the foundational layer.
Instead of:
(def data {
:table-1 #{ { :x 34 :y 33 } { :x 33 :y :fred } { :x "k" :y \u } }
:table-2 #{ { :a "fred" :b "mary" } { :a "sally" :b "joan" } }
})
I'm recommending:
(def data
#{{:rel :table-1 :x 34 :y 33 }
{:rel :table-1 :x 33 :y :fred }
{:rel :table-1 :x "k" :y \u }
{:rel :table-2 :a "fred" :b "mary"}
{:rel :table-2 :a "sally" :b "joan" }})
i.e. making relation and rule names non-special.
Rich
> (logic-rule (:fred :x ?x :y ?y) - (:sally :x ?x :z ?z) ("becky" :y ?y)
> (not! :janet :qqq ?z) (if < ?x ?y))
>
> Translated into positional notation (assuming the columns are named in the
> obvious way):
>
> fred(X,Y) :- sally(X,Z), becky(Y), ~Janet(Z), when X<Y.
>
> The "<" symbol can be any Clojure callable. Its return value will be
> interpreted as a boolean.
>
> So, you'd get every X,Z from the relation sally, cross product with every Y
> from becky, remove each tuple that has a Z in janet, and also remove any
> tuple where X<Y fails. The resulting X,Y would be projected as relation
> fred.
>
> On Wed, Feb 18, 2009 at 3:23 PM, Rich Hickey <richhic...@gmail.com> wrote:
>
> > On Feb 9, 8:46 am, Jeffrey Straszheim <straszheimjeff...@gmail.com>
> > wrote:
> > > No, but I'm really learning as I go here. I'll look into it.
>
> > > On Mon, Feb 9, 2009 at 7:58 AM, Rich Hickey <richhic...@gmail.com>
> > wrote:
>
> > > > Looks like you're moving apace!
>
> > > > Have you considered query/subquery optimization instead of magic sets?
>
> > > > Rich
>
> > > > On Feb 8, 7:51 pm, Jeffrey Straszheim <straszheimjeff...@gmail.com>
> > > > wrote:
> > > > > By the way, if anyone on this list has experience implementing
> > bottom-up
> > > > > optimizations for logic programs, particularly from the magic set
> > family,
> > > > > and is willing to assist, please contact me.
>
> > > > > On Sun, Feb 8, 2009 at 7:47 PM, Jeffrey Straszheim <
>
> > > > > straszheimjeff...@gmail.com> wrote:
>
> > > > > > Stratified negation is working and in trunk.
>
> > > > > > I have some cool ideas of a simple, but powerful, way to implement
> > > > > > evaluable predicates. They'll likely make it in by midweek.
>
> > > > > > The the hard part (magic sets) begins.
>
> > > > > > On Feb 8, 11:43 am, Jeffrey Straszheim <
> > straszheimjeff...@gmail.com>
> > > > > > wrote:
> > > > > > > I now have recursive queries working. My next 3 milestones are
> > > > > > stratified
> > > > > > > negation, evaluable predicates, and then some version of magic
> > sets
> > > > > > > optimization. But now, as long as your queries are non-negated
> > it is
> > > > > > > working.
>
> > > > > > >http://code.google.com/p/clojure-datalog/
>
> > I got a chance to look at your docs:
>
> >http://code.google.com/p/clojure-datalog/wiki/BasicSyntax
>
> > I think your choice of using maps (we don't call them hashes in
> > Clojure as they might not be hash tables) is right on the money for
> > Clojure, especially set-of-maps-is-relation, just like clojure.set.
>
> > Two thoughts:
>
> > I wonder though if the map of rel-names to rels isn't a wart though.
> > It's a pet peeve of mine that relation names don't end up in the db
> > like any other attribute. Yes, they'll need to be indexed, but
> > eventually you'll want to support indexing on any desired attributes
> > as well. Putting relation names in the db gives you a uniform meta-
> > query capability. I haven't thought this all the way through, but you
> > might want to think about it.
>
> > I didn't know how to interpret this:
>
> > (logic-rule (:fred :x ?x :y ?y) - (:sally :x ?x :z ?z) ("becky" :y ?y)
> > (not! :janet :qqq ?z) (if < ?x ?
> > y))
>
> > Overall, it looks very promising!
>
> > If you weren't aware of it:
>
> > Foundations of Databases: The Logical Level
> > Serge Abiteboul, Richard Hull, Victor Vianu
>
> >http://www.amazon.com/gp/product/0201537710
>
> > has good coverage of Datalog, including QSQ.
>
> > Rich
--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---