Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6253253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:57:15+00:00 2026-05-24T13:57:15+00:00

I have a problem of structure for my database. I want to know why

  • 0

I have a problem of structure for my database.

I want to know why MYSQL generate the following error:

#1005 - Can't create table 'test.panier' (errno: 150)
The variable’s name are not important.. its only the structure

Here is my sql file.

DROP TABLE IF EXISTS Panier;
DROP TABLE IF EXISTS Materiel;
DROP TABLE IF EXISTS Medicament;
DROP TABLE IF EXISTS Produit;
DROP TABLE IF EXISTS ListePatient;
DROP TABLE IF EXISTS Patient;
DROP TABLE IF EXISTS Specialiste;
DROP TABLE IF EXISTS TelPers;
DROP TABLE IF EXISTS Personne;
DROP TABLE IF EXISTS Telephone;
DROP TABLE IF EXISTS Adresse;

CREATE TABLE Panier(
idPanier        INT(5) NOT NULL,
idProduit       INT(100) NOT NULL,
PRIMARY KEY (`idPanier`,`idProduit`),
FOREIGN KEY(idPanier) REFERENCES Specialiste(idPanier),
FOREIGN KEY(idProduit) REFERENCES Produit(idProduit)
)ENGINE=InnoDB;

CREATE TABLE Adresse(
idAdresse   INT(100) NOT NULL PRIMARY KEY AUTO_INCREMENT,
num         INT(5) NOT NULL,
rue         VARCHAR(30) NOT NULL,
ville           VARCHAR(15) NOT NULL,
postal      VARCHAR(6) NOT NULL
)ENGINE=InnoDB;

CREATE TABLE Telephone(
idTel           INT(100) NOT NULL PRIMARY KEY AUTO_INCREMENT,
typeTel     VARCHAR(15) NOT NULL,
ind         INT(3) NOT NULL,
quartier        INT(3) NOT NULL,
num         INT(4) NOT NULL
)ENGINE=InnoDB;

CREATE TABLE Personne(
idPersonne      INT(100) PRIMARY KEY NOT NULL AUTO_INCREMENT,
nom             VARCHAR(15) NOT NULL,
prenom          VARCHAR(15) NOT NULL,
idTel               INT(100) NOT NULL,
idAdresse       INT(100) NOT NULL,
FOREIGN KEY(idAdresse) REFERENCES Adresse(idAdresse),
FOREIGN KEY(idTel) REFERENCES Telephone(idTel)
)ENGINE=InnoDB;

CREATE TABLE TelPers(
idPersonne      INT(100) NOT NULL,
idTel               INT(100) NOT NULL,
PRIMARY KEY (`idPersonne`,`idTel`),
FOREIGN KEY(idPersonne) REFERENCES Personne(idPersonne),
FOREIGN KEY(idTel) REFERENCES Telephone(idTel)
)ENGINE=InnoDB;

CREATE TABLE Specialiste(
login           VARCHAR(10) PRIMARY KEY NOT NULL,
password    VARCHAR(10) NOT NULL,
profession  VARCHAR(20) NOT NULL,
idListeP        INT(5) NOT NULL,
idPanier        INT(5),
idPersonne  INT(100),
FOREIGN KEY(idPersonne) REFERENCES Personne(idPersonne)
)ENGINE=InnoDB;

CREATE TABLE Patient(
idPatient    INT(10) NOT NULL PRIMARY KEY AUTO_INCREMENT,
sexe            CHAR NOT NULL,
anniv           DATE,
assurance   INT(3) NOT NULL,
idPersonne  INT(100),
FOREIGN KEY(idPersonne) REFERENCES Personne(idPersonne)
)ENGINE=InnoDB;

CREATE TABLE Produit(
idProduit       INT(100) NOT NULL PRIMARY KEY AUTO_INCREMENT,
nom         VARCHAR(50) NOT NULL,
descr           VARCHAR(255) NOT NULL,
prix            DECIMAL(5,2) NOT NULL,
qte         INT(100) NOT NULL
)ENGINE=InnoDB;

CREATE TABLE Medicament(
idMedic         INT(100)NOT NULL PRIMARY KEY AUTO_INCREMENT,
marque      VARCHAR(10) NOT NULL,
typeMed     VARCHAR(10) NOT NULL,
idProduit       INT(100) NOT NULL,
FOREIGN KEY(idProduit) REFERENCES Produit(idProduit)
)ENGINE=InnoDB;

CREATE TABLE Materiel(
idMateriel  INT(100) NOT NULL PRIMARY KEY AUTO_INCREMENT,
rabais      INT(99) NOT NULL,                                                           /* SI PRODUIT VENANT AVEC PRESCRIPTION  */
idProduit       INT(100) NOT NULL,
FOREIGN KEY(idProduit) REFERENCES Produit(idProduit)
)ENGINE=InnoDB;

