【问题标题】:How to model M-M relationship with differnce variation如何对具有差异变化的 M-M 关系进行建模
【发布时间】:2016-12-13 12:12:08
【问题描述】:

如果用户要求模拟成这样的东西:

1-Company (id -name -etc)

每个公司都有 (Iron,Cement) 输入特定 (month-year)。

Ironlocal salesCementExporting

每个Company (Start balance) 对于 (Iron,Cement) 只输入一次。

如何建模这样的东西?

【问题讨论】:

  • ExportingLocalSales在sql中是同一种数据类型吗?只是命名问题吗?
  • 不,它们是两个不同的含义,实际上Cement 也有local salesIron 没有exporting 字段
  • 是的,我明白了,但它们本质上都是整数吗?
  • @JanezKuhar : 都是十进制
  • Balance startLocal SalesExportingProduction 有任何关系吗?

标签: sql-server database database-design relational-database informix


【解决方案1】:

假设我了解您的域,则可以执行以下操作:

Company(id, name, ...) // PK = id
Material(id, name) // PK = id 
Entry(idCompany, idMaterial, month-year, production, localSales, exporting) // PK = idCompany, idMaterial, month-year
Initial(idCompany, idMaterial, date, balanceStart) PK = idCompany, idMaterial, date

如果您以这种方式创建表,则可以使用一个表来存储水泥和铁的数据。然后,您可以编写自定义 VIEW 以仅显示每种材料的相关列。

【讨论】:

    猜你喜欢
    • 2016-09-06
    • 2021-06-03
    • 2017-09-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-26
    相关资源
    最近更新 更多