Inventory functions in the database