Bonjour,
Je n'arrive pas à comprendre pourquoi j'ai cette erreur, vu que je n'ai défini qu'une seule clé primaire par table.
J'ai deux tables :
- personne ( id_pers, nom_pers, prenom_pers...........)
- structure (id_struct, nom_contact,...............,id_pers)

Je n'arrive pas à mettre id_pers comme clé étrangère dans la table structure!

Voici mon code SQL:
Code : 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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
-- phpMyAdmin SQL Dump
-- version 4.3.12
-- http://www.phpmyadmin.net
--
-- Client :  localhost
-- Généré le :  Lun 23 Mars 2015 à 14:25
-- Version du serveur :  5.5.23
-- Version de PHP :  5.6.5
 
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
 
 
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
 
--
-- Base de données :  `croix_rouge`
--
 
-- --------------------------------------------------------
 
--
-- Structure de la table `personne`
--
 
CREATE TABLE IF NOT EXISTS `personne` (
  `id_pers` int(11) NOT NULL,
  `nom_pers` varchar(30) NOT NULL,
  `prenom_pers` varchar(40) NOT NULL,
  `fct_pers` varchar(40) NOT NULL,
  `tel_m` varchar(11) NOT NULL,
  `tel_d` varchar(11) NOT NULL,
  `tel_p` varchar(11) NOT NULL,
  `mail_pers` varchar(50) NOT NULL,
  `fax_pers` varchar(11) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=2093 DEFAULT CHARSET=latin1;
 
-- --------------------------------------------------------
 
--
-- Structure de la table `structure`
--
 
CREATE TABLE IF NOT EXISTS `structure` (
  `id_struct` int(11) NOT NULL,
  `typologie` varchar(40) NOT NULL,
  `nom_contact` varchar(30) NOT NULL,
  `thematique` varchar(30) NOT NULL,
  `desc_contact` text NOT NULL,
  `nom_struct` varchar(30) NOT NULL,
  `nom_service` varchar(30) NOT NULL,
  `adres_struct` varchar(50) NOT NULL,
  `tel_struct` varchar(20) NOT NULL,
  `fax_struct` varchar(20) NOT NULL,
  `page_web` varchar(20) NOT NULL,
  `mail_struct` varchar(20) NOT NULL,
  `comment_struct` text NOT NULL,
  `id_pers` int(11) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=102 DEFAULT CHARSET=latin1;
 
--
-- Contenu de la table `structure`
--
 
 
 
--
-- Index pour les tables exportées
--
 
--
-- Index pour la table `personne`
--
ALTER TABLE `personne`
  ADD PRIMARY KEY (`id_pers`);
 
--
-- Index pour la table `structure`
--
ALTER TABLE `structure`
  ADD PRIMARY KEY (`id_struct`);
 
--
-- AUTO_INCREMENT pour les tables exportées
--
 
--
-- AUTO_INCREMENT pour la table `personne`
--
ALTER TABLE `personne`
  MODIFY `id_pers` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT pour la table `structure`
--
ALTER TABLE `structure`
  MODIFY `id_struct` int(11) NOT NULL AUTO_INCREMENT;
 
ALTER TABLE `structure`  
  ADD CONSTRAINT fk_personne_structure FOREIGN KEY (id_pers) REFERENCES personne(id_pers);  
 
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
Merci