Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Streda, 25. november 2026
O nás
Magazín
Otvorený softvér
CVS
Služby
Index  »  Projekty  »  phpMyEdit  »  Fórum  »  Writer - books problem

phpMyEdit General     Writer - books problem
Odoslať novú tému   Odpovedať na tému    
 
lanbo     Založený: 08.01.2004   Príspevky: 4  
Príspevok Zaslal: 2004-01-08 13:30
Návrat hore  Odpovedať s citátom     

Hi all,

Remember my last problem?

------------
Imagine table writers: IDwriter, name, surname
And table books: IDbook, IDwriter, bookname
One writer may have written many books.
-------------

OK. Now, if I remove a writer in table WRITERS, how can I automatically remove all his/her BOOKS in table BOOKS?
Which approach would you 'experts' take? ;-)

Thanks in advance and happy new year to you all!!!

 
michal     Založený: 17.06.2003   Príspevky: 537   Bydlisko: Slovakia
Príspevok Zaslal: 2004-01-09 18:39
Návrat hore  Odpovedať s citátom     

triggers should be used for this purpose. in your trigger delete after make a sql query to delete those records.

see documentation in http://opensource.platon.sk/projects/doc.php/phpMyEdit/html/configuration.triggers.html
and one forum questions concerning triggers as examples.

 
ajh     Založený: 17.12.2003   Príspevky: 236  
Príspevok Zaslal: 2004-01-09 21:26
Návrat hore  Odpovedať s citátom     

Just looking at the MySQL manual, if you use InnoDB tables in your database, you can actually create tables with foreign key constraints, so you could cascade delete the books if the writer is deleted. This would be much safer than using a trigger as if for some reason the trigger didn't run, but the main delete did, you would have a whole load of headless book records.

 
Odoslať novú tému   Odpovedať na tému    

Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok · Odkazový formulár · Prihláška
Upozorniť na chybu na PLATON.SK webstránke · Podmienky použitia · Ochrana osobných údajov