我在数据库中有以下两个表(索引不完整,将根据使用的引擎而定):
表格1:
CREATE TABLE `primary_images` (
`imgId` smallint(6) unsigned NOT NULL AUTO_INCREMENT,
`imgTitle` varchar(255) DEFAULT NULL,
`view` varchar(45) DEFAULT NULL,
`secondary` enum('true','false') NOT NULL DEFAULT 'false',
`imgURL` varchar(255) DEFAULT NULL,
`imgWidth` smallint(6) DEFAULT NULL,
`imgHeight` smallint(6) DEFAULT NULL,
`imgDate` datetime DEFAULT NULL,
`imgClass` enum('jeans','t-shirts','shoes','dress_shirts') DEFAULT NULL,
`imgFamily` enum('boss','lacoste','tr') DEFAULT NULL,
`imgGender` enum('mens','womens') NOT NULL DEFAULT 'mens',
PRIMARY KEY (`imgId`),
UNIQUE KEY `imgDate` (`imgDate`)
)
表格2:
CREATE TABLE `secondary_images` (
`imgId` smallint(6) unsigned NOT NULL AUTO_INCREMENT,
`primaryId` smallint(6) unsigned DEFAULT NULL,
`view` varchar(45) DEFAULT NULL,
`imgURL` varchar(255) DEFAULT NULL,
`imgWidth` smallint(6) DEFAULT NULL,
`imgHeight` smallint(6) DEFAULT NULL,
`imgDate` datetime DEFAULT NULL,
PRIMARY KEY (`imgId`),
UNIQUE KEY `imgDate` (`imgDate`)
)
将使用Table 1创建缩略图库,并连接到更大的图片版本。 imgClass
,imgFamily
和imgGender
将精确显示缩略图。
Table 2包含与Table 1中相应内容相关的图像。因此,使用primaryId
将Table 1中的单个图像与Table 2中的一个或多个图像相关联。这就是我考虑使用InnoDB的外键功能的地方,但我也熟悉MyISAM中索引的同样的功能。
不深入了解其余字段,imgDate
用于排序结果。
最后但并非最不重要的是,我应该提到这个数据库是“只读”的。所有数据都将由我输入。据告知,如果数据库是只读的,则应使用MyISAM,但我希望您可以为我的情况提供一些启示。