Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2011
    Posts
    1

    Question Unanswered: Problem with my database

    Hi there, there is a problem with my database. I don't know why because it just said ERROR when i create it.

    I use MYSQL 5.5.6 in PHPMYADMIN.. here's my code

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

    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) PRIMARY KEY NOT NULL,
    idTel INT(100) PRIMARY KEY NOT NULL,
    FOREIGN KEY(idPersonne) REFERENCES Personne(idPersonne),
    FOREIGN KEY(idTel) REFERENCES Telephone(idTel)
    )ENGINE=InnoDB;

    CREATE TABLE Specialiste(
    login VARCHAR(10) PRIMARY KEY NOT NULL PRIMARY KEY,
    password VARCHAR(10) NOT NULL,
    profession VARCHAR(20) NOT NULL,
    idListeP INT(5),
    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 ListePatient(
    idListeP INT(5) NOT NULL PRIMARY KEY,
    idPatient INT(10)NOT NULL PRIMARY KEY,
    FOREIGN KEY(idListeP) REFERENCES Specialiste(idListeP),
    FOREIGN KEY(idPatient) REFERENCES Patient(idPatient)
    )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,
    idProduit INT(100) NOT NULL,
    FOREIGN KEY(idProduit) REFERENCES Produit(idProduit)
    )ENGINE=InnoDB;

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

    Thanks to help me. I want to use the Engine INNODB for relational database. Look at the form and structure, the variable meaning is not necessary.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    you must show us the actual error messages

    off the top of my head, stuff like this will cause an error --
    Code:
    login VARCHAR(10) PRIMARY KEY NOT NULL PRIMARY KEY,
    can you see why?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •