If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Newbie design question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-10-04, 11:44
Noodles Noodles is offline
Registered User
 
Join Date: Sep 2003
Posts: 7
Question 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.
Reply With Quote
  #2 (permalink)  
Old 05-10-04, 22:32
J.D. J.D. is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 05-13-04, 08:43
Noodles Noodles is offline
Registered User
 
Join Date: Sep 2003
Posts: 7
Thumbs up [solved]

Thanx a lot JD!!!
Reply With Quote
  #4 (permalink)  
Old 05-13-04, 10:30
richy240 richy240 is offline
Registered User
 
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...
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On