我有一个你可能很容易回答的问题
我在下面有一个图像表
一张图片可以有多种尺寸——三个表格是不是更好的做法
一个图像详细信息表将 image_details 连接到 image_paths 的另一个表和连接到图像路径的另一个 table-image_sizes 。
或者最好将所有图像尺寸放在图像表中。实际上,我有一张图像,但尺寸不同。寻找优化的最佳选择。所有图像都将具有每种图像尺寸,因此对于某些没有特定尺寸的图像,将来不会有冗余。我不确定是否最好使用另一张桌子,以防我们添加其他尺寸。但是我可以在图像表中添加另一列以获得新的图像大小
图像表
CREATE TABLE IF NOT EXISTS `warrington_main`.`image` (
`id` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT ,
`user_id` BIGINT(20) UNSIGNED NOT NULL ,
`alias_title` VARCHAR(255) NOT NULL ,
`address_id` BIGINT(20) NULL ,
`geolocation_id` BIGINT(20) NULL ,
`camera_id` MEDIUMINT(8) NULL ,
`title` VARCHAR(100) NOT NULL ,
`description` VARCHAR(2000) NOT NULL ,
`main_image` VARCHAR(50) NOT NULL ,
`thumbnail_image` VARCHAR(50) NOT NULL ,
`thumbnail_image_medium` VARCHAR(50) NOT NULL ,
`thumbnail_image_small` VARCHAR(50) NOT NULL ,
`thumbnail_image_gallery` VARCHAR(50) NOT NULL ,
`hits` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' ,
`show_comment` ENUM('0','1') NOT NULL ,
`feature_in_gallery` ENUM('0','1') NOT NULL ,
`created_on` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' ,
`date_taken` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' ,
`updated_on` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' ,
`updated_by` BIGINT(20) UNSIGNED NOT NULL ,
`approved` ENUM('Inprocess','Yes','No') NOT NULL DEFAULT 'Inprocess' ,
`visible` ENUM('0','1') NOT NULL DEFAULT '0' ,
`account_type_created` ENUM('S','Y', 'G', 'FL', 'FB') NOT NULL ,
PRIMARY KEY (`id`) ,
UNIQUE INDEX `alias_title` (`alias_title` ASC) ,
INDEX `title` (`title` ASC) ,
INDEX `approved` (`approved` ASC) ,
INDEX `visible` (`visible` ASC) ,
INDEX `feature_in_gallery` (`feature_in_gallery` ASC) ,
INDEX `fk_image_image_user1_idx` (`user_id` ASC) ,
INDEX `fk_image_camera1_idx` (`camera_id` ASC) ,
INDEX `fk_image_address1_idx` (`address_id` ASC) ,
INDEX `fk_image_geolocation1_idx` (`geolocation_id` ASC) ,
INDEX `fk_image_user1_idx` (`updated_by` ASC) ,
CONSTRAINT `fk_image_image_user1`
FOREIGN KEY (`user_id` )
REFERENCES `warrington_main`.`user` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_image_camera1`
FOREIGN KEY (`camera_id` )
REFERENCES `warrington_main`.`camera` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_image_address1`
FOREIGN KEY (`address_id` )
REFERENCES `warrington_main`.`address` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_image_geolocation1`
FOREIGN KEY (`geolocation_id` )
REFERENCES `warrington_main`.`geolocation` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_image_user1`
FOREIGN KEY (`updated_by` )
REFERENCES `warrington_main`.`user` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
AUTO_INCREMENT = 23162
DEFAULT CHARACTER SET = utf8