Dimitri Marshall wrote:
Hi there, Here's my situation:
I'm making a message board and I've decided the best way to go about the structure is to have 3 tables, two of them will be "Posts" and "Replys". Now, in order for this ti work, each post has to have a UniqueID - same with the replys. Looking at another program, I can see that one way to do this is to do it by rows (ie. count how many rows, add 1, then that is the ID). It would be unique because no two rows would be 1 for example.
The problem I can see is that the database would become incredibly huge (size wise I mean). I want to delete the posts after 30 days, and if I delete the row, then that would mess up the row system.
Any suggestions?
Dimitri Marshall
A standard solution in this case is to use one common table for all messages, both 'posts' and 'replays', distinguishing them by 'type' (TypeID, say 1 for post, 2 for replay), and then build a parent/child relationship between both type of messages in that table. In this way each message will have unique id. When you need all or some 'post' messages, use a query for selecting TypeID = 1, resp. TypeID = 2 for 'replay' messages.
Concerning the deletion of a message (post or replay), you should write a query which will recursively delete the message selected as well as all child messages assigned to that (parent) message. The easiest way to do this is to use triggers, but that depends on the database you work with.
To get closer to this approach and to find some nice examples, check out the following resources:
http://www.sqlmag.com/Articles/Index.cfm?ArticleID=8826 http://www.sqlteam.com/item.asp?ItemID=8866 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/acdata/ac_8_qd_14_5yk3.asp http://www.yafla.com/papers/sqlhierarchies/sqlhierarchies.htm
HTH,
Boyan --
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php