如何模拟具有不同变异的M-M关系

时间:2022-10-03 23:06:59

If the user requirement mock-up to something like that :

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

如何模拟具有不同变异的M-M关系 1-Company (id -name -etc)

1公司(id -name -etc)

and each Company has (Iron,Cement) entered in specific (month-year) .

每个公司都有(铁,水泥)具体(月 - 年)进入。

The Iron has local sales and the Cement has Exporting.

铁有当地销售,水泥有出口。

Each Company has (Start balance) for (Iron,Cement) entered only once .

每个公司只有(铁,水泥)的(期初余额)输入一次。

How to model something like that ?

如何建模这样的东西?

1 个解决方案

#1


2  

Assuming I understood your domain one could do something like this:

假设我了解你的域名,我可以这样做:

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

If you create your tables this way you can use one table to store data for both cement and iron. You can then write a custom VIEW to display only relevant columns for each material.

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

#1


2  

Assuming I understood your domain one could do something like this:

假设我了解你的域名,我可以这样做:

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

If you create your tables this way you can use one table to store data for both cement and iron. You can then write a custom VIEW to display only relevant columns for each material.

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