I’m designing the database for a food delivery app. There are special kind of products:
Product examples:
- Kebab (price is fixed)
- Pizza Margherita – (price is dynamic)
- Pizza Half-Half – (price is dynamic – there are two products combined into one)
Selections within product:
- Each product can have selections like sizes and sauces.
- Size selection changes the product price.
- Sauces selection depends on size selection. For small size you have 1 sauce, for medium 2 sauces and so on. You can chose extra sauces paying extra.
What are your thoughts about this? Perhaps there is something open-source addressing this. I need to keep the Laravel style for functionalities like validations, model creations and so on.
2
Answers
Well, after some sketching I came up with this idea. In the first post I didn't mention the need of the scalability(in the future, more products will be available in the shop)
So..
Products and selections - concepts
The #Selection2 could be listed more times
Selections details
What's your thoughts about this and how will the database structure look like?
So what you need is the database structure. What I do in this cases is write my ideas in a piece of paper, until they get better and better. It helps.
Something quick I can recommend, you can obviously change it a bit.
If someone orders a Pizza Margherita, you just calculate it’s price directly based on it’s size from the prices table.
If someone lets say orders Half Pizza Margherita and half Pepperoni with 3 extra sauces you can do this:
(Margherita price / 2) + (Pepperoni price / 2) + (extra sauce price + extra sauce price + extra sauce price) = total price.