Hello,
I'm working on a photo gallery script and I want the uploaded photo to have the ability to be included in multiple albums so instead of adding "album_id" as a field in "images" table which will limit the number of albums that the image can belong to to only one I thought about this
CREATE TABLE `images` (
`idx` bigint(20) NOT NULL auto_increment,
`added` int(11) NOT NULL default '0',
`filename` varchar(50) NOT NULL default '',
`tn_filename` varchar(75) NOT NULL default '',
`filepath` varchar(150) NOT NULL default '',
PRIMARY KEY `idx` (`idx`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE TABLE albums (
album_id int(11) NOT NULL auto_increment,
album_name varchar(50) NOT NULL default '',
album_description text NOT NULL,
PRIMARY KEY (galbum_id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
and a 3rd table like this
CREATE TABLE album_images (
photo_id int(11) NOT NULL default '0',
album_id int(11) NOT NULL default '0',
PRIMARY KEY (photo_id,album_id)
) TYPE=MyISAM;
The 3rd table should be linked to the first 2 tables by a way or another ?
If this whole pattern is not the best please guide me on how can I reach my goal
Thanks