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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:15:11+00:00 2026-05-26T12:15:11+00:00

I am trying to store word frequency data using Mongo. Each word needs to

  • 0

I am trying to store word frequency data using Mongo. Each word needs to be associated to a user so I can calculate how often an individual uses each word. Currently my words collection looks like this:

{'Hello':3, 'user_id':1}

Which obviously only works on a ‘One To One’ basis and is no good.

I am trying to work out how best to make this a ‘One To Many’ relationshop between the user and the words. Would I store the user relationship in my words collection like so:

{'word':"Hello", 'users':[{'id':1, 'count':4},{'id':2, 'count':10}]}

Or would I attach the word counts to the user collection instead?

{'id':1, 'username':'SomeUser', 'words':[{'Hello':4}]}

The obvious disadvantage to the second approach is that the same words will be used across different users, so having a single words collection would help to keeping the data size down.

Can anyone advise me as to what I should do here? Is there a method I have perhaps overlooked in the documentation?

  • 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-26T12:15:12+00:00Added an answer on May 26, 2026 at 12:15 pm

    The obvious disadvantage to the second approach is that the same words
    will be used across different users, so having a single words
    collection would help to keeping the data size down.

    Nope, that’s the nature of using document db. Data size is really not a matter in non sql solutions, important thing is how easy and how fast you can access your data.

    Your first approach is a typical textbook relational model. There is no advantage of using this in mongo (Though you can model this in relational way in mongo). Instead the second approach gives you

    • Fatser reads/writes since every word is stored inside user. You dont need to perform multiple queries for this
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to store more than 1 data item at a single index
I'm trying to store data in the following fashion with a string as the
I'm trying to find a nice way to store word compositions of the following
I am trying to get a program to let a user enter a word
I've noticed a peculiarity when trying to store 2003 MS word documents within a
I'm creating a word search and am trying to calculate quality of the generated
What I’m trying to do: Build a mobile web application where the user can
I'm trying to store a password in a file that I'd like to retrieve
I'm trying to store an xml serialized object in a cookie, but i get
I am trying to store an xml value in my app.config file. The app.config

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.