/ In this derivative version of the last example of 
/ http://code.kx.com/wiki/JB:KdbplusForMortals/kdbplus_database
/  I've used relative directory locations, but 
/ segmented files might be most usefully applied in the case of separate disks.


/ create serialized variables
`:db/LIFE set 42
`:db/f set {x*y}
`:db/lookup set ([s:`a`b`c] v:1 2 3)

/ create splayed tables
`:db/tref/ set ([] c1:1 2 3; c2:1.1 2.2 3.3)
`:db/cust/ set
    ([] sym:`:db/sym?`ibm`msft`goog;
       name:`:db/sym?`oracle`microsoft`google)

/ create segmented tables
/ To understand the parens, try `$1#'string `tom`jay`stephen
extr:{[t;r] select from t where (`$1#'string sym) within r}
	/ select from a table t all rows where the first letter of the 
	/ sym column value falls between the first and last letter of r.
	/ Thus, we want early alphabet symbols in one place and late
	/ alphabet symbols in another.

/ this table is never written to disk
tlocal:([] ti:09:30:00 09:31:00; sym:`:db/sym?`ibm`t;
    p:101 17f)

/ this table is never written to disk
qlocal:([] ti:09:29:59 09:29:59 09:30:00;
    sym:`:db/sym?`ibm`t`ibm;
    b:100.75 16.9 100.8;a:101.25 17.1 101.1)


`:am/2009.01.01/t/ set extr[tlocal;`a`m]
`:nz/2009.01.01/t/ set extr[tlocal;`n`z]
`:am/2009.01.01/q/ set extr[qlocal;`a`m]
`:nz/2009.01.01/q/ set extr[qlocal;`n`z]

/ this table is never written to disk
tlocal:([] ti:09:30:00 09:31:00; sym:`:db/sym?`t`ibm;
    p:17.1 100.9)

/ this table is never written to disk
qlocal:([] ti:09:29:59 09:29:59 09:30:00;
    sym:`:db/sym?`t`ibm`t;
    b:17 100.7 17.1;a:17.2 101.25 17.25)

`:am/2009.01.02/t/ set extr[tlocal;`a`m]
`:nz/2009.01.02/t/ set extr[tlocal;`n`z]
`:am/2009.01.02/q/ set extr[qlocal;`a`m]
`:nz/2009.01.02/q/ set extr[qlocal;`n`z]

/ `:db/par.txt 0: ("am"; "nz")
`:db/par.txt 0: ("/am"; "/nz")

/ Now, invoke this using q /db
