Recursion with database tables

From: Date: Wed, 19 Feb 2003 13:43:25 +0000
Subject: Recursion with database tables
Groups: php.general 
Request: Send a blank email to php-general+get-136156@lists.php.net to get a copy of this message
Hi all, I am still pretty new to PHP, but I was chatting to a friend the other day and he put some thoughts into my head about how tables are laid out and processed. 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. I have two questions about this: 1. First, is this idea of using one big table with parent/child fields better than my seperate table approach? 2. Secondly, how would I write the logic for the single table approach. Any help or advice or links to documentation would be great. Cheers, Jono

« previous php.general (#136156) next »