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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:59:24+00:00 2026-05-30T04:59:24+00:00

I have 1 collection called Visit , in it I save documents with information

  • 0

I have 1 collection called Visit, in it I save documents with information about visit referrer, page, keyword, dates, so on.

I think Keyword can be considered a collection on it’s own, the same for Page.
This will force me to create different collections but I’m not sure if this is the right way to go.

In a traditional DB model, they will clearly be stored in separate tables connected with FK.

  • But what about mongo ?
  • Is it a good practice for keys to have the same value over and over again for different documents and just create a collection in this case ?
  • 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-30T04:59:25+00:00Added an answer on May 30, 2026 at 4:59 am

    One of the benefits of MongoDB is its ability to embed documents.

    It is perfectly reasonable for the documents in your Visits collection to contain Keyword and Page Sub-Documents.

    The rule of thumb is embed documents for speed, normalize documents for consistency.

    If you embed the Keyword and Page documents in your Visit document, your application will only have to make one query to retrieve all of the relevant information. (speed)

    However, the drawback is that if the Keyword and/or Page information is updated, it will have to be updated in every other Visit document where it appears. If many different Visit documents will rely on the same Keyword and Page documents, it may be better to keep them in a separate collection, especially if they will be changed frequently. (consistency)

    This is of course a generalization, and ultimately it is up to you, the application developer to decide which works best for your unique situation. There is additional information on Embedding versus Linking in the Mongo Document titled “Schema Design”
    http://www.mongodb.org/display/DOCS/Schema+Design

    You may also find the article “MongoDB Data Modeling and Rails” to be beneficial:
    http://www.mongodb.org/display/DOCS/MongoDB+Data+Modeling+and+Rails
    The example is given in Rails, but the theory on Document design applies to any language.

    Good luck!

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

Sidebar

Related Questions

I have a collection of items called RegisteredItems. I do not care about the
In MongoDB I have a collection of documents called 'clients', where each document is
I have a MongoDB collection called employees where there are documents like this: {
I have a Mongo collection called documents which has the following structure: { name:
We have installed TFS 2010 RC. By default it creates a project collection called
I have a collection of an object called Bookmarks which is made up of
I have a collection of about 8,000 test scores in an XML file. Using
I have a collection called Albums with objects from the class Album . This
I have a collection called contract and I would like to group using a_id
I have a collection of Book objects called book. The Book class has a

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.