J
J
Jony13372016-12-03 11:33:41
MySQL
Jony1337, 2016-12-03 11:33:41

What structure would you make in mysql for this data?

There is such a block
prntscr.com/des1gx
I don't want to make tables for Garden,Bedroom,garage...
What should I do?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey_Sarychev, 2016-12-03
@Alexey_Sarychev

You do not need to do them - this way will be wrong in any case.
There are 2 ways. They depend on the task (is it possible to have the same characteristic twice with different values):
1. One table with null-label fields. Judging by the picture, there cannot be multiple values ​​of one parameter.
2. 2 tables: one for real estate, the second for parameters. The parameter table will have the following fields: type, value, property link.
The first way is simpler, the second is more scalable.

X
xmoonlight, 2016-12-03
@xmoonlight

1. If there are no detailed descriptions for each of the objects of the garden, bedroom, garage, etc. - it's just a "flat" list in one table: one object - one column/field.
2. If there are possible additional. parameters: it is better to write data to the cells of this "flat" list in JSON (mysql 5.7 or later). Then it will be possible to display nested parameter levels, taking them from the json data array directly from the database.
PS: JSON is constantly helping out since mysql 5.7!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question