MySQL: DB Design for tags and items
This is my current table design:

Code:
CREATE TABLE IF NOT EXISTS `items` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `title` varchar(255) NOT NULL,
      `description` mediumtext NOT NULL,
      `user_id` bigint(100) NOT NULL,
      `to_read` tinyint(1) NOT NULL DEFAULT '0',
      `added_at` datetime NOT NULL,
      `created_at` datetime NOT NULL,
      `updated_at` datetime NOT NULL,
      PRIMARY KEY (`id`),
      KEY `user_id` (`user_id`),
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;


CREATE TABLE IF NOT EXISTS `tags` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` bigint(100) NOT NULL,
  `item_id` int(11) NOT NULL,
  `tag` varchar(255) NOT NULL,
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `item_id` (`item_id`),
  KEY `user_id` (`user_id`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8;



I want to know if this table design is good in practice or not? Sometimes, I've seen 3 tables be used when people implement tagging functionality.
So please anyone that can confirm this, would be very kind to
July 22nd, 2015 12:49am

Hello Eric,

This is a Forum for Microsoft SQL Server, not for MySQL; please post to a more related forum => http://forums.mysql.com/

I want to know if this table design is good in practice or not?

That depends on on the requirements & business logic; which we don't know, yet.

Free Windows Admin Tool Kit Click here and download it now
July 22nd, 2015 2:11am

Hi Olaf,

Thanks for your reply! I posted on forums.mysql.com.

BTW, how would you have done this?

July 22nd, 2015 2:44am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics