Hi Konrad,

> I have a master record with child records where each child record is a
> string and a number. Different master records do not at all care about
> each others details.
> ...
> so is this the way you would do this?
> 
> (class  +Child +Entity)
>  (rel description (+Key +String))
>  (rel rank (+Number))
> 
> (class +Master +Entity)
> (rel children (+List +Link) ord (+Child))

While the +Child is all right in this example, the 'children' relation
is syntactically not correct.

The 'ord' is wrong. You could write

   (rel children (+List +Link) (+Child))


   The above syntax would be correct if you use '+Joints', i.e.

   (class  +Child +Entity)
   ...
   (rel master (+Joint) children (+Master))

   (class +Master +Entity)
   (rel children (+List +Joint) master (+Child))

With that, you have a bi-directional connection between master and
children. But, as you say, you don't need that, and it also wouldn't
make sense because children cannot be found outside the master's
context, so the back link is not necessary.


Another option would be not to create a separate child entity at all,
and put the data directly into the master. This is recommended if the
number if children is not too large (i.e. maximally a few dozens):

(class +Master +Entity)
(rel children (+List +Bag)
   ((+Key +String))           # description
   ((+Number)) )              # rank

The 'children' relation would then result in a list like

   (("desc1" 1) ("desc2" 2) ("desc3" 3))

BTW, I would be cautious with the '+Key' relation here. It should be
used only if all descriptions are really different. Otherwise better use
'+Ref' and/or its variations.

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

Reply via email to