1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How does db for a forum look like?

Discussion in 'Programming' started by Jangga, Jan 24, 2017.

Tags:
  1. Jangga

    Jangga Junior Member

    Joined:
    Aug 8, 2016
    Messages:
    149
    Likes Received:
    5
    Gender:
    Male
    Occupation:
    Freelancer: A reWriter
    Location:
    Africa
    Pls, I'm about to create a php code which will accept message messages from users, store in db, then can be read by admin & admin can reply the message. I want the message from user & admin's reply to appear like it's a thread(just like this thread you are viewing) so we can chat more.
    The problem is I don't know how the db will look like. Messages upon messages on a thread will enter a column in db? I'm so confused.

    I need insights on the db structure & possible assistance in writing the php code. Pls guy help me here.. I haven't work on a forum code before

    Plssssss
     
  2. Heisenberg

    Heisenberg Jr. VIP Jr. VIP

    Joined:
    Sep 11, 2014
    Messages:
    720
    Likes Received:
    375
    Occupation:
    Freelancer
    Location:
    Croatia
    Assign unique thread number to first post, all additional posts on same thread should carry the same number and then you can display them according to time or additional column for number of post. This is pretty simple, are you sure you are capable making it if you cant figure this out
     
  3. Jangga

    Jangga Junior Member

    Joined:
    Aug 8, 2016
    Messages:
    149
    Likes Received:
    5
    Gender:
    Male
    Occupation:
    Freelancer: A reWriter
    Location:
    Africa
    I understand you boss. But, I'm quite confused. The reply(s) to the thread should be on a new column or row?
     
  4. Heisenberg

    Heisenberg Jr. VIP Jr. VIP

    Joined:
    Sep 11, 2014
    Messages:
    720
    Likes Received:
    375
    Occupation:
    Freelancer
    Location:
    Croatia
    New row for each reply that has a column for thread id
     
  5. Jangga

    Jangga Junior Member

    Joined:
    Aug 8, 2016
    Messages:
    149
    Likes Received:
    5
    Gender:
    Male
    Occupation:
    Freelancer: A reWriter
    Location:
    Africa
    That means there can be hundreds of rows for a particular thread?
     
  6. Heisenberg

    Heisenberg Jr. VIP Jr. VIP

    Joined:
    Sep 11, 2014
    Messages:
    720
    Likes Received:
    375
    Occupation:
    Freelancer
    Location:
    Croatia
    Whats wrong with that? how exactly did you picture it? multiple columns in same row for reply1,reply2...?
     
  7. Jangga

    Jangga Junior Member

    Joined:
    Aug 8, 2016
    Messages:
    149
    Likes Received:
    5
    Gender:
    Male
    Occupation:
    Freelancer: A reWriter
    Location:
    Africa
    Lol yea....

    But, I'm wise now. Thanks to you. If I run into any probs when writing the code, I'll inbox u for some help. Pls can u pm me ur skype or u prefer I continue sending the question here if I run into probs
     
  8. chillerfx

    chillerfx Jr. VIP Jr. VIP

    Joined:
    Mar 20, 2012
    Messages:
    247
    Likes Received:
    66
    Occupation:
    Graphic Designer, Web-dev and Digital Marketer.
    Location:
    Everywhere on net.
    Home Page:
    Hi Jangga,

    You have to add one field to maintain main thread reference id for your messages table.
    If user or admin replied to any thread/post, a new row will insert into your message table with the reference id of main thread id. It will help you to get all the posts (main thread and its all replies) based on a condition (WHERE id = 1 OR reference_id = 1).

    Note:
    Don't maintain all replies in the same row. It will reduce your query performance and raise some issues based on your future updates.
     
  9. Heisenberg

    Heisenberg Jr. VIP Jr. VIP

    Joined:
    Sep 11, 2014
    Messages:
    720
    Likes Received:
    375
    Occupation:
    Freelancer
    Location:
    Croatia
    I'd prefer if you post here, that way anyone facing similar problems in future can see answers here.
     
    • Thanks Thanks x 1
  10. bartosimpsonio

    bartosimpsonio Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 21, 2013
    Messages:
    12,748
    Likes Received:
    11,414
    Occupation:
    COINZ
    Location:
    BUYAH
    Home Page:
    Download a free forum platform and install it on your local machine. Then open some mysql tool and play with it.
     
    • Thanks Thanks x 2