Your tables are designed very poorly. I'm not even able to follow which table relates to which other table.
An easy to follow table design has an ID field that has values that are unique, non-repeating, and refer to the records in that table and the table itself has a meaniningful name. When you make fields that will hold ID values that relate to other tables, name them as such (parentID, childID, etc). For example, remake your tables as such:
Parent (ID, group, toChild (this field confuses me; it doesn't seem to have a purpose))
Child (ID, parentID)
Message (ID, childID)
If your tables were designed like that, it would be very easy to understand what you are trying to do, but as they are, I cannot follow what you are wanting.