Bonjour,
j'ai une table dont une colonne appartient à la clé étrangère (celle-ci porte sur 2 colonnes) et à laquelle j'ai aussi attribué une clé étrangère :
table `license`:
un essai dans PhpMyadmin d'insertion dans cette table semble indiquer que c'est autorisé (clé primaire + clé étrangère). Me confirmez-vous que oui ?
Code sql : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 DROP TABLE IF EXISTS `license`; CREATE TABLE `license` ( `id_SESA` int(6) NOT NULL, `application_key` smallint(2) NOT NULL, `currently_active` tinyint(1) DEFAULT NULL, `activate_date` date DEFAULT NULL, `deactivate_date` date DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -- -- Index pour la table `license` -- ALTER TABLE `license` ADD PRIMARY KEY (`id_SESA`,`application_key`) USING BTREE, ADD KEY `fk_application` (`application_key`); -- -- Contraintes pour la table `license` -- ALTER TABLE `license` ADD CONSTRAINT `fk_application` FOREIGN KEY (`application_key`) REFERENCES `application` (`application_key`), ADD CONSTRAINT `fk_user` FOREIGN KEY (`id_SESA`) REFERENCES `user` (`sesa`);
Et d'ailleurs, ceci étant le résultat d'un export, comment se fait-il qu'on trouve 2 fois la déclaration de `fk_application` ?
Partager