如何建模 M-M 与不同变化的关系
How to model M-M relationship with differnce variation
如果用户要求 mock-up 是这样的:
1-Company (id -name -etc)
并且每个公司都有 (Iron,Cement
) 输入具体 (month-year
) 。
Iron
有 local sales
,Cement
有 Exporting
。
每个 Company
有 (Start balance
) for (Iron,Cement
) 只输入一次。
如何建模这样的东西?
假设我了解您的域,可以这样做:
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
如果您以这种方式创建 tables,您可以使用一个 table 来存储水泥和铁的数据。然后,您可以编写自定义 VIEW
以仅显示每个 material.
的相关列
如果用户要求 mock-up 是这样的:
Company (id -name -etc)
并且每个公司都有 (Iron,Cement
) 输入具体 (month-year
) 。
Iron
有 local sales
,Cement
有 Exporting
。
每个 Company
有 (Start balance
) for (Iron,Cement
) 只输入一次。
如何建模这样的东西?
假设我了解您的域,可以这样做:
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
如果您以这种方式创建 tables,您可以使用一个 table 来存储水泥和铁的数据。然后,您可以编写自定义 VIEW
以仅显示每个 material.