D
D
dmytrotus2019-08-27 00:11:05
Database design
dmytrotus, 2019-08-27 00:11:05

How to make database structure in Laravel 5.8 online store?

Good evening.
Who made the filter for the online store?
If you do not know what goods will be and what properties they will have.
How did you create the database?
I am adding a group of products to the table. They have red and blue colors.
And then, after some time, I would like to add a product through the admin panel without adding columns in the database that already has the material type property but no color.
How to make a database correctly and how to filter on it later?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
O
oleg_ods, 2019-08-27
@oleg_ods

And where do you think you will record the type of material?
Look at similar stores, what categories, characteristics, etc. are there, and then start building your base.

D
Daria Motorina, 2019-08-27
@glaphire

Such questions are laid down at the design stage of the store code - to design the ER diagram correctly, correctly set the validation in the models for creating/updating products, and the frontend for
this is a consequence of whether the right questions were asked at the design stage. There is no need to change the columns here, it is necessary, roughly speaking, to understand all the options for the existence of goods in the context of the store and paint it in the code. MySQL allows it, PHP on frameworks allows it, it remains only to dig into them.

A
asd111, 2019-08-27
@asd111

Take postgres. You add all fields with product properties to a column with jsonb data type, except for price, name, etc. common columns. Those. in your json column you will have something like {"color":"red","material":"fur"} and so on. like in document oriented database but only in postgres.
They did it all not too long ago. Like in 2016.
It seems that json columns were also added to mysql, but I did not look at them.

J
JhaoDa, 2019-08-27
@JhaoDa

Google "EAV".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question