如何使这个简单的关系模型适应维度?

时间:2015-01-29 08:32:30

标签: database database-design dimensional-modeling

我有这个相当基本的关系模型来存储自行车模型。它包含2个表:

    (modelID, modelName, brandName)
    (modelID,  type, color, wheelSize, suspension, frameMaterial, brakeManufacturer, gearType, gearModel, yearProduced)

我被要求将其改编为维度模型。

这些是维度表:

    tbl_d_model(modelID, modelName)
    tbl_d_brand(brandID, brandName)
    tbl_d_color(colorID, color)
    tbl_d_type(typeID, type)
    tbl_d_wheel(wheelID, wheelSize)
    tbl_d_suspension(suspID, suspension)
    tbl_d_frameMat(frameID, frameMaterial)
    tbl_d_brakeMan(brakeId, brakeManufacturer)
    tbl_d_gear(gearID, gearType, gearModel)

这就是事实表:

    tbl_f_fact(modelID, brandID, colorID, typeID, wheelID, suspID, frameID, brakeID, gearID, yearProduced)

这是最佳方式吗?还有更好的方法吗?

1 个答案:

答案 0 :(得分:1)

在尺寸建模上使用按键。

您需要的是单个维度,而不是10个维度和事实表。

因此

dimension_bycicle(key_bicicle, modelName, brandName, type, color, wheelSize, suspension, frameMaterial, brakeManufacturer, gearType, gearModel, yearProduced, modelId)

请注意,modelId是您的自然键(操作系统密钥,不应用作数据仓库密钥)。