Hello,

I am trying to create some tables that I can use the delete on cascade function for. 
This would help me code the project and ensure data integrity. I am on the docs @ 
http://www.mysql.com/doc/en/InnoDB_foreign_key_constraints.html but I am not quite 
understanding the syntax.

I am creating two test tables to work out the logic. What I want to do is delete a 
certain 'ID' from 'table 'ONE' and have it delete the same foreign key id of the same 
value in table 'TWO'.

Here is what I have entered into the mysql command.
mysql> create table one (id varchar(2) not null, name varchar(20), primary key (
id)) type=INNODB;
That is table one, with a primary key on ID;
Now the foreign key table;

mysql> create table two (fid varchar(2), fname varchar(20), fOREIGN KEY (fid) RE
FERENCES one(id) on delete cascade);

Insert data:
one:
id    name
1    'scott'
2    'benjamin'

two:
fid    name
1   'twoscott'
2   'twobenjamin'



Problem is when I delete from one where id = '1' it does not delete the foreign key 
one in table two.

I hope I explained this well.

thanks,
Scott



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to