I am in a design dilemma, I am designing a database for a house rental application, the point that got me stuck is the amenities of the house, given that a house can have multi amenities like Ceiling board,Dishwasher, Refrigerator, Paved yard, Wall fence etc
How do I store such a house in the database? Some suggestion I have been given are(Simplified tables):
` |id |description|amenities|
|1 | | |
Store amenity ids eg 1,2,3,4
in the amenities column
Store the amenity strings in the amenities column
Between the two option 1 is best because am saving memory but isn't there a better way to store multiple ids than this?
You can use EAV model for that, you will save memory, but will lose performance on select, or use sparse columns
EAV approach:
EAV table:
Attribute table:
Entity table:
Attributes would be
Ceiling board,Dishwasher, Refrigerator, Paved yard, Wall fence etc
Entities
house 1, house 2
Sparse columns:
House table:
Simple mapping:
House table:
Amenities table:
HouseAmenitiesMapping:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.