Ernest E Vogelsinger wrote:

At 14:43 19.02.2003, Jono Bacon said:
--------------------[snip]--------------------

At the moment I have three tables: Topic, Message, Comment. A topic has messages and each message can have comments. I have set this up with a table each and a field for the id of the parent (e.g. a comment will have the id of the message that it refers to).

My mate said to me that I should really put all of this in one big table with a parent and child field. He said that my code should then figure out what is the child of what and how it is displayed.

This are one-to-many relationships? If yes, then your mate is wrong, you
can't easily implement one-to-many using a single table.

<snip>


Hi Ernest,

Thanks for your swift response.

The code that you posed is the technique I have used at the moment. This technique works fine, but like my mate said, this limits me to a single parent for a comment/message. I admit that is unlikely that I would need more than one parent, but what would happen if I changed the parent - would this model still work fine?

I am considering sticking with this technique - it seems to make more sense and I thought it would be quicker for queries as I wouldnt have to query a single table with a million rows.

One questions though - if I delete a topic, I need to delete all of its child messages and all of the child comments from each message. What is the best technique to do this? This has been driving me up the wall as it seems to involve some kind of looping and recursion.

Jono




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to