I need to save measures coming from devices into a SQL database (SQL Server 2008). Each device gives, at a specific time, the same array of measures. An array is composed of 80 measures, that can be grouped.
To resume, at a specific time t(x), I have the following data (t(x) considered as one “session” of measures):
- t(0): DeviceID, DateTime, 80 measures
- t(1): DeviceID, DateTime, 80 measures
- …
A device produces, in a session of measures t(x), 8 sets of same type of 10 measures (a, b, c, d, e, f, g, h, i, j) (a, b ,c … representing the type of measures as int, float, double, etc..) corresponding of 8×10=80 measures in total.
Example:
- set N°1 can be (10, 2, 3.2f, 4.76, “Data1”, 3, 2, 2.2, 5.6f, 10.0f)
- set N°2 can be (2, 4, 31.2f, 4.23, “Data2”, 1, 1, 3.2, 2.2f, 2.1f)
- ….
- set N°8 can be (10, 7, 1.1f, 2.35, “Data8”, 8, 1, 2.1, 2.1f, 8.2f)
Note: the number of sets of measures, 8, will not change.
I would like to know what can be the best design of table(s) to handle these measures (insert, select, delete, no update)?
I thought about these possibilities:
- It can be one table with 82 columns.
- It can be one main table (DeviceID, DateTime) and 8 sub tables representing the 8 set of measures.
- It can be one main table (DeviceID, DateTime) and 1 sub table that can have one set of measure, and a type to indicate which set of measures.
If every “session” consists of (8, either stable or not) number of sets where every “set” consists of (10, not-to-change) number of measurements (of possibly different types), I’d choose one table with fields:
You can also have a
deviceSession, where thedateordatetimefield for every session can be stored:I would also add a foreign key constraint from
deviceDatato this table:And every
INSERTcould be a transaction that inserts one row atdeviceSessionand 8 rows atdeviceData.Sample data: