2 Answers
2

Ok this is untested and makes some assumptions. First assumption is that the id numbers are integers and that the releaseid will never be 0. Next assumption is the projectid is the PK of the table. Final assumption is that you can tell the parentproject because the parentid is null.

Now the only correct way to do this is in trigger. That way it will always be correct no matter how the data is changed. There is no other completely reliable way to ensure the data stays in synch. Triggers must be written to handle multiple records. This trigger is a rough approximation and is not tested. Be sure to thoroughly test a trigger (including tesiting a multiple rcord insert and a multiple record update) before using it.