IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 MySQL Discussion :

problème de contrainte avec tables INNODB


Sujet :

MySQL

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Étudiant
    Inscrit en
    Mai 2008
    Messages
    160
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2008
    Messages : 160
    Par défaut problème de contrainte avec tables INNODB
    Bonjour a tous,

    J'ai un petit souci, j'avais créer des table avec des clé étrangère mais comme je n'utilisais le type INNODB elle n'étais pas pris on compte
    j'ai refais mes tables avec le type INNODB

    j'utilise easyphp avec mysql 5.1.43

    voici mes table
    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
     
    CREATE TABLE GroupeClients
    (
    	NumerosGroupeClient					INTEGER 		NOT NULL 	AUTO_INCREMENT,
    	NomGroupe							VARCHAR(100),
    		PRIMARY KEY(NumerosGroupeClient)
    ) TYPE=INNODB;
    CREATE TABLE Clients
    (
    	NumerosClient						INTEGER			NOT NULL 	AUTO_INCREMENT,
    	NomClient							VARCHAR(100),
    	Prenom						VARCHAR(100),
    	Rue									VARCHAR(100),
    	Npa									INTEGER(4),
    	Ville								VARCHAR(100),
    	Tel									VARCHAR(20),
    	Natel								VARCHAR(20),
    	Email								VARCHAR(100),
    	Ref_NumerosGroupe					INTEGER(10)		NOT NULL,
    		PRIMARY KEY(NumerosClient)
    ) TYPE=INNODB;
     
    CREATE TABLE ExpediteurEmails
    (
    	NumerosExpediteur					INTEGER 		NOT NULL 	AUTO_INCREMENT,
    	Email								VARCHAR(100),
    	NomExpediteur						VARCHAR(100),
    	UserName							VARCHAR(100),
    	Password							VARCHAR(100),
    	Smtp								VARCHAR(100)		DEFAULT 'mail.kayenne.ch',
    	Port								INTEGER				DEFAULT '587',
    		PRIMARY KEY(NumerosExpediteur)
    ) TYPE=INNODB;
     
    CREATE TABLE fileEmail
    (
    	NumerosFileEmail					INTEGER			NOT NULL	AUTO_INCREMENT,
    	NomFileEmail						VARCHAR(100),
    	Chemin								VARCHAR(100),
    	Ref_NumerosEmails					INTEGER			NOT NULL,
    		PRIMARY KEY(NumerosFileEmail)
    ) TYPE=INNODB;
    CREATE TABLE Emails
    (
    	NumerosEmail						INTEGER			NOT NULL	AUTO_INCREMENT,
    	Ref_NumerosExpediteur				INTEGER			NOT NULL,
    	Ref_DestinataireClient				INTEGER,
    	Ref_DestinataireGroupeClients		INTEGER,
    	Sujet								VARCHAR(100),
    	Contenu								TEXT,
    		PRIMARY KEY(NumerosEmail)
    ) TYPE=INNODB;
    CREATE TABLE Concours
    (
    	NumerosConcours						INTEGER 		NOT NULL 	AUTO_INCREMENT,
    	DateParticipation					DATE,
    	ValideReponse						INTEGER(1),
    	Ref_NumerosClient					INTEGER(10)		NOT NULL,
    		PRIMARY KEY(NumerosConcours)
    ) TYPE=INNODB;
     
    CREATE TABLE Pages (
    	IdPage								INTEGER 		NOT NULL 	AUTO_INCREMENT ,
    	Titre 								VARCHAR(255) 	NOT NULL ,
    	Mots_cles							VARCHAR(255),
    	Description 						VARCHAR(255),
    	Chemin								VARCHAR(255) 	NOT NULL ,
    	Id_parent 							INTEGER 			DEFAULT '1' ,
    		PRIMARY KEY (IdPage)
    ) TYPE=INNODB;
    et maintenant je n'arrive pas y insérer les contrainte de clé étrangère

    voici mes contrainte
    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
     
    ALTER TABLE Clients
    	ADD CONSTRAINT fk_Clients_GroupeClients
    		FOREIGN KEY (Ref_NumerosGroupe)
    		REFERENCES GroupeClients(NumerosGroupe);
     
     
    ALTER TABLE Concours
    	ADD CONSTRAINT fk_Concours_Clients
    		FOREIGN KEY (Ref_NumerosClient)
    		REFERENCES Clients(NumerosClients);
     
     
    ALTER TABLE Emails
    	ADD CONSTRAINT fk_Emails_ExpediteurEmails
    		FOREIGN KEY (Ref_NumerosExpediteur)
    		REFERENCES ExpediteurEmails(NumerosExpediteur);
     
     
    ALTER TABLE Emails
    	ADD CONSTRAINT fk_Emails_Clients
    		FOREIGN KEY (Ref_DestinataireClient)
    		REFERENCES Clients(NumerosClients);
     
     
    ALTER TABLE Emails
    	ADD CONSTRAINT fk_Emails_GroupeClients
    		FOREIGN KEY (Ref_DestinataireClient)
    		REFERENCES GroupeClients(NumerosGroupeClient);
     
     
    ALTER TABLE fileEmail
    	ADD CONSTRAINT fk_fileEmail_Emails
    		FOREIGN KEY (Ref_NumerosEmails)
    		REFERENCES Emails(NumerosEmails);
    voici le message erreur

    #1005 - Ne peut créer la table 'db_kayenne.#sql-c8_7a9' (Errcode: 150) (<a href="server_engines.php?engine=InnoDB&amp;page=Status&amp;token=8e6985a1b170ae65157feebe47db1f45">Détails...</a>)

    Merci pour l'aide que vous allez m'apporter

  2. #2
    Expert confirmé
    Avatar de qi130
    Homme Profil pro
    Expert Processus IT
    Inscrit en
    Mars 2003
    Messages
    3 932
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 64
    Localisation : France

    Informations professionnelles :
    Activité : Expert Processus IT
    Secteur : Finance

    Informations forums :
    Inscription : Mars 2003
    Messages : 3 932
    Par défaut
    Un grand classique...

    Regarde ce qui est mentionné ici: http://dev.mysql.com/doc/refman/5.0/...nstraints.html

  3. #3
    Membre confirmé
    Profil pro
    Étudiant
    Inscrit en
    Mai 2008
    Messages
    160
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2008
    Messages : 160
    Par défaut
    Merci pour le fichier que tu m'as mis comme lien

    Selon ce que j'ai lu et compris il faut créer les index sur les colonne qui vont servir de clé étrangère.
    J'ai modifier mes tables
    les voici modifier
    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
    CREATE TABLE GroupeClients
    (
    	NumerosGroupeClient					INTEGER 		NOT NULL 	AUTO_INCREMENT,
    	NomGroupe							VARCHAR(100),
    		PRIMARY KEY(NumerosGroupeClient)
    ) TYPE=INNODB;
    CREATE TABLE Clients
    (
    	NumerosClient						INTEGER			NOT NULL 	AUTO_INCREMENT,
    	NomClient							VARCHAR(100),
    	Prenom								VARCHAR(100),
    	Rue									VARCHAR(100),
    	Npa									INTEGER(4),
    	Ville								VARCHAR(100),
    	Tel									VARCHAR(20),
    	Natel								VARCHAR(20),
    	Email								VARCHAR(100),
    	Ref_NumerosGroupe					INTEGER(10)		NOT NULL,
    		PRIMARY KEY(NumerosClient),
    		INDEX ind_Ref_NumerosGroupe(Ref_NumerosGroupe)
    ) TYPE=INNODB;
     
    CREATE TABLE ExpediteurEmails
    (
    	NumerosExpediteur					INTEGER 		NOT NULL 	AUTO_INCREMENT,
    	Email								VARCHAR(100),
    	NomExpediteur						VARCHAR(100),
    	UserName							VARCHAR(100),
    	Password							VARCHAR(100),
    	Smtp								VARCHAR(100)		DEFAULT 'mail.kayenne.ch',
    	Port								INTEGER				DEFAULT '587',
    		PRIMARY KEY(NumerosExpediteur)
    ) TYPE=INNODB;
     
    CREATE TABLE fileEmail
    (
    	NumerosFileEmail					INTEGER			NOT NULL	AUTO_INCREMENT,
    	NomFileEmail						VARCHAR(100),
    	Chemin								VARCHAR(100),
    	Ref_NumerosEmails					INTEGER			NOT NULL,
    		PRIMARY KEY(NumerosFileEmail),
    		INDEX ind_Ref_NumerosEmails(Ref_NumerosEmails)
    ) TYPE=INNODB;
    CREATE TABLE Emails
    (
    	NumerosEmail						INTEGER			NOT NULL	AUTO_INCREMENT,
    	Ref_NumerosExpediteur				INTEGER			NOT NULL,
    	Ref_DestinataireClient				INTEGER,
    	Ref_DestinataireGroupeClients		INTEGER,
    	Sujet								VARCHAR(100),
    	Contenu								TEXT,
    		PRIMARY KEY(NumerosEmail),
    		INDEX ind_Ref_NumerosExpediteur(Ref_NumerosExpediteur),
    		INDEX ind_Ref_DestinataireClient(Ref_DestinataireClient),
    		INDEX ind_Ref_DestinataireGroupeClients(Ref_DestinataireGroupeClients)
    ) TYPE=INNODB;
    CREATE TABLE Concours
    (
    	NumerosConcours						INTEGER 		NOT NULL 	AUTO_INCREMENT,
    	DateParticipation					DATE,
    	ValideReponse						INTEGER(1),
    	EstGagnant							INTEGER(1),
    	Ref_NumerosClient					INTEGER(10)		NOT NULL,
    		PRIMARY KEY(NumerosConcours),
    		INDEX ind_Ref_NumerosClient(Ref_NumerosClient)
    ) TYPE=INNODB;
     
    CREATE TABLE Pages (
    	IdPage								INTEGER 		NOT NULL 	AUTO_INCREMENT ,
    	Titre 								VARCHAR(255) 	NOT NULL ,
    	Mots_cles							VARCHAR(255),
    	Description 						VARCHAR(255),
    	Chemin								VARCHAR(255) 	NOT NULL ,
    	Id_parent 							INTEGER 			DEFAULT '1' ,
    		PRIMARY KEY (IdPage)
    ) TYPE=INNODB;
    ensuite je retente de faire les contrainte mais je n'y arrive toujours pas toujours la même erreur
    les voici
    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
    ALTER TABLE Clients
    	ADD CONSTRAINT fk_Clients_GroupeClients
    		FOREIGN KEY (Ref_NumerosGroupe)
    		REFERENCES GroupeClients(NumerosGroupe)
    		ON DELETE RESTRICT;
     
     
    ALTER TABLE Concours
    	ADD CONSTRAINT fk_Concours_Clients
    		FOREIGN KEY (Ref_NumerosClient)
    		REFERENCES Clients(NumerosClients)
    		ON DELETE RESTRICT;
     
     
    ALTER TABLE Emails
    	ADD CONSTRAINT fk_Emails_ExpediteurEmails
    		FOREIGN KEY (Ref_NumerosExpediteur)
    		REFERENCES ExpediteurEmails(NumerosExpediteur)
    		ON DELETE RESTRICT;
     
     
    ALTER TABLE Emails
    	ADD CONSTRAINT fk_Emails_Clients
    		FOREIGN KEY (Ref_DestinataireClient)
    		REFERENCES Clients(NumerosClients)
    		ON DELETE RESTRICT;
     
     
    ALTER TABLE Emails
    	ADD CONSTRAINT fk_Emails_GroupeClients
    		FOREIGN KEY (Ref_DestinataireClient)
    		REFERENCES GroupeClients(NumerosGroupeClient)
    		ON DELETE RESTRICT;
     
     
    ALTER TABLE fileEmail
    	ADD CONSTRAINT fk_fileEmail_Emails
    		FOREIGN KEY (Ref_NumerosEmails)
    		REFERENCES Emails(NumerosEmails)
    		ON DELETE RESTRICT;
    Est-ce que j'aurais oublier un détail par rapport au document
    car on gras il disent qu'avant d'utiliser ALTER TABLE il faut avoir créer les index ce que j'ai fais
    La je ne comprend plus d'où pourrais venir l'erreur
    JE remercie d'avance qui pourra m'aiguillez encore un peu Merci

  4. #4
    Membre confirmé
    Profil pro
    Étudiant
    Inscrit en
    Mai 2008
    Messages
    160
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2008
    Messages : 160
    Par défaut
    excusez moi pour la discussion en plus
    car le problème venais en plus des index les nom de colonnes n'entais pas correct

    Merci a tous

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Problème de concurrence sur table InnoDB
    Par MonsieurPoulet dans le forum Requêtes
    Réponses: 1
    Dernier message: 27/09/2013, 11h21
  2. Problème de mapping avec table d'association
    Par Madfrix dans le forum JPA
    Réponses: 3
    Dernier message: 03/04/2013, 11h48
  3. Excel 2000-problème de contrainte avec le solveur
    Par jncoffy dans le forum Conception
    Réponses: 1
    Dernier message: 04/02/2010, 01h18
  4. Problème de filtration avec tables couples
    Par moilou2 dans le forum VBA Access
    Réponses: 4
    Dernier message: 22/07/2008, 12h11
  5. Problème avec la création de mes tables innoDB (Pb de Foreign Key)
    Par pofexpray dans le forum SQL Procédural
    Réponses: 7
    Dernier message: 08/03/2007, 08h44

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo