I want to create a small database for my inventory but I have some problems on picking a structure. The inventory will be updated daily at the end of the day.
The problem I am facing is the following.
I have a table for my products, having an
id, name, price, quantity.
Now I have another table for my sales, but there is my problem. What kind of fields do I need to have. At the end of the day I want to store a record like this:
20 product_x $ 5,00 $ 100,- 20 product_y $ 5,00 $ 100,- 20 product_z $ 5,00 $ 100,- 20 product_a $ 5,00 $ 100,- ------------------------------------------------- $ 400,-
So how do I model this in a sales record. Do I just create a concatenated record with the product id's comma separated.
Or is there another way do model this the right way.
Include the cost of each item, the location of the warehouses where it's stored if you have more than one, the specific customer or distribution location for which it's intended and its shipping cost. If you used credit to pay for the order or production, include the weekly or monthly interest the inventory costs you.
The following are the key elements to a well organized inventory tracking system. Create well designed location names and clearly label all locations where items may be stored. Use well organized, consistent, and unique descriptions of your items, starting with nouns. Keep item identifiers (part numbers, sku's, etc..)
Inventory database is a centralized repository for all inventory data in an organization. Database for inventory management software allows balancing inventory costs and risks against the desired inventory performance metrics.
This is a model which supports many aspects,
Hope this would help. Please let me know if you need further information on each table.
Cheers...!!!
Wajira Weerasinghe.
I'd have a table with a row per item per day - store the date, the item ID, the quantity sold, and the price sold at (store this even though it's also in the product table - if that changes, you want the value you actually sold at preserved). You can compute totals per item-day and totals per day in queries.
Tables:
create table product ( id integer primary key, name varchar(100) not null, price decimal(6,2) not null, inventory integer not null ); create table sale ( saledate date not null, product_id integer not null references product, quantity integer not null, price decimal(6,2) not null, primary key (saledate, product_id) );
Reporting on a day:
select s.product_id, p.name, s.quantity, s.price, (s.quantity * s.price) as total from product p, sale s where p.id = s.product_id and s.saledate = date '2010-12-5';
Reporting on all days:
select saledate, sum(quantity * price) as total from sale group by saledate order by saledate;
A nice master report over all days, with a summary line:
select * from ( (select s.saledate, s.product_id, p.name, s.quantity, s.price, (s.quantity * s.price) as total from product p, sale s where p.id = s.product_id) union (select saledate, NULL, 'TOTAL', sum(quantity), NULL, sum(quantity * price) as total from sale group by saledate) ) as summedsales order by saledate, product_id;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With