S
S
semki0962020-08-26 01:39:09
Database design
semki096, 2020-08-26 01:39:09

How to place a product, an attribute, and a different price depending on the attribute in one sqlite table?

There is a small pizzeria project - pizza has 3 attributes (big, normal, small), and each attribute forms its own price for pizza. I thought that it makes no sense to look towards complex solutions like EAV for such a task. I suspect that this can be solved using mongodb (json). But is it possible to do this in sqlite, or rather, the question is whether it is advisable to do this in sqlite or mysql? Or is Mongo better?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2020-08-26
@semki096

It is better to make two tables instead of one. In the first one, store the main data that does not change (for example, the name), and in the second - individual options for this pizza with a price (for each option, a separate entry in this table).

pizzas
id | name

pizzas_variants
id | pizza_id | price

K
Konstantin Tsvetkov, 2020-08-26
@tsklab

pizza has 3 attributes (big, normal, small)
Since the attributes are mutually exclusive, keep the размер, цена1, цена2, цена3.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question