F
F
Flaker2015-09-13 18:35:19
PHP
Flaker, 2015-09-13 18:35:19

How to organize the database structure for dynamic characteristics?

Comrades, please tell me the best way to organize the MySQL database structure for a dynamic system of characteristics and search by them.
More specifically: There are houses. Houses have characteristics. The values ​​of these characteristics can be a number, a string, or a boolean. It is necessary to organize the base so that the characteristics can be added. At the same time, each house has its own values ​​for the same characteristic. In this case, it will be necessary to organize filtering according to these characteristics.
My option:
9f26809c583f4aa3b5d650153c5f5094.png
When using MySQL, as it is now shown in my picture, all filtering will have to be done through CAST or CONVERT.
So I'm thinking about the best way to organize this.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
S
Stanislav Makarov, 2015-09-13
@Flaker

How to add a product to the cart?
- EAV (link provided by @muhammad_97);
- JSON/XML in a relational database;
- JSON in document base (CouchDB/MongoDB) (preferred option);

M
Muhammad, 2015-09-13
@muhammad_97

EAV: https://en.m.wikipedia.org/wiki/Entity-attribute-v...

D
DVamp1r3, 2015-09-13
@DVamp1r3

It may also help to serialize objects to a string

H
heartdevil, 2015-09-13
@heartdevil

In the characteristics table, make specifically three fields, instead of type
Id (int)
name (varchar)
string_option (varchar)
number_option (int/float/decimal)
bool_option (boolean)
prefix (varchar)
suffix(varchar)
And store selectively values ​​for each field

D
DastiX, 2015-09-14
@DastiX

What is the best way to store user settings in a database?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question