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 > is this a legal operation?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-11-04, 05:44
evilz35 evilz35 is offline
Registered User
 
Join Date: Feb 2004
Posts: 78
is this a legal operation?

hi in the following table i have 2 foriegn key which reference to a different table, is this the way i would show this.?


CREATE TABLE Car_stats
(
VehReg VARCHAR(10) NOT NULL,
Model VARCHAR(40) NOT NULL,
Make VARCHAR(55) NOT NULL,
Colour VARCHAR(30) NOT NULL,
Millage INT NOT NULL,
MOT_Due_Date TIMESTAMP(6) NOT NULL,
PRIMARY KEY (VehReg),

CONSTRAINT statmodel_fk FOREIGN KEY (Model) REFERENCES Car_type (Model),
CONSTRAINT statmake_fk FOREIGN KEY (Make) REFERENCES Car_type (Make)
);
Reply With Quote
  #2 (permalink)  
Old 03-11-04, 06:35
omiossec omiossec is offline
Registered User
 
Join Date: Jan 2003
Location: Paris, France
Posts: 320
You forget to create index for you col ref

You will get a 150 error if you use INNODB table type
__________________
Olivier Miossec
--
http://www.lasso-developpeur.net/
--
Reply With Quote
  #3 (permalink)  
Old 03-11-04, 07:38
evilz35 evilz35 is offline
Registered User
 
Join Date: Feb 2004
Posts: 78
how would i do that?
Reply With Quote
  #4 (permalink)  
Old 03-11-04, 07:55
evilz35 evilz35 is offline
Registered User
 
Join Date: Feb 2004
Posts: 78
would it be okay to do this instead?

CREATE TABLE Car_stats
(
VehReg VARCHAR(10) NOT NULL,
Model VARCHAR(40) NOT NULL,
Make VARCHAR(55) NOT NULL,
Colour VARCHAR(30) NOT NULL,
Millage INT NOT NULL,
MOT_Due_Date TIMESTAMP(6) NOT NULL,
PRIMARY KEY (VehReg),

CONSTRAINT statmodel_fk FOREIGN KEY (Model,Make) REFERENCES Car_type (Model,Make)

);
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