我有一个现有的数据库需要进行一些更改。我需要决定是更改表来记录额外数据,还是使用已记录该数据的现有表进行单独测试,并将其链接到带有新表的另一个表。
现有:
tSubTest(ixSubTest (pk), ixTest (fk))
tPressureVolume( ixPressureVolume (pk), ixSubTest (fk), ...data fields 1...)
tMotorData( ixMotorData (pk), ixSubTest (fk), ...data fields2...)
选项 1:
tSubTest(ixSubTest (pk), ixTest (fk))
tPressureVolume( ixPressureVolume (pk), ixSubTest (fk), ...data fields 1...)
tMotorData( ixMotorData (pk), ixSubTest (fk), ...data fields2..., ...data fields 1...)
选项 2:
tSubTest(ixSubTest (pk), ixTest (fk))
tPressureVolume( ixPressureVolume (pk), ixSubTest (fk), ...data fields 1...)
tMotorData( ixMotorData (pk), ixSubTest (fk), ...data fields2...)
tMDPVLink( ixMDPVLink (pk), ixMotorData (fk), ixPressureVolume (fk))
基本上,它的工作方式是在测试序列开始时进行一次检查压力体积的测试。现在他们想每五分钟记录一次以及其他电气数据。他们仍将进行初始压力容量测试。
I have a existing database that needs some changes done. I need to decide whether to alter a table to record the extra data or use the existing table that already records that data for a separate test and link it to the other table with new table.
Existing:
tSubTest(ixSubTest (pk), ixTest (fk))
tPressureVolume( ixPressureVolume (pk), ixSubTest (fk), ...data fields 1...)
tMotorData( ixMotorData (pk), ixSubTest (fk), ...data fields2...)
Option 1:
tSubTest(ixSubTest (pk), ixTest (fk))
tPressureVolume( ixPressureVolume (pk), ixSubTest (fk), ...data fields 1...)
tMotorData( ixMotorData (pk), ixSubTest (fk), ...data fields2..., ...data fields 1...)
Option 2:
tSubTest(ixSubTest (pk), ixTest (fk))
tPressureVolume( ixPressureVolume (pk), ixSubTest (fk), ...data fields 1...)
tMotorData( ixMotorData (pk), ixSubTest (fk), ...data fields2...)
tMDPVLink( ixMDPVLink (pk), ixMotorData (fk), ixPressureVolume (fk))
Basically the way it was working was there was a test to check pressure volume once at the start of the test sequence. Now they want to record it every five minutes with the other electrical data. They will still be performing the initial pressure volume test.
发布评论
评论(2)
我不会仅仅因为它是在项目后期添加的这一事实而将某些内容放入带有参考的单独表中。
尝试将那些属于一起的信息放在一起 -->我宁愿用一两列额外的列来更新现有表,也不愿创建一个人工的、新的“链接”表。
此规则的唯一例外可能是,如果您有大量形成逻辑实体的列(例如:10 或更多),并且仅在不到 10% 的情况下才会出现在您的业务案例中。
例如,如果您有特定类型的客户,需要大量额外字段,但实际上只有少数客户(例如您的“黄金”客户),那么最好将这些数据“集群”放入单独的表中并将其链接起来 - 否则对于绝大多数数据库实体来说,一大堆字段都将为空(NULL)。
希望能有点帮助——只是我自己的 2 美分;-)
I wouldn't put something into a separate table with a reference just based on the fact it's being added late in the project.
Try to keep those bits of information together that belong together --> I would rather update existing tables with an extra column or two, than create an artificial, new "linked" table.
The only exception to this rule might be if you have a substantial number of columns (say: 10 or more) that form a logical entity and that are only ever going to be present in your business case in less than 10% of the cases.
E.g. if you have a specific type of customer which needs lots of extra fields, but that's really only a handful of customer (like your "Gold" customers), then it might be better to put those "clusters" of data into a separate table and link it up - since otherwise a whole bunch of fields will all be empty (NULL) for the vast majority of your database entities.
Hope that helps a bit - just my own 2 cents ;-)
如果所有数据(电机+泵)同时采样,则将所有数据放入一张表中,如下所示:
如果压力/体积的采样与电机数据无关,请使用:
If all data (motor + pump) is sampled at the same time, put everything in one table, like this:
If pressure/volume is sampled independently from motor data, use this: