【问题标题】:One table or many tables with relationships [closed]一张或多张有关系的表[关闭]
【发布时间】:2013-09-28 04:57:10
【问题描述】:

我有 170 个属性的实体。这是来自车辆监控的数据。每个实体都有数据时间标签和 GPS 终端的唯一 ID。终端的日期时间和 id - 这些是 GROUP BY 操作的条件。我可以为所有实体创建一个表:

CREATE TABLE rows {
   terminal_id long reference terminals(id),
   time timestamp,
   -- description 170 attributes
   PRIMARY KEY(terminal_id, time)
}

或者我可以创建许多具有关系的表:

CREATE TABLE rows {
   row_id long PRIMARY KEY,
   terminal_id long  reference terminals(id),
   time timestamp -- need create index for group by
}

CREATE TABLE gps {
   row_id long references rows(row_id),
   -- description gps attributes
}

CREATE TABLE fuel {
   row_id long references rows(row_id),
   -- description fuel attributes
}
-- etc.

请建议该类型数据库的最佳结构。

【问题讨论】:

    标签: sql database postgresql database-performance


    【解决方案1】:

    在我看来,将属性移动到不同的表没有任何好处,实际上,由于从数据库中获取数据需要额外的连接,你的性能会更差。您描述的分解仅在对可能彼此独立存在的不同实体进行建模时才需要,而这不是您的情况。

    【讨论】:

      猜你喜欢
      • 2018-01-11
      • 1970-01-01
      • 2013-02-17
      • 1970-01-01
      • 2021-07-11
      • 2020-11-21
      • 1970-01-01
      • 2012-08-27
      • 2020-09-09
      相关资源
      最近更新 更多