« - »

Look-up Tables: Data type look-up table

10 August 2008

I decided to call my look-up table of property types Data Type, because I’m starting to think that it will have broader application than just its current use in the look-up table subsystem. On a number of occasions, I have implemented the concept of data “attributes” that can be customized for specific purposes, and I can see using this table, or something like it, to define attribute “types” in the same manner as we are defining property “types” here. For example, you can have a generic user system that can be extended by using sites with custom-defined user “attributes”. A table such as this one would be a good addition to such a strategy, as you could establish the “type” of attribute instead of just using a generic text field.

Since we are using the look-up table subsystem to develop a portion of the look-up table subsystem, it gets a little confusing at times, but the resulting “virtual” tables that are created are pretty much equivalent in concept to any other data table — they just happen to reside in a single, generic physical table in the database. The Data Type table is no exception, and like many look-up tables, it has some additional data in it beyond the basic labels and values normally found in a look-up table. Here are the additional properties that I have defined so far:

maximumSize (Decimal)
Eventually, this value will be used to set the size of certain text input fields, and will also be used in user input validation. A “size” is not really appropriate for all data types. For data types where size is not a useful data point, this property should be set to zero (0).
sourceUsed (Boolean)
The idea of “source” refers to having a fixed list of valid values. At this point, the only “source” available for such values would be another look-up table. Eventually, I can see including other, outside sources as well, but I haven’t even gotten the internal look-up table source working at this point, so I’m not quite ready to get that ambitious.
inputControl (Text)
This is the first “code snippet” text block, and unlike all of the others, the language for this one is HTML. The concept here is that you provide the basic HTML template for the input control for this type of data, with some placeholders that will be resolved at runtime. So far, the only placeholder that I have programmed is the tagName, which should be coded as {0} … eventually, I plan to have a few others, particularly the “size” attribute, which will probably be coded as {1}, and then {2} will end being something else and so on … somewhere, there will have to be list of all of these, but for now, it’s just the tagName, so we’re pretty safe.
populationScript (Text)
This is another “code snippet” text block. The language for this one, and all of those that follow, is Javascript. The concept here is that you are provided with a populated field called “value” and you need to provide the code to take that value and place in within your input control (see above) for user editing.
validationScript (Text)
The script that you place here actually has two jobs: 1) validate the user input, and move the data out of your control and back into the field called “value”. Aslo, if you need to do any data conversion because you store the field differently than you display it, then this would be the place for that as well.
formatScript (Text)
This one I am not using yet, but the thought here is that, for viewing purposes (not editing) you might want to provide some code to format the data to make it look pretty for some reason. Again, I have not done anything with this as yet, but that’s the theory on its purpose anyway.

When all is said and done, you should be able to use the look-up table subsystem to list out the contents of the Data Type table and then add any new data types at will and have them start showing up as options for additional properties in any table definition. The Data Type table itself actually used three different types of properties (Decimal, Boolean, and Text), so the Data Type table definition is an example of how data types are used in the system.

Right now, I just have a handful of data types defined, but my thought is that I will just define more as I need them. If all works as it should, that should be a simple as defining a new entry in the table. If I’ve done the job right, there should be no coding or development work involved.


Comments are closed.

Sorry, the comment form is closed at this time.