I am developing a small database application where various measurements can be recorded. I want to allow the measurements to be recorded in the units which suit the user/ measuring instrument: Length in centimetres or inches, mass in kg or pounds, energy in kJ or kcal, temp in C or F etc.
The table holding these preferences also holds a conversion factor; for Unit Of Measure 1 to Unit Of Measure 2.
tblConvert tblConvert
The user data entry form for recording measurements allows the values to be entered, and depending on the preference, displays the Unit1Name or Unit2Name as the caption for the specific entry (Temp [ deg C or deg F ], Blood Pressure [ kPa or mmHg ] etc).
The question is what is the recommended method for dealing with a change in the PrefSetting for any Measure?
Two approaches in consideration:
1. If the preference is changed, then apply the conversion factor as needed to update all values in tables that store the relevant observations/measurements. Generally it would not be expected that setting are changed, however it will happen.
2. Always store the values as Unit1 values, but simply display the entry in the preferred unit. So for Temp, say, on entry if Unit1 is preferred then no conversion. If Unit2 is preferred, then an entry of 100 (deg F) will be stored as (100-32) / 1.8 = 37.7778. This would also mean applying the same conversion on reports when needed, by checking preferences. Extracting raw data should be done with the Unit1 label.
I don't think it reasonable to store mixed values in records for any one measure.
Issues / thoughts / recommendations ?
The table holding these preferences also holds a conversion factor; for Unit Of Measure 1 to Unit Of Measure 2.
tblConvert tblConvert
Measure | Unit1Name | Unit2Name | PrefSetting | ConversionFactorU1U2 |
---|---|---|---|---|
Mass | kg | lb | Yes | 2.20 |
Length | cm | in | Yes | 0.39 |
Energy | kJ | kcal | Yes | 0.24 |
BloodGlucose | mmol/l | mg/dl | Yes | 18.02 |
BloodOxygen | kPa | mmHg | Yes | 7.50 |
BloodPressure | kPa | mmHg | No | 7.50 |
Temp | deg C | deg F | Yes | 1.80 |
The question is what is the recommended method for dealing with a change in the PrefSetting for any Measure?
Two approaches in consideration:
1. If the preference is changed, then apply the conversion factor as needed to update all values in tables that store the relevant observations/measurements. Generally it would not be expected that setting are changed, however it will happen.
2. Always store the values as Unit1 values, but simply display the entry in the preferred unit. So for Temp, say, on entry if Unit1 is preferred then no conversion. If Unit2 is preferred, then an entry of 100 (deg F) will be stored as (100-32) / 1.8 = 37.7778. This would also mean applying the same conversion on reports when needed, by checking preferences. Extracting raw data should be done with the Unit1 label.
I don't think it reasonable to store mixed values in records for any one measure.
Issues / thoughts / recommendations ?