What is a table of tables?
Table of Tables is the use of a single two or three keyed value reference table to emulate many small, single key, field value reference tables. Looking at the commonality of field checks within any application there are only certain forms of checks that happen on them. There are free format fields which are only limited by size and character set allowed within them. There are field that are limited within ranges of values (i.e., -78.6 to 99.7 or A to F). Finally there are the fields that are filled from lists of allowed values. It is this third set of validations and set controls that the Table of Tables concept works to facilitate. Turns out 80-95% of all list reference checks have the same core functions:
Why use a table of tables?
Let's be honest with ourselves. We all have reasons to do things quickly. Tables of Tables is one of those few things that allows all levels of a development effort to get what they want.
You will also hear....
Built in Referential Integrity checks within databases cannot handle this way of working. | My perspective is that they can be made to work with some careful thought that the primary unique key in a TableofTables is with the proper SetCode of the field and not NULL for everything. |
How will this perform when it has hundreds of sets within it. | Database tables are built for handling 10s of thousands of records. A Table of Tables , if it has 1000 sets of values and the average number of values to a set is 15 but ranges from 1 to 200 then we are still only talking about 15,000 records. Well within what a typical DB table is capable of. We built this in Business Basic and the TableofTables File was loaded once and held in RAM for sessions rather than for every call. The stored procedures were likewise loaded and prepared once. This ended up being a 1000 fold performance improvement over an individual file situation. At the time a file and index load was measured as 20,000 CPU cycles and unload of 10,000 CPU cycles with about 1000 CPU instructions to do the find and response. This 30,000 CPU cycles was for every field vs the TableofTables result which was the 1000CPU instructions for the check of only slightly larger index. |
Can you get redundant / duplicate Code Sets? | Absolutely this is a data management consideration. The question then is that the set MetaData needs to help avoid this by having good descriptions and help map when valid reasons for this does exist. Guess what that is all within the Codes set ZZZSETDESC. One place. |
How can upcoming roll-outs of changes be handled with the Tableof Tables? | Set Values can get rolled out to an end environment in advance of the software to handle it as long as the EffectiveEndDate on a record is set in the past. A quick data tabel update to reset the values that are in place to have a blank EffectiveEndDate then make them valid values without any transmission and load time delays. In some situations this is why having the EffectiveEndDate as a Date and Time fields will give you release control to the second rather than just at midnight. |
Can this be used too much? | In my experience a table of tables allows anything that would otherwise get hard coded, as a value or length, to be dynamically held and referenced. In a manufacturing product development situation we set Table of Table values for the lengths of fields that were core to our effort. An example was to set the "Part Number" length to a maximum size of 20 characters. We put it in the table and dutifully referenced it whenever we needed to but never expected it to ever change. But sure enough on our 15th customer installation they needed/demanded a Part Number length of 27 characters. Had we been completely true to our goal of referencing the dynamic value whenever we needed it? The test was that we shifted that customer install to 30 in the table reference and tested. One report no longer formatted properly because it used the new value and that put the printing beyond the page width allowed by the printer. Remember - That which you believe cannot happen WILL!!! |
What are the minor additions to fulfill the 2nd iteration of Pareto's Assertion (80:20 rule)?
Structure of a table of tables
SetCode SetValue OrderNumber EffectiveEndDate Description OtherInfo
Table Field Descriptions
SetCode | 10 to 19 characters | (In some ERP systems you will see this as int or doubleint)[this is small and efficient but a a true pain to utilize as a developer] |
SetValue | 10 to 19 characters | |
OrderNumber | Integer | Special Order you wish values shown in |
EffectiveEndDate | Blank or a Valid Date. | In some rare situations you may want this to be full Date and Time. After this date the Set Value is no longer valid for verifications of new or modification of entry. |
Description | 15 to 30 characters free format | describe what the set value stands for i.e.,CA=Canada vs CA=California. This will typically be shown in any drop downs or value presentations you might display. |
OtherInfo | 15 to 30 characters free format. | My experience is that a cross reference value can be useful i.e., CAD with CA - USD with US... typically this should be something structured info and parsable. |
Primary Index | SetCode + SetValue |
Index 2 | Setcode + SetValue + EffectiveEndDate |
Index 3 | SetCode + OrderNumber + EffectiveEndDate |
ZZZSETDESC ZZZSETDESC 1 {blank} Set_MetaData_to_each_SetCode {blank}
Add/Modify a Record |
SetCode is found in the ZZZSETDESC table set |
Display Set Alpha Ever Records |
Select * from TableofTables |
Valid Value Ever Check |
Select SetValue from TableofTables |
Valid Value Date Check (aka. Value Value Now Check) High Usage for field entry checking |
Select SetValue from TableofTables Note: A processing version of this with OtherInfo in Fields list should be considered. |
Display Set Date Alpha High Usage for dropdown presentation |
Select SetValue Description from TableofTables where SetCode = Parameter1 |
Display Set Date Optimized High Usage for dropdown presentation |
Select SetValue Description OrderNumber from TableofTables where SetCode = Parameter1 |
Get Default Set Value High Usage to grab default values |
Select SetValue Description OrderNumber from TableofTables where SetCode=Parameter1 |
How to use it?