database - 船舶管理数据库结构讨论(应该非规范化?)

标签 database database-design normalization denormalization

我的软件几天前投入生产,现在我想讨论一下数据库结构。

软件收集船舶的数据,目前每艘船舶174个明细,每个明细可以是一个文本值,一个长文本值,一个数字(指定长度,有或没有指定小数位数),一个日期、带时间的日期、 bool 字段、包含许多值的菜单、数据列表等等。

我用下表解决了这个问题

Ship:
- ID - smallint, Autoincrement identity
- IMO - int, A number that does not change for the life of the ship

ShipDetailType: 
- ID - smallint, Autoincrement identity
- Description - nvarchar(200), The description of the value the field contains
- Position - smallint, The position of the field in the data input form
- ShipDetailGroup_ID - smallint, A key to the group the field belongs to in the data input form
- Type - varchar(4), The type of the field as mentioned above

ShipDetailGroup
- ID - smallint, Autoincrement identity
(snip...)

ShipMenuPresetValue
- ID - smallint, Autoincrement identity
- ShipDetailType_ID - smallint, A key to the detail the values belongs to
- Value - nvarchar(100), The values preset in the menu type detail

ShipTextDetail
- ID - smallint, Autoincrement identity
- Ship_ID - smallint, A Key to the ship the detail belongs to
- ShipDetailType_ID - smallint, a Key to the detail type of the value
- Text - nvarchar(500), the field containing the detail's value
- ModifiedDate - smalldatetime
- User_ID - smallint, A key to the user table

ShipTextDetailHistory
(snip...) 
This table is the same as the ShipTextDetail and contains every change to the details.

Other tables for the list detail type, each with the specified fields required for the list, ...

我刚刚读了这篇文章:http://thedailywtf.com/Articles/The_Inner-Platform_Effect.aspxhttp://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:10678084117056

文章说这不是处理问题的正确方法。

我的客户在更改详细信息描述和添加更多详细信息时有一个用于详细信息和组的管理图形用户界面。

数据输入表单是通过读取DetailGroups和DetailTypes的结构动态构建的,每个细节类型生成一个指定的输入控件。

评论表明解决这个问题的另一种方法是动态创建和删除表中的列。

你怎么看?

图表截图:http://img24.imageshack.us/my.php?image=66604496uk3.png

最佳答案

我会 refactor你的代码如果:

  • 您的客户投诉
  • 你发现了一些不起作用的东西
  • 您找到了一种代码无法处理的方法 你知道会发生的改变 将来。

您记得编写允许您重构的单元测试,对吧?

*就您那里的结构而言,我以前见过类似的结构。这有点麻烦,但在很多地方都是标准的。要记住的一件事是,虽然可以动态地从数据库中添加和删除列,但数据库的内部存储机制并不一定要求您连续添加和删除这些列。但我认为与以上几点相比,这不是很相关,可以归结为:*它有效吗?

关于database - 船舶管理数据库结构讨论(应该非规范化?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/539525/

相关文章:

c++ - 将图形存储到内存中的最佳方式

Oracle 首选列长度

elasticsearch - 存储整数而不是全文会更好吗?

multidimensional-array - TensorFlow:在多个维度上采用 L2 范数

java - 在数据库中存储和搜索集(具有许多可能的值)(来自 Java)

sql - "Create table if not exists"- 如何检查架构?

sql-server - 使用 DateTime 作为主键的 Sql Server

mysql - 使用MySQL,如何根据半相关记录计算 View 字段?

machine-learning - 预测 RF 后的数据归一化

sql - MySQL 查询(混合插入和选择)