对于房子的任意属性,您可以为所有人准备一张桌子。
CREATE TABLE `property_prop` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`properties_id` INT UNSIGNED NOT NULL ,
`name` VARCHAR( 32 ) NOT NULL ,
`value` VARCHAR( 64 ) NOT NULL ,
PRIMARY KEY ( `id` ) ,
INDEX ( `property_id` )
) ENGINE = MYISAM
INSERT INTO property_prop (properties_id,name,value) VALUES (100,'Spacing','100');
INSERT INTO property_prop (properties_id,name,value) VALUES (100,'Rooms','4');
INSERT INTO property_prop (properties_id,name,value) VALUES (100,'Description','This is a nice house. ;)');
//Get a list of all properties for house with id 100.
SELECT name,value FROM property_prop WHERE properties_id=100;