将实体置于层次结构中,还是作为具有查找 table 的属性?

Putting an entity in hierarchy, or as an attribute with lookup table?

假设我的公司生产医疗产品,这些产品用于许多不同的实验室测试仪器。业务逻辑层次结构如下:

A lab has multiple locations (Up to thousands)
A location has multiple departments (Chemistry, Hematology, 3-5 per location)
A department has multiple instruments (No more than 10-20 instruments per location)
An instrument has many products.(No more than 1-5 product types per instrument)

table 结构当前反映了业务逻辑,如左侧所示。我建议我们做一个小改动,显示在右边。

每种方法的优缺点是什么?我觉得左边的方法可能会有点慢,因为连续链接了这么多 Joins

我看到右侧方法的最大问题 "con" 是您失去了 Department 和 Location 之间的关联。对于您在 post 顶部描述的关系,从设计的角度来看,左侧的结构是正确的。

然而...

您的设计意味着圣安东尼奥工厂的质谱仪与丹佛工厂的质谱仪具有不同的 ID。这是故意的吗?

----------------评论中讨论后修改----------------

您描述了几个多对多关系 - 一个位置将有多个仪器,多个位置可以有相同的仪器(例如质谱仪)。为此,您需要交叉引用 table。这是一个初始草图。我的标准是调用table的主键"ID",任何名为“[table-name]_ID”的字段都是对应table的外键:

Lab
    ID
    Name

Location
    ID
    Lab_ID
    Street_Address
    City
    etc.

Department
    ID
    Name

Location_Department    -- this lists the departments at a given location
    ID
    Department_ID
    Location_ID

Instrument        -- Scale, Oscilloscope, Mass Spectrometer, etc.
    ID
    Name
    Description

Location_Department_Instrument    -- inventory at a given location
    Location_Department_ID
    Instrument_ID
    Instrument_Serial_Number

让我知道这是否有意义。