php - The advantage of having another table for multiple product images? -


this product table in mysql

create table if not exists `tbl_products` (   `productid` int(11) unsigned not null auto_increment,   `productsku` varchar(6) collate utf8_bin not null,   `productname` varchar(75) character set utf8 collate utf8_unicode_ci not null,   `productdescription` text character set utf8 collate utf8_unicode_ci not null,   `extraspecification` text collate utf8_bin,   `productprice` decimal(10,2) not null default '0.00',   `mrp` decimal(10,2) not null default '0.00',   `productimage` varchar(300) collate utf8_bin not null,   `pagetitle` varchar(75) collate utf8_bin not null,   `productkeywords` varchar(250) collate utf8_bin not null,   `metadescription` varchar(250) collate utf8_bin not null,   `dateadded` timestamp not null default current_timestamp on update current_timestamp,   `addedby` varchar(300) collate utf8_bin not null,   primary key (`productid`),   unique key `productname` (`productname`),   fulltext key `productname_2` (`productname`) ) engine=innodb  default charset=utf8 collate=utf8_bin auto_increment=174 ; 

you see, have column product image

  `productimage` varchar(300) collate utf8_bin not null, 

it saves path product image in folder 'data' on server , works fine.

the problem, need have @ least 3 images per product. saw few ecommerce database structure , realized of them have different table 'product_images' storing multiple images per product.

can please explain me concept , more importantly advantage of having table altogether , how can done.

the drawback of using same table need column every image, create 3 new columns (or use comma separated list) 3 images, , client says want 4 or 5 images, you're having add new columns (or increase length of existing column) number of images want increases..... using separate table allows growth without further change database structure or code (after initial work support it)


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -