yeahz Posted February 2, 2011 Report Share Posted February 2, 2011 (edited) Ir tabulas ar šādu struktūru: table1 +----+------------+---------+ | id | article_id | kautkas | +----+------------+---------+ table2 +----+------------+---------+ | id | article_id | kautkas | +----+------------+---------+ table3 +----+------------+---------+ | id | article_id | kautkas | +----+------------+---------+ Vai var izdzēst no visas datubāzes, kur ir, piemēram, article_id=6? Vajag šo izmantot pie raksta dzēšanas un lai visi raksta dati arī tiek izdzēsti no datubāzes, savādāk jātaisa katrai tabulai savs kverijs + ja izveido kaut ko jaunu (pluginu, addonu), tad par šo var piemirst (izveidot vēl kveriju dzēšanai jaunajam addonam). Edited February 2, 2011 by yeahz Quote Link to comment Share on other sites More sharing options...
codez Posted February 2, 2011 Report Share Posted February 2, 2011 (edited) Ieliec FOREIGN KEY Constraints un ON DELETE Kad izdzēsīs galveno ierakstu, izdzēsīs visus saistītos ierakstus. Edited February 2, 2011 by codez Quote Link to comment Share on other sites More sharing options...
briedis Posted February 2, 2011 Report Share Posted February 2, 2011 imo uz MyISAM neies tas FOREIGN KEY, laikam būs jālieto innodb Quote Link to comment Share on other sites More sharing options...
Rincewind Posted February 2, 2011 Report Share Posted February 2, 2011 imo uz MyISAM neies tas FOREIGN KEY, laikam būs jālieto innodb Dokumentācijā šitādu atradu, kā CASCADE DELETE aizvietotājs laikam der: CREATE TRIGGER delete_myisam_child BEFORE DELETE ON myisam_parent FOR EACH ROW BEGIN DELETE FROM myisam_child WHERE mparent_id=old.mparent_id; END; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.