与计算列相比设计不佳?

Bad design to compare to computed columns?

使用 SQL 服务器 我有一个带有计算列的 table。该列连接 60 列:

CREATE TABLE foo 
(
    Id INT NOT NULL,
    PartNumber NVARCHAR(100),

    field_1 INT NULL,
    field_2 INT NULL,
    -- and so forth
    field_60 INT NULL,

    -- and so forth up to field_60
)

ALTER TABLE foo 
    ADD RecordKey AS CONCAT (field_1, '-', field_2, '-', -- and so on up to 60
                            ) PERSISTED

CREATE INDEX ix_foo_RecordKey ON dbo.foo (RecordKey);

为什么我使用持久化列:

这个 table 将包含不少于 2000 万条记录。 Adds/Inserts/updates 经常发生,有些二进制文件每个 运行 执行数以万计的 inserts/updates/deletes,我们希望它们快速且有效。

目前我们有 C# 代码来管理 table foo 中的记录。它有一个函数,可以按照与计算列相同的顺序连接相同的字段。如果具有相同连接键的记录已经存在,我们可能不会插入,或者我们可能会插入但调用我们通常不会调用的其他函数。

这是一个糟糕的设计吗?我看到的最大危险是代码是否出于任何原因与计算列的串联顺序不匹配(如果编辑了一个而不是另一个)。

Rules/Requirements

更好的table设计是

parts table
-----------
id
partnumber
other_common_attributes_for_all_parts


attributes table
----------------
id
attribute_name
attribute_unit (if needed)


part_attributes table
---------------------
part_id (foreign key to parts)
attribute_id (foreign key to attributes)
attribute value

它看起来很复杂,但由于适当的索引,即使 part_attributes 包含数十亿条记录,这也是非常快的!