Results 1 to 15 of 15

Thread: [RESOLVED] Forum Help - Thread/Post Storage

  1. #1

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Resolved [RESOLVED] Forum Help - Thread/Post Storage

    I am making a small forum for my website and i am not sure of the best way to store posts and threads.

    Should i store them all in one table and just have a field "parent" that if it is blank it must be a thread and if not, it is a post.

    Or should they be in separate tables?

    I think that when they are together it makes it easier for me to count the number of posts and thread on the main forum page.

    http://www.rapidfriends.com/forums.php That is what i have so far.
    My usual boring signature: Something

  2. #2

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Forum Help - Thread/Post Storage

    never mind! i decided to go with them all in the same table.

    rep was distributed accordingly
    My usual boring signature: Something

  3. #3
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: [RESOLVED] Forum Help - Thread/Post Storage

    I thought I replied to this last night. In my imaginary reply I said that you should put them in two tables. It will reduce redundancy and overhead (i.e: when moving threads).

    It also means it is more normalized.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [RESOLVED] Forum Help - Thread/Post Storage

    Threads are not posts. They must be in separate tables. The data that you store in each case is quite different.

  5. #5
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: [RESOLVED] Forum Help - Thread/Post Storage

    FroumID, Number Of Replies, Thread Starter, Post Time, Rating, Deleted Flag

    All those are the data you are likely to find in a thread.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [RESOLVED] Forum Help - Thread/Post Storage

    And the title, of course.

    Mind you, I'd be inclined to omit the 'number of replies' field, and use an aggregate instead.

  7. #7
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: [RESOLVED] Forum Help - Thread/Post Storage

    Quote Originally Posted by penagate
    And the title, of course.

    Mind you, I'd be inclined to omit the 'number of replies' field, and use an aggregate instead.
    Duplication in favour of efficiency.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  8. #8
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [RESOLVED] Forum Help - Thread/Post Storage

    Bah. Not worth it for a count field.

  9. #9
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: [RESOLVED] Forum Help - Thread/Post Storage

    Certainly is - a single SQL query creates a lot of overhead. In a forum it is better to do that during the update rather than the recall.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  10. #10
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [RESOLVED] Forum Help - Thread/Post Storage

    Disagree. Row count is a quick lookup. Also, executing it as a single query would be foolish. It would be done as part of the query to fetch the list of threads for a forum. Nil overhead.

  11. #11
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: [RESOLVED] Forum Help - Thread/Post Storage

    If you are just fetching a list of threads you do not need a relational link to the posts table. If you want to count the number of posts in the thread you'd need to link up with the table and consequently deal with more records.

    Assuming anyone actually replies to the thread.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  12. #12

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: [RESOLVED] Forum Help - Thread/Post Storage

    ok thanks you guys for the replies, but this is just a tiny little forum for my small site. i dont need anything fancy. All deletes are deleted right away, i dont need any bells and whistles added.

    One table works fine for me.
    My usual boring signature: Something

  13. #13
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [RESOLVED] Forum Help - Thread/Post Storage

    Quote Originally Posted by visualAd
    If you want to count the number of posts in the thread you'd need to link up with the table and consequently deal with more records.
    Actually, you're right. I wasn't thinking, but you would need a predicate to count the replies. I suppose my logic only makes sense if each thread had its own table of replies, which would be idiocy.


    Quote Originally Posted by visualAd
    Assuming anyone actually replies to the thread.
    I'm sure dclamp can reply to his own threads.

  14. #14
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] Forum Help - Thread/Post Storage

    Why have a "forums" on a social networking site? Seems illogical.

    "RabidFriends" Is it a site for friends with th rabies?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  15. #15

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: [RESOLVED] Forum Help - Thread/Post Storage

    Quote Originally Posted by RobDog888
    "RabidFriends" Is it a site for friends with th rabies?
    deja-vu... yes, rabid people come together and talk about their stories...
    My usual boring signature: Something

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width