I'm building a database for monitoring devices and I've reached an impasse.
I have 40 different types of devices, each of which records different information and have some common (e.g. device name, sample date) but mostly differing attributes (e.g. signal_50_100Hz, device_arm_attached).
As I see it, there are two options:
Build a large table that includes and exhausts all attributes from all devices.
- Cons: Not all devices will have values for all attributes, and not all attributes will be relevant for all devices. Much of the table may end up empty and I may have to build a table to record attribute names for each device in order to generate sensible output.
- Pros: Having one table greatly simplifies things, and makes it easier to aggregate and roll up values later, less SQL to write, more generalized, and easier to understand.
Create a separate table for each device type, listing each attribute separately in each table.
- Cons: Need to write custom SQL every time I get a new device, rehash the entire system, no common interface. Large number of tables to build and manage independently.
- Pros: Everything is laid out succinctly and can be decoupled to stand alone if need be. There is no extra baggage and one device type is not coupled to other device types via the generalized set of attributes.
The intent of this database is to continually aggregate information from these monitoring devices into a single view which then gets queried depending on the needs of the analyst.
I like the idea of creating a different table for each device, and then using a common view to aggregate the relevant data from those tables into a more usable and common form. This would allow me to retain the data (for retention sake), and aggregate it as needed from a common, abstracted layer, one large view.
Do you see any issues with this approach? Which approach makes more sense? What other strategies might I employ? Does anyone have any general advice on how to better approach this issue?