A
A
alx2das2016-02-29 14:27:54
MySQL
alx2das, 2016-02-29 14:27:54

How to implement a set of heterogeneous properties for an element?

Let's say there is a table in the database with elements. Each element has properties, they can be of different types (string, number, boolean, plural or list). How can I implement the binding of properties to an element so that it would be convenient to pull them out of the database? Preferably under PHP, ideally under Yii2.
If there are any ready-made solutions, please point a finger or point me on the right path.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
nozzy, 2016-02-29
@alx2das

zlob.in/2013/01/struktura-tablic-dlya-kataloga-tov...

D
Dmitry Kovalsky, 2016-02-29
@dmitryKovalskiy

If we talk about the data structure, then everything is solved quite simply.
1) entity table (obviously you have it).
2) a table of properties (indicating the type of properties, whether it has standard values ​​or individual values ​​for each entity.
3) a table of property values ​​(entity id ,property id, value). The third table may have some other data, such as the date of setting, the author of the changes, and so on.

I
igruschkafox, 2016-03-10
@igruschkafox

XML
JSON

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question