Designing a database model

If you have a vending machine with various products and payment methods, it's recommended you use a database to store all transactions in the vending machine.

Three data points that you should take care about are product, transaction, and machine vending capabilities. In general, we can describe the core database design as follows:

The Product table consists of product information, including quantity and price. If you look at the schema in the figure, there are two fields: product_code and product_vending_code. product_code is the internal manufacturing identity that the system will use for all transactions. You can put Stock Keeping Unit (SKU) data into this field. Each product usually has an SKU ID so we can use it for our product identity. Otherwise, the product_vending_code field is designed for identity numbers on vending machines. These are the number that users see and select to buy on the vending machine. They're usually two- to five-digit numbers depending on how many products are in the vending machine.

The Transaction table is used for storing all transactions that occur in the vending machine. This is useful for logging and tracking. If the vending machine is connected to the internet, we can identify the current stock of each product remotely. Once product stock is low, we can deliver new products to the vending machine.

Lastly, the Vending table keeps information about machine capabilities such as product capacity, payment method, location, and so on. You can put all general information about the vending machine here.

This is a simple database design. You can extend it based on your use case and target while building your vending machine.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.236.219