Hi all,
I need to develop some tables in SQL server to store formulas. These formulas can be of varying complexity. Some might take the form:
1 + 2 (ordinal1, ordinal2, operator '+')
Others might take a more involved form:
(calculation_from_a_field_in_another_table, random_ordinal, +) / (34 *2)
And so on and so forth.
The key point is that formulas can contain 1...n expressions and also a given term may be an ordinal that the user inputs, or it could be a reference to a pre-existing calculated value.
I thought of:
term_id,
term_1 (NULL),
term_2 (NULL)
term_id_1 (NULL),
term_id_2 (NULL),
operator
But you could end up with something hideously recursive.
I would appreciate hearing from anyone who has modelled this sort of thing in their database and how best to do it from the point of view of retrieving the information quickly and efficiently.
Thanks.