B
B
blantcat2019-10-04 21:15:03
Database design
blantcat, 2019-10-04 21:15:03

Should attribute values ​​be stored as separate columns in EAV?

The task of storing entities with an arbitrary number of attributes arose. At the same time, the number of attribute types is limited: 7. If you use EAV, is it worth making a separate column for each type?

+----+-----------+------------+----------+-----------+--------------+------------+
| id | entity_id | name       | type     | value_int | value_string | value_date |
+----+-----------+------------+----------+-----------+--------------+------------+
| 1  | 1         | size       | int      | 10        | null         | null       |
+----+-----------+------------+----------+-----------+--------------+------------+
| 2  | 1         | title      | string   | null      | product      | null       |
+----+-----------+------------+----------+-----------+--------------+------------+
| 3  | 1         | created_at | datetime | null      | null         | 2019.10.04 |
+----+-----------+------------+----------+-----------+--------------+------------+

What rake can be stepped on with such "optimization" of eav storage?
Basic selections:
1. Get entities with a creation date (or other attribute) in the x and y range
2 Get a list of entity attributes and their values.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question