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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:32:03+00:00 2026-06-04T08:32:03+00:00

I need some advice on MongoDB schema design for a natural language database. I

  • 0

I need some advice on MongoDB schema design for a natural language database.

I need to store for each language texts and words like:

lang: {
    _id: "English",
    texts : [
        {   text : "This is a first text", 
            date : Date("2011-09-19T04:00:10.112Z"),
            tag : "test1"
        },
        {   text : "Second One", 
            date : Date("2011-09-19T04:00:10.112Z"),
            tag : "test2"
        }
    ],
    words : [
        {   
            word : "This",
        },
        {   
            word : "is",
        },
        {   
            word : "a",
        },
        {   
            word : "first",
        },
        {   
            word : "text",
        },
        {   
            word : "second",
        },
        {   
            word : "one",
        }


    ]

}

And then I need to know each words and texts a user has associated. The word/text amount tends to be huge and I need to list all words on a language and all words a user has associated for that language.

From my perspective I think storing the user_ids that are associated with a given word in an array for the word is maybe a good approach like:

lang: {
    _id: "English",
    texts : [
                ...
    ],
    words : [
        {   
            word : "This",
            users: [user1,user2,user3]
        },
        {   
            word : "is",
                users: [user1,user2]
                },
                ...
    ]
}

Having in mind that a word can be associated to hundreds of thousand of users and the document limit (as I read) is 4MB and that I need to:

  1. List all words for a given user and language

Is this a good approach? Or can you think of a better one?

Hope this question is clear enough and that someone can give me a help on this 😉

Thank you all!

  • 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-04T08:32:04+00:00Added an answer on June 4, 2026 at 8:32 am

    I don’t think this is a good approach, for just the reason you mention: the document size limit. It looks like with your approach, you are definitely going to run up against the limit. I would go for a flatter approach (which should also make your collection easier to query). Something like this:

    [
        {
            user: "user1",
            word: "This",
            lang: "en"
        },
        {
            user: "user1",
            word: "is",
            lang: "en"
        },
        // et cetera...
    ]
    

    In other words, grow vertically by adding documents rather than horizontally by adding more data to one document. You can query words for a given user with db.find( { user: “user1”, lang: “en” });.

    This approach isn’t “normalized”, of course, so if you’re concerned about space then you might want to create a separate collection for users, words, and languages and reference them in the main collection by an ID. But since there are no join queries in MongoDB, you have to weigh query performance against space efficiency.

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

Sidebar

Related Questions

I need some advice on a little project im doing. I have a database
I need some advice about the design on my app. I have several screens
I need some advice on what kind of pattern(s) I should use for pushing/pulling
I need some advice from experts :) I will develop a website using PHP
I need some advice, what is the rule of the thumb when creating Rails
I need some advice on techniques to perform page redirect in asp.net. Which one
I need some advice in creating and ordering indexes in mongo. I have a
I need some advice before I start. My PHP Skills are only 3 months
Experts - I need some advice in the following scenario. I have a configuration
I just need some advice on if this is wise. I'm loading my site

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.