Thanks for the help. 😀

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T13:57:16+00:00Added an answer on May 24, 2026 at 1:57 pm

    You are missing an index for the idPanier column in Specialiste table

    The table you are creating “Panier” references two columns
    1. Specialiste(idPanier)
    2. Produit(idProduit)

    idProduit is indexed since it is a primary key

    You will need to add index for the idPanier column as well in Specialiste table

    Also since the Panier table references other two tables … those tables should be created first

    The updated script is as follows:

        DROP TABLE IF EXISTS Panier;
    DROP TABLE IF EXISTS Materiel;
    DROP TABLE IF EXISTS Medicament;
    DROP TABLE IF EXISTS Produit;
    DROP TABLE IF EXISTS ListePatient;
    DROP TABLE IF EXISTS Patient;
    DROP TABLE IF EXISTS Specialiste;
    DROP TABLE IF EXISTS TelPers;
    DROP TABLE IF EXISTS Personne;
    DROP TABLE IF EXISTS Telephone;
    DROP TABLE IF EXISTS Adresse;
    
    
    CREATE TABLE Adresse(
    idAdresse   INT(100) NOT NULL PRIMARY KEY AUTO_INCREMENT,
    num         INT(5) NOT NULL,
    rue         VARCHAR(30) NOT NULL,
    ville           VARCHAR(15) NOT NULL,
    postal      VARCHAR(6) NOT NULL
    )ENGINE=InnoDB;
    
    CREATE TABLE Telephone(
    idTel           INT(100) NOT NULL PRIMARY KEY AUTO_INCREMENT,
    typeTel     VARCHAR(15) NOT NULL,
    ind         INT(3) NOT NULL,
    quartier        INT(3) NOT NULL,
    num         INT(4) NOT NULL
    )ENGINE=InnoDB;
    
    CREATE TABLE Personne(
    idPersonne      INT(100) PRIMARY KEY NOT NULL AUTO_INCREMENT,
    nom             VARCHAR(15) NOT NULL,
    prenom          VARCHAR(15) NOT NULL,
    idTel               INT(100) NOT NULL,
    idAdresse       INT(100) NOT NULL,
    FOREIGN KEY(idAdresse) REFERENCES Adresse(idAdresse),
    FOREIGN KEY(idTel) REFERENCES Telephone(idTel)
    )ENGINE=InnoDB;
    
    CREATE TABLE TelPers(
    idPersonne      INT(100) NOT NULL,
    idTel               INT(100) NOT NULL,
    PRIMARY KEY (`idPersonne`,`idTel`),
    FOREIGN KEY(idPersonne) REFERENCES Personne(idPersonne),
    FOREIGN KEY(idTel) REFERENCES Telephone(idTel)
    )ENGINE=InnoDB;
    
    CREATE TABLE Specialiste(
    login           VARCHAR(10) PRIMARY KEY NOT NULL,
    password    VARCHAR(10) NOT NULL,
    profession  VARCHAR(20) NOT NULL,
    idListeP        INT(5) NOT NULL,
    idPersonne  INT(100),
    idPanier        INT(5),
    INDEX(idPanier),
    FOREIGN KEY(idPersonne) REFERENCES Personne(idPersonne)
    )ENGINE=InnoDB;
    
    
    CREATE TABLE Patient(
    idPatient    INT(10) NOT NULL PRIMARY KEY AUTO_INCREMENT,
    sexe            CHAR NOT NULL,
    anniv           DATE,
    assurance   INT(3) NOT NULL,
    idPersonne  INT(100),
    FOREIGN KEY(idPersonne) REFERENCES Personne(idPersonne)
    )ENGINE=InnoDB;
    
    CREATE TABLE Produit(
    idProduit       INT(100) NOT NULL PRIMARY KEY AUTO_INCREMENT,
    nom         VARCHAR(50) NOT NULL,
    descr           VARCHAR(255) NOT NULL,
    prix            DECIMAL(5,2) NOT NULL,
    qte         INT(100) NOT NULL
    )ENGINE=InnoDB;
    
    CREATE TABLE Medicament(
    idMedic         INT(100)NOT NULL PRIMARY KEY AUTO_INCREMENT,
    marque      VARCHAR(10) NOT NULL,
    typeMed     VARCHAR(10) NOT NULL,
    idProduit       INT(100) NOT NULL,
    FOREIGN KEY(idProduit) REFERENCES Produit(idProduit)
    )ENGINE=InnoDB;
    
    CREATE TABLE Materiel(
    idMateriel  INT(100) NOT NULL PRIMARY KEY AUTO_INCREMENT,
    rabais      INT(99) NOT NULL,                                                           /* SI PRODUIT VENANT AVEC PRESCRIPTION  */
    idProduit       INT(100) NOT NULL,
    FOREIGN KEY(idProduit) REFERENCES Produit(idProduit)
    )ENGINE=InnoDB;
    
    CREATE TABLE Panier(
    idPanier        INT(5) NOT NULL,
    idProduit       INT(100) NOT NULL,
    FOREIGN KEY(idPanier) REFERENCES Specialiste(idPanier),
    FOREIGN KEY(idProduit) REFERENCES Produit(idProduit),
    PRIMARY KEY (`idPanier`,`idProduit`)
    )ENGINE=InnoDB;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following casting problem when my data structure sSpecificData contains a field
This is the edited question with full problem. Following is the table structure. (Only
i have problem using LIKE structure in DB2 : for example: select * from
I have problem i need to convert from my Array structure to std::vector<int> ...
I have problem with copying sdf file to WM emulator. My solution structure MyApp.DataLayer
I have a problem here that requires to design a data structure that takes
Here's my problem.I have 2 xmlfiles with identical structure, with the second xml containing
I have a slight problem... we made a change to our url structure the
I have the following problem in my Data Structures and Problem Solving using Java
I have a database table, with people identified by a name, a job and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.