Search code examples
mysqldatabase-designarchitectureinventory

Inventory Architecture in Database


This is not a question related to a specific language, rather on the correct methodology of architectural of handling inventory.

Consider the following structure for storing software:

platforms (platformID*, platformName)
titles (titleID*, titleName)

And the following is a joiner table for unique products

products (platformID*, titleID*, releaseDate, notes)

And the following is a table I would like to keep track of my inventory

inventory (platformID*, titleID*, quantityAvailable)

In examples I have seen, others have created a table where each unique copy of a software is stored in a separate line as such:

software(softwareID*, softwareTitle)
inventory(inventoryID*, softwareID*)

I would like to know which approach is preferable? Should I create an inventoryID and thus a row for each unique software copy:

inventory(inventoryID*, platformID*(fk), titleID*(fk))

Or use a table that stores quantity instead, as such:

inventory(platformID*(fk), titleID*(fk), quantityAvailable)

Solution

  • I also would start with quantityAvailable instead of lines for all the items. But I would still opt for an inventoryId, since cases could occur, where you have to dissect the entries with the same platform/title combination -- with an inventoryId you are more enhanceable in the future.

    I would also recommend to add a further column: versionNo --- the version number of a software product. Sometimes you might have differing versions of the same product. When you have this, it is not a good idea to drop the information into the title (for example you want to search for all "Microsoft Office" products regardless of version ...).