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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:02:37+00:00 2026-06-06T13:02:37+00:00

I am making a new application in MongoDB, and I have found that the

  • 0

I am making a new application in MongoDB, and I have found that the Document-oriented modeling style fits all of my models quite well.

However, my one stumbling block is a “CheckIn” style action. Users can check in at a location, and I need to store the following for each check in:

  • User ID
  • Place ID
  • Date of checkin

Now normally I’d just store this under the User document as an embed, but I frequently will want to ask the following questions:

  • Where are all places a user has checked in?
  • What are all checkins that have happened at a certain place?
  • All checkins for a given user-place combo?
  • All checkins for a user or place in a specific time frame?

In a relational database this screams has-many through, but in Mongo that’s not such an obvious relation. Should I just make Checkin a top-level object and take the performance hit of the join-style query? I might also need to add fields to the checkin object over time, so I want to keep the solution flexible.

  • 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-06T13:02:39+00:00Added an answer on June 6, 2026 at 1:02 pm

    Yes. If you embed checkins as an array within the user document, then the query “10 most recent checkins for a place” will be nearly impossible. Same if you embed in place, “10 most recent checkins for user” will be very hard. So make checkins its own collection.

    If you index both userid and placeid in the checkins collection your queries should be fast enough. For example, to find user Jesse’s most recent checkins, look up users by name to find Jesse’s _id, and query checkins for that userid. It’s just two queries. Same for a place’s most recent checkins.

    If you query the most recent checkins for a place and want the users’ names, you can first query the checkins collection to get the list of userids, and use an $in query to get all the user documents. Again, it’s just two queries, and both are fully indexed if you create the proper indexes.

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

Sidebar

Related Questions

Starting from the top, I am making an application that in the new project
Lately I've been making a new application and I'm using a ton of forms.
I'm making a new Mac OS X application. (not an iPhone app) This is
I'm new to Rails and making application where college members (teachers and students) can
I'm making a new game that generates a huge grid (lets say 1000x1000). The
We're in the middle of making a new e-commerce related PHP application and we
I'm making a sample GUI for a new application we are developing at work.
I'm starting a a new application, and want to concentrate on making it modular.
I'm making a new application and its basically filled with information about Warcraft. I
I have this application using CAL. All the modules derive from a special class,

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.