Hi Thorsten,
> assume I have a (hypothetical) database with objects of class +Thing
> that have relations defined like this:
>
> #+name: myBag
> #+BEGIN_SRC picolisp
> (rel stamp (+Bag)
> ((+Symbol)) # timestamp-type
> ((+Ref +Date)) # start date
> ((+Time)) ) # start time
> #+END_SRC
>
> e.g.
>
> ,--------------------------
> | stamp (active 735458 NIL)
> `--------------------------
>
> #+name: myListBag
> #+BEGIN_SRC picolisp
> (rel props (+List +Bag)
> ((+Ref +String)) # Key
> ((+String)) ) # Value
> #+END_SRC
>
> e.g.
>
> ,--------------------------------------------------------
> | props (("key1" "val1") ("key2" "val2") ("key3" "val3"))
> `--------------------------------------------------------
>
> #+name: myStringList
> #+BEGIN_SRC picolisp
> (rel tags (+List +Ref +String))
> #+END_SRC
>
> e.g.
>
> ,----------------------------
> | tags ("tag1" "tag2" "tag3")
> `----------------------------
>
>
> Now, how can I query the DB from a program, using these relations? E.g.
>
> 1. Find objects with an active (time)stamp with date 735458?
> 2. Find objects with props with key 'key1' and value 'val1' or 'val2'
> for this key?
> 3. Find objects with tags 'tag1' and 'tag3'?
The simplest is using 'collect' (not tested):
(collect 'stamp '+Thing 735458)
(filter
'((This)
(find
'((L)
(and
(= "key1" (car L))
(member (cadr L) '("val1" "val2")) ) ) )
(: props) )
(collect 'props '+Thing "key1") )
(sect
(collect 'tags '+Thing "tag1")
(collect 'tags '+Thing "tag2") )
♪♫ Alex
--
UNSUBSCRIBE: mailto:[email protected]?subject=Unsubscribe