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 > foreign key problems

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-08-04, 08:14
rockyroad rockyroad is offline
Registered User
 
Join Date: Nov 2004
Posts: 9
foreign key problems

I am having problems creating foreign keys. I include them in the "create table" text but they do not appear on table when I do a "describe table" query

I use (for example) this text

create table departamento
(dept char(4) not null,
dedif char(3) not null,
ddespacho integer not null,
dchfno char(3),
primary key (dept))

create table curso
(cno char(4) not null,
cnombre char(22) not null,
cdescp char(25) not null,
cred integer not null,
ctarifa numeric not null,
cdept char(4) not null,
primary key (cno),
foreign key (cdept) references departamento (dept))

What am I doing wrong?

Thanks in advance
Reply With Quote
  #2 (permalink)  
Old 12-08-04, 15:57
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
mysql does not support foreign keys unless you use innodb tables
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 12-09-04, 12:48
rockyroad rockyroad is offline
Registered User
 
Join Date: Nov 2004
Posts: 9
What should I do in order to use innodb tables?
Reply With Quote
  #4 (permalink)  
Old 12-09-04, 13:23
nanc nanc is offline
Registered User
 
Join Date: Dec 2004
Posts: 9
You have to select InnoDB Storage engine in configuration of schema/table.

try that,

-Nanc
Reply With Quote
  #5 (permalink)  
Old 12-09-04, 13:26
nanc nanc is offline
Registered User
 
Join Date: Dec 2004
Posts: 9
You have to select InnoDB Storage engine in configuration of schema/table.
[which is in mysql administrator]
there are 5-6 different kind of engines available in mysql, you choose InnoDB and you are covered.
Still after changing to InnoDB If you dont see foreign key, I guess you recreate tables.
try that,

-Nanc
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