Return to Snippet

Revision: 2130
at January 1, 2007 11:10 by alexwilliams


Updated Code
DROP TABLE IF EXISTS `products_tags`;
DROP TABLE IF EXISTS `tags`;
DROP TABLE IF EXISTS `products`;

CREATE TABLE `products` (
  `id` int(11) NOT NULL auto_increment,
  `title` varchar(100) NOT NULL,
  `price` decimal(10,2) NOT NULL,
  PRIMARY KEY  (`id`)
)

CREATE TABLE `tags` (
  `id` int(11) NOT NULL auto_increment,
  `title` varchar(64) NOT NULL,
  PRIMARY KEY  (`id`)
)

CREATE TABLE `products_tags` (
  `product_id` int(11) NOT NULL default '0',
  `tag_id` int(11) NOT NULL default '0',
  PRIMARY KEY  (`product_id`,`tag_id`)
)

Revision: 2129
at January 1, 2007 11:07 by alexwilliams


Initial Code
DROP TABLE IF EXISTS `products_tags`;
DROP TABLE IF EXISTS `tags`;
DROP TABLE IF EXISTS `products`;

CREATE TABLE `products` (
  `id` int(11) NOT NULL auto_increment,
  `title` varchar(100) NOT NULL,
  `price` decimal(10,2) NOT NULL,
  PRIMARY KEY  (`id`)
)

CREATE TABLE `tags` (
  `id` int(11) NOT NULL auto_increment,
  `title` varchar(64) NOT NULL,
  PRIMARY KEY  (`id`)
)

CREATE TABLE `products_tags` (
  `product_id` int(11) NOT NULL default '0',
  `tag_id` int(11) NOT NULL default '0',
  PRIMARY KEY  (`product_id`,`tag_id`)
)

Initial URL


Initial Description


Initial Title
HABTM relationship MySQL tables for use in Rails

Initial Tags
mysql, database

Initial Language
SQL