I'v noticed that in the example of offical documents, the data table of relationships has a field of id
of NOT NULL and AUTO_INCREMENT, define like this:
create table `posts_categories` (
`id` int(10) unsigned NOT NULL auto_increment,
`posts_id` int(10) unsigned not null,
`categories_id` int(10) unsigned not null,
primary key (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
Can I drop the field id
? like this:
create table `posts_categories` (
`posts_id` int(10) unsigned not null,
`categories_id` int(10) unsigned not null,
UNIQUE KEY `pid_cid` (`posts_id`, `categories_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
and the code in the models is the same with the previous vision(the table with id
field)?