I am a beginner in database design, researching ways in which to implement a time-series data. Basically, I want to design a database that store battery metrics i.e. current, voltage and the time for users. The more I think about it, the more I start to confuse myself. Please help me to point in the rieght direction. So far, I come up with the following psuedo-code:
Table: User
Column 1: UserID( Primary Key )
Column 2: UserName
Table: Battery
Column 1: BatteryID ( Primary Key )
Column 2: ManufactureSerial
Column 3: ManufactureDate
Column 4: UserID (Foreign Key )
Table: BatteryLog
Column 1: Voltage
Column 2: Current
Column 3: SOC
Column 4: DateTime
Column 5: BatteryID (Foreign Key)
Now, my question is: what should be the primary key for BatteryLog table? A batterylog can contain millions of Time-Series rows at a specified time internal. I am using SqlServer relational database now. Is there a optimization design for it?
Thank you for your help in my research!
You can create an autoincremental primary key for BatteryLog table:
[BatteryLogID] [int] IDENTITY(1,1) NOT NULL
This will serve the purpose of unique identifier for each record.
Alternatively, you can create a composite primary key on BatteryID and [DateTime] if they are also unique for each record (which is usually the case for time series)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With