Hello all,
I am creating a social bookmarking app. I am having a re-thought of the DB design in the middle of development.
Should I normalise the bookmarks table and remove the tag columns that I have into a separate table. I have 10 tags per bookmark and therefore 10 columns per record (per bookmark).
It seems to me that breaking the table into two would just mean I would have to do a join but the way I currently have it, its a straight select - but the table doesn't feel right...?
Thanks all
Update
Current Table Structure:
CREATE TABLE IF NOT EXISTS `bookmarks` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` char(250) NOT NULL,
`link` text NOT NULL,
`keyword_1` char(250) NOT NULL,
`keyword_2` char(250) NOT NULL,
`keyword_3` char(250) NOT NULL,
`keyword_4` char(250) NOT NULL,
`keyword_5` char(250) NOT NULL,
`keyword_6` char(250) NOT NULL,
`keyword_7` char(250) NOT NULL,
`keyword_8` char(250) NOT NULL,
`keyword_9` char(250) NOT NULL,
`keyword_10` char(250) NOT NULL,
`date_added` datetime NOT NULL,
`privacy_type` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=68 ;
Just to add, a bookmark belongs to user, in addition a tag belongs to a bookmark. So should I add the user_id to the tags table?
A new related question:
How would you search for a tag and return the bookmark?
Great to see a SQL Query example. I am hoping for something efficient as I currently can't think of anything decent apart from doing a LIKE test on every keyword column!