Hi Edwin,

> checking the docs out, +Aux is a "Prefix class maintaining auxiliary
> keys for +relations, in addition to +Ref or +Idx indexes. Expects a
> list of auxiliary attributes of the same object, and combines all keys
> in that order into a single index key."
> 
> which means that there must exist a primary key for the +relation in question.
> 
> however, i'm looking for a +Key with multiple columns.

Yes, that's what +Aux is doing.

If you look at the example below the above cited text:

   (rel nr (+Ref +Number))                # Normal, non-unique index
   (rel nm (+Aux +Ref +String) (nr txt))  # Combined name/number/text index
   (rel txt (+Aux +Sn +Idx +String) (nr)) # Text/number plus tolerant text index

Then you see that the two combined indexes for 'nm' and 'txt' consist of
several keys which are by themselves not unique.


Let's use this example for a stand-alone program:

################################################################
(pool "aux.db")
(push '*Bye '(call 'rm "-f" "aux.db"))

(class +A +Entity)
(rel nr (+Ref +Number))
(rel nm (+Aux +Ref +String) (nr txt))
(rel txt (+Aux +Sn +Idx +String) (nr))

(mapc
   '((N S B)
      (new T '(+A)  'nr N  'nm S  'txt B) )
   '(3 6 2 4 1 5)
   '("a" "a" "a" "b" "b" "b")
   '("Abcd" "Efgh" "Ijkl" "Mnop" "Qrst" "Uvwx") )
(commit)
################################################################

If you load this, and then look at the indexes:

   : (scan (tree 'nm '+A))
   ("a" 2 "Ijkl" . {9}) {9}
   ("a" 3 "Abcd" . {2}) {2}
   ("a" 6 "Efgh" . {8}) {8}
   ("b" 1 "Qrst" . {;}) {;}
   ("b" 4 "Mnop" . {:}) {:}
   ("b" 5 "Uvwx" . {A}) {A}


   : (scan (tree 'txt '+A))
   ("AFST" {2} . T) {2}
   ("Abcd" 3 . {2}) {2}
   ("EFS" {8} . T) {8}
   ("Efgh" 6 . {8}) {8}
   ("ISL" {9} . T) {9}
   ("Ijkl" 2 . {9}) {9}
   ("MNF" {:} . T) {:}
   ("Mnop" 4 . {:}) {:}
   ("QRST" {;} . T) {;}
   ("Qrst" 1 . {;}) {;}
   ("UFS" {A} . T) {A}
   ("Uvwx" 5 . {A}) {A}
   ("bcd" {2}) {2}
   ("fgh" {8}) {8}
   ("jkl" {9}) {9}
   ("nop" {:}) {:}
   ("rst" {;}) {;}
   ("vwx" {A}) {A}

You see that the actual indexes are lists of values. So while "a" is not
a unique name, you can access a specific object with

   : (aux 'nm '+A "a" 6)        
   -> {8}
   : (aux 'nm '+A "a" 5 "Uvwx")
   -> NIL
   : (aux 'nm '+A "b" 5 "Uvwx")
   -> {A}

Does this help?

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:[email protected]?subject=Unsubscribe

Reply via email to