Vehicle spare parts inventory datadase model

database-designschema

I am modeling a database to be used for vehicle spare parts inventory management and I am stuck…

Some spare parts can be broken down from a kit into component parts. I would like to create a model that supports this, but do not know how to build it.

Spare parts can be issued in sets or pieces. The database should keep information about how many complete sets we have and how many have been broken into pieces. For instance, one piston ring set will have 6 different individual piston rings.

Can you point me in the right direction?

Best Answer

Great, the part/whole modelling problems.

Here is how LedgerSMB does it. We are likely to change this at some point but this part works well enough.

Basically we have two tables, called parts and assembly. The exact names/layout will change over time but this basic concept will probably stay the same.

In the parts table, we have parts (goods in inventory), services, and assemblies (as you put it, sets). In the assembly table we store the assembly to connect with, the part or assembly that is a part of it, and the number required. This allows sets to be parts of other sets recursively. This effectively creates a components tree in assembly and a sales component tree in parts.

It works well enough, especially when done on a database which supports WITH RECURSIVE common table expressions (i.e. not MySQL...)

Of course then you have a table or two to manage inventory movements and this would handle the sets and their deconstruction according to your business rules.