Normalize this table?

I am creating a social bookmarking application. I reflect on database design in the middle of development.

Should I normalize the bookmark table and remove the tag columns that I have in a separate table. I have 10 tags per bookmark and therefore 10 columns per record (per bookmark).

It seems to me that splitting a table into two simply means that I will need to join, but the way I use it now is its direct choice - but the table does not seem to be correct ...?

Thank you all

Update

The structure of the current table:

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, the bookmark belongs to the user, in addition, the tag belongs to the bookmark. So should I add user_id to the tag table?

New related question:

How to search for a tag and return a bookmark?

SQL Query. - , , LIKE !

+3
3

, , .

, , , ..

SELECT key_word, count(bookmark_id) AS tag_frequency
FROM tags
GROUP BY key_word
ORDER BY count(bookmark_id) DESC LIMIT 10

- , tag1, tag2 .. , , .

, , -.

, -, . , , . , .

, .

, :

SELECT bookmarks.id, bookmarks.title
FROM tags
JOIN bookmarks ON bookmarks.id = tag.bookmark_id
WHERE tags.key_word = ?

, .

+3

- , , . , , . , , . , . , , :).

+4

. , . , , Tagg- .

0

Source: https://habr.com/ru/post/1739051/


All Articles