Reputation: 3
The database is supposed to contain the information about different virtual machines instances. Each VM has a unique ID, a user, and a "is running" tag. Also, for each ID, there is a list of datapoints for the CPU utilization over the last hour.
I was thinking of creating two tables:
Instances(ID, user, isRunning)
Datapoints(ID, value, timestamp)
The table 2 would look like that:
+-----+-------+-----------+
| ID | Value | Timestamp |
+-----+-------+-----------+
| ID1 | . | . |
| ID1 | . | . |
| ID1 | . | . |
| ID2 | . | . |
| ID2 | . | . |
| ID2 | . | . |
+-----+-------+-----------+
The unique IDs would have to be repeated in the table for the number of datapoints associated with it. I was wondering if that design would work?
Upvotes: 0
Views: 86
Reputation: 1022
The design will work with following datapoints
table modifications:
Another options:
item_num
so primary key will be (ID, item_num)datapoint_id
column as primary key and make (ID, timestamp) uniqueUpvotes: 1
Reputation: 2761
in your datapoints table you may need 4 columns. the ID will be a foreignKey, linked to you instances table.
Therefore you need to add a datapointID to have a unique identifier for the datapoint
Rgds
Upvotes: 0