You have a many-to-many relationship between properties and amenities. To model this, you need a separate table, not a variable number of columns.
There is one table which stores your properties.
INSERT INTO property (id, address, square_footage...) VALUES (111, '123 Main St', 1234...)
There is one table which stores all possible amenities.
INSERT INTO amenities (id, type, description) VALUES (222, 'Unit Features', 'Air Conditioning');
For each amenity a property has, insert one row into the table relating these two:
INSERT INTO property_amenitities (property_id, amenity_id) VALUES (111, 222);
When you want to know what amenities a specific property has, just SELECT
all rows from this table for that property's key. When you want to print out checkboxes for all amenities, SELECT
from the amenities
table and do a LEFT OUTER JOIN
to the property_amenities
table. Those rows with null values from the property_amenities
table are the boxes which are unchecked.
Related reading. You should pick up a book on relational databases from your local BORDERS before they go out of business :)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…