Thanks for the reply!

That makes sense, I knew it must have something to do with the b-tree index 
structure, but have just been following examples and language reference.  
'collect and 'select are definitely more appropriate for the exploration I am 
doing (though I am also curious about the low level stuff too)

If you don't mind, I am still having a bit of trouble figuring out if my E/R 
models are correct, and also if I'm creating objects in the right way. Here's 
what I have so far, I'd appreciate any comments or hints!  Thank you!

(class +User +Entity)
(rel nr (+Need +Key +Number))
(rel name (+Need +Idx +String))
(rel memberships (+List +Joint) user (+Membership))

(class +Group +Entity)
(rel name (+Need +Idx +String))
(rel memberships (+List +Joint) group (+Membership))

(class +Membership +Entity)
(rel role (+Need +Ref +String))
(rel user (+Joint) id (+User))
(rel group (+Joint) name (+Group))

(obj ((+User) nr 1) name "Grant")
(obj ((+Group name "Go Club")))
(commit)

(obj ((+Membership) role "Organizer") user (db 'nr '+User 1) group (db 'name 
'+Group "Go Club"))
(commit)

Grant


Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Sunday, May 19, 2019 12:40 AM, Alexander Burger <a...@software-lab.de> wrote:

> Hi Grant,
>
> welcome here :)
>
> > My name is Grant and I'm just getting started with picolisp. I'm trying an
> > exercise to model user-groups and memberships with the Entity/Relation 
> > database.
> > I must be misunderstanding something, or doing something strange because I
> > can't seem to create/retrieve items the way I expect to. For example:
>
> I think you did everything perfectly right.
>
> But 'iter' is a rather low-level function. If you call it as
>
> > (iter (tree 'name '+User) '((This) (println (: name))))
>
> it printsall entries in the b-tree. As your 'name' relation is an '+Idx', it
> creates several entries per value.
>
> If you want to iterate only the primary entries, you can pass a boolean 5th
> argument to 'iter':
>
> (iter (tree 'name '+User)
> '((This) (println (: name)))
> NIL
> T
> T )
>
> Or use one of the higher-level functions which know about the relations and
> handle them properly
>
> (collect 'name '+User)
> (collect 'name '+User NIL T 'name)
>
> In interactive mode you can also just
>
> (select +User)
> (select +User name "Grant")
> (select nr name memberships +User name "Grant")
>
> ☺/ A!ex
>
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe



--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to