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 6944637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:19:58+00:00 2026-05-27T13:19:58+00:00

I want to create a simple Messaging System on my LAMP site. Not an

  • 0

I want to create a simple Messaging System on my LAMP site. Not an instant messaging System, but an asyncronous messaging system, like a very simple form of e-mail.

In the Database, should I:

A) create one table for the Inbox (receiver) and one table for Sent (sender), so that when a receiver deletes the message from their Inbox, the sender can still see it in their Sent folder,

or

B) create just one table, and then add a column for whether the Receiver/Sender has deleted it or not and then display it accordingly to each user based on that?

I would also like to keep track of whether the receiver has read it and whether they have replied to it or not.

Option B seems more efficient since you are not essentially duplicating a table, but I’m wondering if there are any potential issues with that method that I’m not thinking about.

So, which option do you recommend, A), B) or something else, and why?

  • 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-27T13:19:58+00:00Added an answer on May 27, 2026 at 1:19 pm

    I would create it as a single table with something like:

    ID
    FromID
    ToID
    Message
    

    An additional table that linked users to messages would be used to determine who has read what (the sender automatically being linked to that message, for example).

    UserID
    MessageID
    

    Essentially, if a user has read a message, they’ll have an entry in this table.

    Doing it this way gives us a single view for all users. Someone’s inbox is basically any message in the table where they are the recipient, and there sent box is any message where they are the sender.

    My InBox:

    SELECT * FROM Messages WHERE FromID = @MyID
    

    My OutBox:

    SELECT * FROM Messages WHERE ToID = @MyID
    

    My Unread messages:

    SELECT * FROM Messages
    WHERE ToID = @MyID
    AND ID NOT IN (SELECT MessageID FROM MessagesRead WHERE UserID = @MyID)
    

    This is far simpler, imho than trying to use two tables that are basically doing the same thing. And you’d be replicating the From and To in both tables, but in reverse and we’d have 2 copies of the message floating around when we only needed one. Using an additional MessagesRead table allows us to track who has read what.

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

Sidebar

Related Questions

I want to create simple form using CForm (yii framework) but 'elements' => array('username'=>array('type'=>'text'))
I want to create simple application like android image gallery but I don't want
I want to create a simple user registration form with First / Last name,
I want to create a simple transaction on my Web Site where after the
I want to create simple charts like pies and bars in python. I tried
I want to create simple form to validate each row of mysql_fetch_array if it's
I want to create simple poll system. I have two question and two answers.
i want create one simple windows form ,it just contain Editcontrol(textbox),Static Edit(label),Button (Name of
I want to create simple factory class which implements interface like this: IFactory {
I want to create simple login system using the SQLLIte I have created the

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.