Data Modeling  with diferents entities

Good night guys,

I want to create a pizza ordering system.

I am having trouble modeling the data so that it is saved correctly in the database and presented to the user.

I have in mind a "pizza" record with:

1. flavor

2. small size price

3. medium size price.

4. price for large size.

Do I need to create three entities: one with flavor, one with size and one with value?

And how to make the aggregates in the preparation?



Hi Davi Matsuo,

If those are characteristics of a Pizza (for you), then you would add them directly as attributes of a single Pizza entity.

If flavor can be one of several predefined options (e.g. Margherita, Four Cheeses, Calzone, etc...) then you may want to create a Flavor static entity as well (with one record for each option available), and on the Pizza entity add an attribute of type Flavor Identifier.

As for the Size vs. Price... the way you defined it, it's confusing two different relationships. Your ValorId attribute in Pizza shouldn't be there (it's creating an unwanted one-to-many relationship between a price-for-specific-size and a Pizza definition). The Price entity itself already establishes a many-to-many relationship between Pizza and Size, qualified by the actual price of that pizza at that size.

Hope this helps!

Hi Davi Matsuo, 

You can create a static entity for flavor and size and one master entity to store all details related to order and take the reference of these static entities. I think the price should not be kept in a static entity because the price can be change



Thanks guys,

I will try to implement your suggestions. 

Hi @Davi Matsuo 

You can implement something like this

In this way, the entity pizza will store a price of a pizza by flavor and by size.

Hope this helps


Gonçalo Almeida

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.