Our team is developing an application that takes statistics of the population we regulate, and applies a set of parameters to those statistics via an algorithm to produce measurements for each member of the population. The user will be able to set the values of each parameter, run the algorithm, see the results, and redo it with different values, etc.
The parameters are fixed (say 12 parameters), but are of different numeric types and/or precision.
For example, some parameters are very large integers, some are small integers, some are monetary, some are high precision decimals.
The first cut of the data model has the parameters defined explictly in a couple of tables each with the data type and precision that suits that parameter, eg (simplified):
STABLE_PARAMETERS
id number(4)
very_large_parameter_1 number(18)
very_large_parameter_2 number(15)
range_parameter_min number(3)
range_parameter_max number(9)
VOLATILE_PARAMETERS
id number(4)
monetary_min number(5,2)
monetary_max number(11,2)
conversion_rate number(7,6)
count_rate number(5,4)
The algorithm is being defined in code in the application, tested and is expected to be stable for at least a couple of years. If the algorithm changes, it will be a code change, retest and release. If a new parameter is added as part of this, it would need to be added to the relevant table and the code changed to accommodate it.
I had initially thought that a more generic approach to the parameters would be better, with the parameters defined as rows in a generic table instead of explicitly defined as individual columns, eg:
PARAMETERS
id number(4)
parameter_name varchar2(100)
parameter_type varchar2(20) -- eg INTEGER, MONEY, FLOAT?
parameter_value ???
where parameter_value could be:
(1) string representation of the number
parameter_value varchar2(20) -- "0.000032" or "1000000000" or "1500.00"
or
(2) all-encompassing number definition
parameter_value number(24,6) -- 0.000032 or 1000000000.000000 or 1500.000000
or
(3) 3 columns, 1 for each parameter_type, each parameter row has only 1 of these columns populated, the other 2 are null.
parameter_value_int number(18) -- 1000000000
parameter_value_money number(11,2) -- 1500.00
parameter_value_float number(7,6) -- 0.000032
None of these seem to be the right way to go. (1) is storing numbers as strings which is risky and needs interpretation of the value based on the parameter_type. (2) is overkill for many of the numbers. (3) is a bit better but needs interpretation based on the parameter_type.
In future who knows, maybe date parameters or character parameters will be added too?
Given this scenario, what would be the best way to model this?