我是数据库设计的初学者,研究如何实现时间序列数据。 基本上,我想设计一个数据库,存储电池指标,即电流,电压和用户的时间。 我越想越想,就越是开始迷惑自己。请帮助我指出正确的方向。到目前为止,我想出了下面的伪代码:时间序列数据库设计
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)
现在,我的问题是:应该是什么BatteryLog表的主键? batterylog可以在指定的时间内包含数百万个时间序列行。 我现在在使用SqlServer关系数据库。有没有针对它的优化设计?
谢谢你在我的研究中的帮助!
我喜欢复合主键的方法,因为它支持以下查询:在特定的BatteryID范围内选择特定时间段的行。谢谢。 – user2952473