Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2003
    Posts
    7

    Question Unanswered: Newbie design question

    Hi I'm new on MySql and i'm trying to design my tables.
    One of them is this:

    CREATE TABLE UnidadesFuncionales
    (CodigoConsorcio varchar(10) NOT NULL PRIMARY KEY,
    Piso varchar(10) NOT NULL PRIMARY KEY,
    Dpto varchar(10) NOT NULL PRIMARY KEY,
    Propietario varchar(100) NOT NULL,
    Telefono varchar(30) NULL,
    Telefono2 varchar(30) NULL,
    Telefono3 varchar(30) NULL,
    Telefono4 varchar(30) NULL,
    Fax varchar(30) NULL,
    Email varchar(50) NULL,
    Observaciones varchar(150) NULL)

    Once i run the script i get the error message "Multiple Primary Key defined", and that's exactly what i need!!!!. This is possible in SQL Server, but can i do it on MySql??

    Thanx for any help.

  2. #2
    Join Date
    May 2004
    Location
    NJ USA
    Posts
    21
    You have to set the PRIMARY KEY in the following way:

    CREATE TABLE UnidadesFuncionales (
    CodigoConsorcio varchar(10),
    Piso varchar(10),
    Dpto varchar(10),
    Propietario varchar(100) NOT NULL,
    Telefono varchar(30) NULL,
    Telefono2 varchar(30) NULL,
    Telefono3 varchar(30) NULL,
    Telefono4 varchar(30) NULL,
    Fax varchar(30) NULL,
    Email varchar(50) NULL,
    Observaciones varchar(150) NULL,
    PRIMARY KEY(CodigoConsorcio, Piso,Dpto )
    );

    You should have no problems with this.
    J.D.
    Database Administrator

  3. #3
    Join Date
    Sep 2003
    Posts
    7

    Thumbs up [solved]

    Thanx a lot JD!!!

  4. #4
    Join Date
    Sep 2003
    Posts
    24
    This is only when creating a table with multiple primary keys, correct? Otherwise, I assume Noodles was doing this the right way...

Posting Permissions

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