|
|
|
Indexing Hook Numbers for Maximum User
Efficiency The Existing Database Structure. (This is a description of long-standing practices of the lock shop.) There are two different kinds of keys in the HOOK field, regular and other.
Problem 1: Undesirable sorting order in the location database Hook is a character field in a database containing location data (building, room, master, was [previous hook], dept., description, etc.
When I found this problem (in the early 1990s) I decided to index on the value of the hook number. dBase and FoxPro both had a function called VALUE(), which converted a character string to its numerical equivalent. The indexing command was something like INDEX ON VALUE(HOOK)TO [index name], which mostly worked but gave undesired results for the manufactures' numbers which can contain alpha characters. After experimentation I added the dot to make the value of manufacturers' numbers less than 1 to move them to the beginning of the sort. My final indexing command was something that probably shouldn't have worked (because it produced a mixed [character and numeric] result) but did exactly what was desired. It used an IIF command (the interactive version of IF) which says "if x is true, do this, otherwise that". It went something like: INDEX ON IIF( VALUE(HOOK<1), HOOK, VALUE(HOOK)) which means "IF THE VALUE OF HOOK IS LESS THAN 1, INDEX ON HOOK [the standard left to right character method], OTHERWISE INDEX ON THE NUMERIC VALUE OF HOOK." This placed all non-hook numbers in the front of the index in proper order, the rest fell into their proper order further back. This method also places each record in its proper place regardless of leading zeros, which is desirable. I don't know if Access can provide such a complex function, but I strongly recommend using the numeric value of hook when setting the order, and if necessary letting the non-hook numbers fall to beginning of the sort in any order. One possibility: create a new field, calculated to be IF(VALUE(HOOK)<1,HOOK,VALUE(HOOK)), and sort on that field (I don't know Access, so the VALUE function is probably something different, but that's the idea.)
Problem 2. The Hook database isn't indexed by physical key description. Hook database contains fields of hook, keyway, pinning, mast. It is normally sorted by hook, but there has to be another method of sorting based on keyway+pinning. This is used when you have an unmarked key and wish to find out its hook number, or when looking for a new pinning not currently existing in the system. My method was INDEX ON TRIM(KEYWAY)+" "+HOOK TO [index name]. This allowed me to input keyway (1-4 characters), space, pinning and find what I needed, but I think that skipping the fanciness and doing a simple Access equivalent of Index on keyway+pinning would work just fine, requiring Darwish to pad out short keyways with spaces when necessary.
If you have any questions, please don't hesitate to email me at
Ralph |
|
Copyright © 2001-07 by Ralph G. Johnson; all rights reserved. |