Skip to content
Advertisement

Relationship model of an inventory control

I’m trying to create a mer diagram, for an inventory control with the following logic, I have 10 components of the same model (10 ACER 24 monitors, with the same characteristics.), The only thing that differentiates each of these components would be the serial number, so I had the following logic:

enter image description here

But I don’t know if these relationships are correct, especially with the inventory part, would it be correct for me to add the serial number in the component entity, and create 10 inventory records?

enter image description here

I’m having a hard time choosing the best path for this logic that I described above.

Advertisement

Answer

In relational notation every relation must have a primary key, while in your example:

stock, component_has_component_category, user_has_components do not.

To solve it, add both fields in a primary key for each relation.

components relation on the other hand has a useless field id, which could be replaced with primary key component_id + serial_number, and so if a user has a component (refers by foreign key) relation user_has_components will have both fields component_id + serial_number which is logical, since the user has a specific component instance.

A hypothetical relation components_inventory would be similar, it has two fields component_id and serial_number which are both primary key and foreign key to components, denoting that a specific component with a serial number is present. (in some sense components_inventory is subset of components)

EDIT: My view of how it would look like data-wise:

component

| component_id | .. other stuff |
|            1 | ..             |
|            2 | ..             |


components (all existent components and serial numbers)

| component_id | serial_number |
|            1 |           101 |
|            1 |           102 |
|            1 |           103 |
|            1 |           104 |
|            2 |           201 |
|            2 |           202 |


user_has_component (refers to components)

| user_id | component_id | serial_number |
| mary    |            1 |           101 |
| john    |            1 |           104 |
| john    |            2 |           202 |

category_inventory (refers to components, some components we have, but not
users)

| component_id | serial_number | location           |
|            1 |           102 | warehouse New York |
|            1 |           103 | warehouse New York |
|            2 |           201 | warehouse Paris    |

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement