Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Wednesday, November 11, 2026
About Us
Magazine
Open Source
CVS
Services
Index  »  Projects  »  phpMyEdit  »  Forum  »  Writer - books problem

phpMyEdit General     Writer - books problem
Post new topic   Reply to topic    
 
lanbo     Joined: 08 Jan 2004   Posts: 4  
Post Posted: 2004-01-08 13:30
Back to top  Reply with quote     

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     Joined: 17 Jun 2003   Posts: 537   Location: Slovakia
Post Posted: 2004-01-09 18:39
Back to top  Reply with quote     

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     Joined: 17 Dec 2003   Posts: 236  
Post Posted: 2004-01-09 21:26
Back to top  Reply with quote     

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.

 
Post new topic   Reply to topic    

Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top · Feedback form · Application form
Report bug on PLATON.SK website · Terms of use · Privacy policy