Database collections

What if I have a restaurant that has many flavors of items and each flavor has 3 sizes or more and each size has a specific price in the sense that I have a group of items for each item a group of sizes and a group of flavors where the price differs in terms of size and in terms of flavor, for example I have a chicken pizza that has a price of 5 dollars for the small size The medium is $8 and the large is $10, while the margherita pizza has the small size $6, the medium size $7 and the large $11 and so on, can I solve this problem?

Hi @Motazabuzaid.

As an option, you can create one collection for Items, and another for Sizes. Then you set up a relationship so that one Item can have only one Size, but one Size can apply for many Items.
And finally, you add the items themselves, e.g.:
margherita - size S - price $5,
margherita - size M - price $10,
etc etc.

With this your user will be able to select size in the dropdown / choose it from the list, and you can filter the items based on name & size.

Another, more complex approach would be to have 3 collections:

  • Item Groups, where you will store the “common name” for the group.
  • Sizes
  • Items, where you will store the exact item of an exact size with its price. Items will have 1:m relationship with Sizes (one item can have only one size) and 1:m relationship with Item Groups (one Item can belong only to one group).

With this you will have something like:

  • Item groups:
    → Margherita
    → Calzone
    → …
  • Sizes (S, M, L, XL, …)

And then you create each entry in Items like this:
→ Margherita for two (this is a text name) - relation to Item Groups (select Margherita) - relation to Sizes (select size needed, e.g. S) - price $5 (number).
→ Margherita for four (this is a text name) - relation to Item Groups (select Margherita) - relation to Sizes (select size needed, e.g. M) - price $10 (number).

With this approach you will allow user to select a pizza type first (Margherita, Calzone, etc.), and then select the desired size. Also there is still a possibility to sort/filter pizzas by size.

Hope this helps.


My friend i appreciate your support , But in my case i have created 3 collections one for the item and one for the flavor and another one for the sizes , So i want the user to press on for example the pizza item and then he will choose the size and the flavor

Hi @Motazabuzaid,

I am not sure what do you mean by “flavours” and “items” in your setup. Why would you like to distinguish between them? In your pizza example there is no difference.

In my second example I’ve explained the approach with “Item Groups”. So you can have a list of “Item Groups” on some screen, where you will see pizzas: Margarita, Calzone, Chicken, etc.
Then user selects a pizza and gets to the next screen, where he/she can select a size: s/m/l. Depending on a size the price will be different.

Could you please try to explain what exactly would you like to achieve and what issues are you facing. Especially it would be great if you explain in more details the relationships between “flavours”, “items” and “sizes”.


Dear ,
In items i mean the user will select for example pizza , the the app will take him/her to a page which contains tge flavours for example margarita , chicken , pepperoni in this page he will select the flavor and the size so the price depends on the flavor nd the size

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.