0
我一直在设计决策上如何存储在表信息中挣扎。单或分割表来保存在数据库中记录这个?
我有表叫物业持有的房地产物业的纪录。
CREATE TABLE `property` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`addDate` datetime NOT NULL,
`serial` varchar(30) NOT NULL,
`title` varchar(100) NOT NULL,
`description` text,
`user_id` int(11) NOT NULL,
`area_id` int(11) NOT NULL,
`category_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `serial` (`serial`),
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`),
FOREIGN KEY (`area_id`) REFERENCES `area`(`id`),
FOREIGN KEY (`category_id`) REFERENCES `category`(`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
我有显示功能5财产,由公司索引页网站所有者提供5 hotDeal财产。我无法决定将记录保存在一张桌子还是两张不同的桌子上。例如
。
CREATE TABLE `property_featured` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`addDate` datetime NOT NULL,
`description` text DEFAULT NULL,
`position` tinyint(1) DEFAULT '0',
`property_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `position` (`position`,`property_id`),
FOREIGN KEY (`property_id`) REFERENCES `property`(`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `property_hotdeal` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`addDate` datetime NOT NULL,
`description` text DEFAULT NULL,
`position` tinyint(1) DEFAULT '0',
`property_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `position` (`position`,`property_id`),
FOREIGN KEY (`property_id`) REFERENCES `property`(`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
哪种方法应该与单个或拆分?
事实上,两个不同的表可能会产生额外的麻烦,保持'id'列独特的两个表(我想你会想这样做)英寸 – Travesty3 2012-02-28 18:00:57