Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vikrantsingh47's avatar

shopping cart database design for "products" table

should the "products" table for an ecommerce website have two columns: "availability" and "quantity", so that when user clicks on checkout, availability will reduce, and when the order is completed, quantity will reduce? or should it just be "quantity" ?

I am a bit confused about the overall process of adding products to cart/ checkout/ complete order , and how it relates to product quantity/availability.

0 likes
2 replies
siangboon's avatar

i'm confused too... i always thought available is a boolean flag that based on quantity... perhaps someone can explain better why and when need to have both availability and quantity...

artcore's avatar

For me 'availability' is the date it becomes available, 'quantity' is stock keeping. For instance when stock/quantity = 0, restock but that takes time so availability = 3 weeks.

Of course a good shopkeeper will restock in advance ;)

Please or to participate in this conversation.