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

  • SEARCH
  • Home
  • 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 6757065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:36:07+00:00 2026-05-26T13:36:07+00:00

Which of the following db design would be preferable for an internal messaging system.

  • 0

Which of the following db design would be preferable for an internal messaging system.

Three tables:

MessageThread(models.Model):
    - subject
    - timestamp
    - creator

Message(models.Model):
    - thread (pk)
    - content
    - timestamp
    - sender

MessageRecipient
    - message_id (pk)
    - recipient (pk)
    - status (read, unread, deleted)

Two tables:

Message
    - thread_id
    - subject
    - content
    - timestamp
    - sender (fk)

MessageRecipient
    - message_id (fk)
    - recipient (fk)
    - status (read, unread, deleted)

What would be the advantages of one over another?

  • 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-26T13:36:07+00:00Added an answer on May 26, 2026 at 1:36 pm

    Strengths of the first

    The first schema obeys better normalization rules, and so is probably better in most cases.

    Having a thread_id, which is basically a natural key, that isn’t a FK to another table is probably asking for trouble. It will be very difficult to enforce that it is unique when you want it to be, and the same when you want it to be. For this reason, I would encourage the first suggested schema.

    Strengths of the second

    Your second schema allows the subject to be altered for each message in the thread. If this is a feature you want, you can’t use the first option, as you’ve written it (but see below).

    Other options

    Message
        - id
        - parent (fk to Message.id)
        - subject
        - content
        - timestamp
        - sender (fk)
    
    MessageRecipient
        - message_id (fk)
        - recipient (fk)
        - status (read, unread, deleted)
    

    Instead of having a thread_id concept, you can intead have a parent concept. Then every reply will point to the original message’s record. This allows threading, without a ‘thread’ table. Another possible advantage of this, is it allows thread trees as well. Simply put, you can represent much more complicated relationships between messages and replies this way. If you don’t care about that, then this won’t be a bonus for your application.

    If you don’t care about the threading advantages I just mentioned, I would probably recommend a hybrid of your two schemas:

    MessageThread(models.Model):
        - id
    
    Message(models.Model):
        - thread (pk)
        - subject
        - content
        - timestamp
        - sender
    
    MessageRecipient
        - message_id (pk)
        - recipient (pk)
        - status (read, unread, deleted)
    

    This is similar to first schema, except that I moved the ‘subject’ column from the MessageThread to the Message table, to allow the subject to change as the thread progresses… I’m simply using the MessageThread table to act as a constraint on the thread ID used in Message (which overcomes the limitations I mentioned at the beginning of my answer). You may have additional meta data you want to include in the MessageThread table as well, but I’ll leave that up to you and your application.

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

Sidebar

Related Questions

I would like to get the stackoverflow community's opinion on the following three design
I am supposed to design a component which should achieve the following tasks by
In the book of application architecture design, which I'am reading, I've found the following
Problem: I have to design an algorithm, which does the following for me: Say
Consider following tables and java classes to phrase the problem for which I seeking
What would be the best way to design a mysql table, which can be
For converting a Java object model into XML I am using the following design:
I use JEditable for making edit field which following code: $(function() { $(.field).editable(http://localhost/index.php/welcome/update_record, {
I use the following which works perfectly in all browsers, except ie9 $result =
I found the following which shows how to delete an attribute from XML in

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.