To quote from the JDB Wiki:

 

 

There are three ways you can refer to columns in tables that are linked with 
foreign keys.

·         The canonical way is a list of referencing columns in the form: 
col.col...col . For example, in the sed 
<http://www.jsoftware.com/jwiki/JDB/Examples#sed>  database, column popul in 
table r can be referenced from table t as enum.secnum.rnum.popul. Note that 
this method gives a unique reference.

*       A column can be referenced by name only if it is unique in the 
database, as in column popul in the sed database.
*       A column can be referenced in the form table.name.

Note that the last two references work correctly only when there is a single 
route from the original table to the column, i.e. when no table has two columns 
both referencing the same table as foreign key.

 

However, I have found that they work fine with non-unique paths and use the 
earliest defined path by default. I encountered this issue in a situation where 
I had non-unique paths to the same value, so I think I can completely ignore 
the fact that there are multiple paths (the example below has distinct values).

 

Create__hd 'TFTABLE';'boo boolean;truth char'

Create__hd 'ANDTABLE';'andls boolean,andrs boolean;landr TFTABLE'

Create__hd 'ORTABLE';'orls boolean,orrs boolean;lorr TFTABLE'

 

Insert__hd 'TFTABLE';< 0 1;'F',:'T'

Insert__hd 'ORTABLE';< 0 0 1 1;0 1 0 1;0 1 1 1

Insert__hd 'ANDTABLE';< 0 0 1 1;0 1 0 1;0 0 0 1

 

Create__hd 'ANDORTABLE';'ls boolean,rs boolean;landrkey ANDTABLE,lorrkey 
ORTABLE'

Insert__hd 'ANDORTABLE';< (],,~@<@]) 0 0 1 1;0 1 0 1

 

   Reads__hd '* from TFTABLE'

┌───┬─────┐

│boo│truth│

├───┼─────┤

│0  │F    │

│1  │T    │

└───┴─────┘

   Reads__hd '** from ANDTABLE'

┌─────┬─────┬─────┬─────┐

│andls│andrs│landr│truth│

├─────┼─────┼─────┼─────┤

│0    │0    │0    │F    │

│0    │1    │0    │F    │

│1    │0    │0    │F    │

│1    │1    │1    │T    │

└─────┴─────┴─────┴─────┘

   Reads__hd '** from ORTABLE'

┌────┬────┬────┬─────┐

│orls│orrs│lorr│truth│

├────┼────┼────┼─────┤

│0   │0   │0   │F    │

│0   │1   │1   │T    │

│1   │0   │1   │T    │

│1   │1   │1   │T    │

└────┴────┴────┴─────┘

   

   Reads__hd '** from ANDORTABLE'

┌──┬──┬─────┬─────┬─────┬─────┬────┬────┬────┬─────────────┐

│ls│rs│andls│andrs│landr│truth│orls│orrs│lorr│lorrkey.truth│

├──┼──┼─────┼─────┼─────┼─────┼────┼────┼────┼─────────────┤

│0 │0 │0    │0    │0    │F    │0   │0   │0   │F            │

│0 │1 │0    │1    │0    │F    │0   │1   │1   │T            │

│1 │0 │1    │0    │0    │F    │1   │0   │1   │T            │

│1 │1 │1    │1    │1    │T    │1   │1   │1   │T            │

└──┴──┴─────┴─────┴─────┴─────┴────┴────┴────┴─────────────┘

 

   Reads__hd 'truth,TFTABLE.truth,landrkey.truth,lorrkey.truth from ANDORTABLE'

┌─────┬─────────────┬──────────────┬─────────────┐

│truth│TFTABLE.truth│landrkey.truth│lorrkey.truth│

├─────┼─────────────┼──────────────┼─────────────┤

│F    │F            │F             │F            │

│F    │F            │F             │T            │

│F    │F            │F             │T            │

│T    │T            │T             │T            │

└─────┴─────────────┴──────────────┴─────────────┘

 

 

Has anyone played with non-unique paths in JDB and found any situations where 
it doesn't simply take the earliest defined path as default?

 

Thanks,

Jordan

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to