1

I have a question regarding the correct implementation of a Schema that I'm currently wrecking my head with:

We have machines, which consist of components, which consist of parts.

However, the relationships are as follows:

  • Machines (1) --> Components (N) - a machine is made up of various components
  • Components (N) --> Parts (N) - a component is made up of multiple parts, a part may be used in multiple components
  • Components (N) --> Components (N) - a component can also be made up of other components
  • Machines (N) --> Parts (N) - Some parts may also be directly assigned to a machine

Furthermore, both parts and components that are flagged as needs_welding=1 will have a price associated with them. These prices will change over time.

I'm not quite sure as to how to model the following aspects:

  1. How to relate the Parts directly to the machine table
  2. How to model the parent/child relationship between the components
  3. How to attach prices to the items (kinda reminds me of an SCD in a DWH, but I cannot seem to patch it together)
4

1 回答 1

1

N->N 映射的一个很好的解决方案是创建一个特定的映射表。因此,例如,要将组件映射到组成它的部件,您可以创建一个名为 MapComponentToItsParts 的表,它有两列,第一列包含组件的 ID,第二列包含零件的 ID。它们都应该是各自表的外键。您可以创建与 MapComponentToSubComponent 或 MapMachineToPart 类似的表。

于 2014-05-20T16:57:11.070 回答