List:General Discussion« Previous MessageNext Message »
From:Martin Ramsch Date:September 30 1999 1:11pm
Subject:Re: Foreign key constraint does not seems to be worked
View as plain text  
On Thu, 1999-09-30 17:06:03 +0100, Sajida Kalsoom wrote:
> would some one like to tell me how i can implement refrential
> integrity constraints i mean primay and foreign key relationship i
> have write the following code to create table;
> 
> CREATE TABLE TblTrafficCodes
>      (
>      TrafficCode          INT NOT NULL AUTO_INCREMENT,
>      Description          CHAR(50),
>      AmountPerMb          REAL,
>      PRIMARY KEY (TrafficCode)
>      );
> 
> CREATE TABLE TblPlans
>      (
>      PlanID               INT NOT NULL AUTO_INCREMENT,
>      PlanName             CHAR(50),
>      Selected             TINYINT  NOT NULL DEFAULT 1,
>      TrafficCode          INT,
>      Lapse                TINYINT,
>      WarningMail          TINYINT,
>      PRIMARY KEY		  (PlanID),
> 	 FOREIGN KEY     (TrafficCode) REFERENCES TblTrafficCodes (TrafficCode)
> 	 );
> 
> but it does not seems to be worked. when i delete parent record from
> TblTrafficCodes while child record exit it does so.

Where did you read that MySQL does this kind of referential integrity
checks?

MySQL does accept the FOREIGN KEY syntax for compatibility reasons, so
that it can read such table schemas without parsing errors, but it
doesn't do anything with it.

As you maybe didn't read the MySQL Reference Manual, may I point you
to chapters "5.3.5 Foreign Keys" and "7.6 CREATE TABLE syntax" (look
for FOREIGN KEY)?

Regards,
  Martin
-- 
Martin Ramsch <m.ramsch@stripped> <URL: http://home.pages.de/~ramsch/ >
PGP KeyID=0xE8EF4F75 FiPr=52 44 5E F3 B0 B1 38 26  E4 EC 80 58 7B 31 3A D7
Thread
Foreign key constraint does not seems to be workedSajida Kalsoom30 Sep
  • Re: Foreign key constraint does not seems to be workedMartin Ramsch30 Sep
  • Re: Foreign key constraint does not seems to be workedBob Kline30 Sep