Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7056449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:52:06+00:00 2026-05-28T03:52:06+00:00

I have a Private messaging system using PHP and mySQL with notification. The database

  • 0

I have a Private messaging system using PHP and mySQL with notification.

The database table has following fields(not all listed) — message_tbl:

MessageID
senderUserID
RecUserID
Message
Subject
DateTime
Status - whether read or not i.e 0/1

All replies are stored in a second table, since each message creates a thread. A thread exist within the parent message, so everytime a parent message is loaded all its replies also are loaded with it.
The second table looks a bit like this: – replies_tbl

messageID - FK
senderUserID
rstatus - how should i use this?
Mesage
DateTime

I need to show count of all the unread messages.
At the moment i run a sql count function to get total unread messages from the message_tbl where status is 0 and userid equal to RecUserID, the easy part.

But i have a small issue is how to get count for the replies table? Can the database design be improved?

thanks guys.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:52:07+00:00Added an answer on May 28, 2026 at 3:52 am

    As I see it, a reply is, itself, a message, so why is it going into a separate table. What happens with a reply to a reply? It would seem you would have a null FK at that point.

    My first thought is:

    • Add ParentID column to Messages table
    • Set ParentID to 0 for root messages
    • Set ParentID to the MessagesID if it’s a reply

    With that structure, you could easily track replies to replies and the thread could continue as deep as you wanted it to …

    Just my thoughts, though …

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Take facebook's private messaging system where you have to keep track of sender and
I have a private messaging system and would like to have about 4-5 links
Backgroun: I'm trying to build a private messaging system in Mysql with conv view.
I currently have the following tables for a private messaging forum: alt text http://img159.imageshack.us/img159/45/pmdata.jpg
I am coding a website in PHP and Javascript which implements private messaging functionality,
I have recently found a hole in my SELECT statement for a private messaging
I'm designing a C#/NHibernate website that features a private messaging system. I would like
I'm currently working on my private messaging system for my website and so far
I am currently working on a private messaging system. Right now I'm coding the
I'm trying to create a single table for private messaging on a website. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.