Hello, I have a real estate ad site. When adding a client, you can specify several rubrics that the client is interested in:
- House rent
- Commercial real estate for rent
- Rent a room
Each type of property has its own set of parameters that the client enters:
- Rent a house (area, number of floors, amenities (tv, wifi) .. and so on
- Rental of commercial real estate (area, type, etc.)
- Room rental (area, number of rooms, amenities, etc.)
Here I do not know how to organize the database to store all the data. While the idea is to make 3 tables - object_type, attributes and attributes_value
object_type ('id', 'name') attributes ('id', 'type', 'name', 'add_options', 'object_type_id') attributes_value ('id', 'attribute_id', 'value', 'client_id')
In the object_type table, for example -
name = 'Продам дом' In the attributes table, for example -
name = 'Количество комнат' type = 'text' object_type_id = object_type.name = 'Продам дом' In the attributes_value table, the attribute entry id, and value. Those. will be offered to the client by attributes.name, depending on the object_type we chose earlier. And the field for the record is the value from the attributes_value table.
But I somehow don’t really like this approach, maybe someone faced such a problem ?? How best to organize a database, and how easier it will be to work with it through PHP, using the yii2 framework.