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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:06:11+00:00 2026-06-02T16:06:11+00:00

i am writing an application using mongodb in which user can send messages to

  • 0

i am writing an application using mongodb in which user can send messages to each other here are the fields i want to store

user_to
user_from
message
sent
ip
unread

what i am asking is if user A sends msg to user B for eg:

user_to : B,
user_from : A,
message :hello world,
sent:1334901545,
ip : XX.XX.XX.X,
unred : true

this is the format how data is stored for first time but when again user A sends message to user B how should i store that data should ??
i have thought of two ways please tell me which is most efficient

user_to : B,
user_from : A,
message :hello world again,
sent:1334901745,
ip : XX.XX.XX.X,
unred : true

or

user_to : B,
user_from : A,
messages : array(
array(message="hello world",sent="1334901545",ip: XXX.X.XX.XX,unread:true),
array(message="hello world again",sent="1334901745",ip:XX.XX.XX.X,unread:true )
)

first type is very simple in structure better for querying and very easy to analyse but i think it increase duplicate data and will consume larger disk space as application grows

whereas second type eliminates duplicate record and low on disk space but it complicates data retrieval difficult to read cannot be used efficiently to write amd many other complication

i just want to know which is the right way considering mongodb is highly scaleable should i go for simplicity or eliminate duplicate records and save disk space

  • 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-06-02T16:06:12+00:00Added an answer on June 2, 2026 at 4:06 pm

    Separate records will be better for query speed, I would go with that. Also in your example there is not so much redundant data. If there was you could always factor it out into a new collection.

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

Sidebar

Related Questions

I'm writing web application using codeigniter framework. Here is the structure of document root
I'm currently writing an application using Vala that requires me to send data over
I'm writing a web application using Spring/Hibernate that displays a report to a user,
I'm writing an application using Seam 2.2.x which will be deployed on JBoss 5.1.
I'm writing a small application using GWT and JDOs to store persistent data. I've
I am writing one web application using PHP/CodeIginter. Now, I want to add a
I am writing application using c++, in windows. I want to get a thumbnail
I am writing an application using Core Data which heavily depends on setting attributes
I'm writing an application using Python that adds videos to a user's playlist on
I am writing an application using cocoa which, in some point (surprise), opens window.

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.