Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2004
    Posts
    9

    Unanswered: 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

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    mysql does not support foreign keys unless you use innodb tables
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Nov 2004
    Posts
    9
    What should I do in order to use innodb tables?

  4. #4
    Join Date
    Dec 2004
    Posts
    9
    You have to select InnoDB Storage engine in configuration of schema/table.

    try that,

    -Nanc

  5. #5
    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

Posting Permissions

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