This one took me a year to realise.
Yes a bit thick!
It is so simple, one wonders why it was not visible before.
I had to design a database table for charges against a service.
The charge depends on various parameters.
The usual way of representing would be to put the parameter values and the results in single unique record
Eg:
Z= f(x,y,z)
Z= 40.9 when x=1 y=2 z= 3
Record
Z x y z
40.9 1 2 3
Blow up the same methodology for cases like 3<=x<=9.5
For this, you would need columns such as
GEx GTx EQx LEx LTx
Populate with values and you can define a condition
Repeat for each variable.
You will end up having a table with fairly large number of columns.
I did not want this.
Also I was wondering about cases where say Y is a string and not a number.
This was posed as a question to ether space via this blog in an post made in Apr09
Z = 80.345 when x=1,z=3 and Y contains string "Singh"
Say it defines a taxi rate to the airport when your name is same as the driver's.
The solution I found is to represent these conditions as multiple records in a different table which a link to the unique rate record held in the 'rate' table.
I am sure this has been done before and used commonly!
Anyway, no one was there to tell me.
Yes a bit thick!
It is so simple, one wonders why it was not visible before.
I had to design a database table for charges against a service.
The charge depends on various parameters.
The usual way of representing would be to put the parameter values and the results in single unique record
Eg:
Z= f(x,y,z)
Z= 40.9 when x=1 y=2 z= 3
Record
Z x y z
40.9 1 2 3
Blow up the same methodology for cases like 3<=x<=9.5
For this, you would need columns such as
GEx GTx EQx LEx LTx
Populate with values and you can define a condition
Repeat for each variable.
You will end up having a table with fairly large number of columns.
I did not want this.
Also I was wondering about cases where say Y is a string and not a number.
This was posed as a question to ether space via this blog in an post made in Apr09
Z = 80.345 when x=1,z=3 and Y contains string "Singh"
Say it defines a taxi rate to the airport when your name is same as the driver's.
The solution I found is to represent these conditions as multiple records in a different table which a link to the unique rate record held in the 'rate' table.
I am sure this has been done before and used commonly!
Anyway, no one was there to tell me.
Comments
Post a Comment