3 ms·
Then you're supposed to use another table with a foreign key to canonical measurement record. This is the concept of fully normalized schemas. What you're des
by recursive 2y ago
Then you're supposed to use another table with a foreign key to canonical measurement record. This is the concept of fully normalized schemas.
What you're describing is closer to how people do it in practice.
- chongli 2y agoI'm still a bit confused. Suppose you have another table, call it temperatures with columns id and temperature, where every row contains only a valid temperature (no NULL records), and you have a main logging table with date and temperature_id so that you can join on temperature_id = temperatures.id. This seems to be what you mean, with a canonical measurement record table related via the temperature_id foreign key. But then if your sensor fails to record a measurement don't you end up with NULL for that row's temperature_id?
- recursive 2y agoForeign key would probably go the other way: LogEntry(LogEntryId, Date) Temperature(TemperatureId, LogEntryId, DegreesF) If there is no temperature measured, then you don't create a record in Temperature.
- wvenable 2y agoAh but then how do you record that the measurement actually happened but did not produce a value? I want a record of that failure. I mean sure, you could do yet another table. But honestly that level of normalization is much more work than it's worth. Just because it's some academic definition doesn't make it right.
- recursive 2y agoYou put a record in the Measurement table, and none in the Value table. > But honestly that level of normalization is much more work than it's worth Yes. I question whether it's worth anything to begin with.