Hi!

The message I sent 5 minutes ago answers also this :).

I have now improved foreign key support so that version 3.23.50 does

1. show the FOREIGN KEY definitions when you call SHOW CREATE TABLE; this
should also show them in mysqldumps;
2. preserve FOREIGN KEY definitions in ALTER TABLE and CREATE INDEX;
3. allow backquotes around column and table names in foreign key
definitions: backquotes are produced by SHOW CREATE TABLE;
4. allow adding a new foreign key constraint ot a table through
    ALTER TABLE ... ADD CONSTRAINT FOREIGN KEY (...) REFERENCES ... (...);
remember though that you first have to create the appropriate indexes on the
parent and child table so that InnoDB approves the constraint.

I try to get also in .50 a command SET FOREIGN KEY CONSTRAINT CHECKS=0 which
allows you to disable them when you import dumped tables in a wrong order
regarding to the foreign key definitions.

In versions < 3.23.50 the only way to 'dump' foreign key definitions is to
call SHOW TABLE STATUS FROM ... which prints them in the table comments.

Best regards,

Heikki Tuuri
Innobase Oy
---
Order technical MySQL/InnoDB support at https://order.mysql.com/
Speed up adding of features to MySQL/InnoDB through support contracts
See http://www.innodb.com for the online manual and latest news on InnoDB


-----Original Message-----
From: "van den Heuvel, Frank" <[EMAIL PROTECTED]>
Newsgroups: mailing.database.mysql
Date: Tuesday, March 12, 2002 10:16 AM
Subject: foreign keys for relation ships


>Hello,
>
>I am creating tables within MySql  3.23.49. I want to add relation ships
>between different tables. I tried to do this with foreign key statements.
>For example:
>
>CREATE TABLE domains (
>  domain varchar(100) NOT NULL,
>  registrarid int(10) NOT NULL,
>  foreign key (registrarid) REFERENCES registrars(registrarid),
>  PRIMARY KEY  (domain)
>) TYPE=INNODB;
>
>CREATE TABLE registrars (
>  registrarid int(10) unsigned NOT NULL auto_increment,
>  url varchar(200) default NULL,
>  whois varchar(100) default NULL,
>  tld varchar(100) default NULL,
>  PRIMARY KEY  (registrarid)
>) TYPE=INNODB
>
>So the column registrarid in the domain table is a reference to the
>registrars table(registrarid). When I put this in mysql it doesn't complain
>about it. Then I use ODBC to link the database to Access. I use Access as
my
>front-end. There I cannot see the relationship. Also when I do a show
create
>table within mysql I cannot see the relationship. Is this the wrong way to
>do this ? In other words, what is the right way to do this ?
>
>Thanks Frank
>
>---------------------------------------------------------------------
>Before posting, please check:
>   http://www.mysql.com/manual.php   (the manual)
>   http://lists.mysql.com/           (the list archive)
>
>To request this thread, e-mail <[EMAIL PROTECTED]>
>To unsubscribe, e-mail
<[EMAIL PROTECTED]>
>Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to