I have finally stumbled across a problem that I can't already find the answer to on SO...
I am working on a database that will store recorded sampled data recorded over time. Originally, the client had built a table that was very specific to the data that they were currently recording, however, they would are concerned that as they expand, the collected data may begin to vary, and more, or at least different, columns may be required.
Current model:
+------------------+ +------------------+
| FACILITIES | | DATA_RECORD |
+------------------+ +------------------+
| ID | | ID |
| NAME | | FACILITY_ID |
| DESC | | TIMESTAMP |
| etc. | | TEMP_WATER |
+------------------+ | TEMP_AIR |
| pH_WATER |
| etc... |
+------------------+
I think the database should be designed as follows:
+------------------+ +------------------+ +------------------+
| FACILITIES | | DATA_RECORD | | COLUMNS |
+------------------+ +------------------+ +------------------+
| ID | | ID | | ID |
| NAME | | FACILITY_ID | | NAME |
| DESC | | details etc.. | | DESC |
| etc. | +------------------+ | UNITS, etc... |
+------------------+ +------------------+
+------------------+
| DATA_POINT |
+------------------+
| ID |
| DATA_RECORD_ID |
| COLUMN_ID |
| VALUE |
+------------------+
My questions are:
- Is this the best way to design the database, or is there a better way that I am not familiar with.
- How do I form the query statement to return each data record with each of its associated columns?
- Is there a generally accepted good data-type to use as DATA_POINT.VALUE? e.g. float, decimal...?
Thank you so much for your help.
Sincerely,
Nate K.