mysql foreign key syntax / tutorial

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi.

Any body got an idea how to use hte foreign keys in mysql innodb tables
and how whould the change affect the performance of the server?

lets say i have Items table, Clients table, and Sales table
the Sales table always stores ClientID and ItemID
but not every client/item is there
a sale can be deleted without harming the client
nor the item.

i guess (not sure at all) it should go like :

ALTER TABLE Sales
 ADD FOREIGN KEY ClientID(ClientID)
 REFERENCES Clients(ClientID)
 ON DELETE RESTRICT;

ALTER TABLE Sales
 ADD FOREIGN KEY ItemID(ItemID)
 REFERENCES Items(ItemID)
 ON DELETE RESTRICT;

Am I correct?

thanks.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux