Tu ne peux pas faire une primary_key dessus par contre tu peux
configurer un UNIQUE TOGETHER.
Le lun. 07 mai 2012 16:40:53 CEST, dseed a écrit :
Mais pour une table de croisement j'ai réussit mettre 2 champs en clé
etrangère qui sont des clé primaires : PRIMARY KEY (`id_url`,`id_user`)
ps: ca fonctionne !!
Comment je fais en Django pour retranscrire ça ?
CREATE TABLE `t_x_site` (
`id_x_site` int(11) unsigned NOT NULL AUTO_INCREMENT,
`id_user` int(11) unsigned NOT NULL,
`id_url` int(11) unsigned NOT NULL,
`nb_visite` int(11) unsigned NOT NULL DEFAULT '0',
`date_visite` datetime DEFAULT NULL,
`recommander` tinyint(1) unsigned NOT NULL DEFAULT '0',
`actif` tinyint(1) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id_url`,`id_user`),
UNIQUE KEY `id_x_site` (`id_x_site`),
KEY `lien_url` (`id_url`),
KEY `lien_user` (`id_user`),
CONSTRAINT `lien_url` FOREIGN KEY (`id_url`) REFERENCES `t_url`
(`id_url`),
CONSTRAINT `lien_user` FOREIGN KEY (`id_user`) REFERENCES `t_user`
(`id_user`)
) ENGINE=InnoDB AUTO_INCREMENT=549 DEFAULT CHARSET=utf8;
_______________________________________________
django mailing list
[email protected]
http://lists.afpy.org/mailman/listinfo/django
_______________________________________________
django mailing list
[email protected]
http://lists.afpy.org/mailman/listinfo/django