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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:41:33+00:00 2026-05-26T02:41:33+00:00

I just wanted to seek some advice on database design with mongoid and rails.

  • 0

I just wanted to seek some advice on database design with mongoid and rails.

If I have complex objects that need the ability to reference each other, would this be an appropriate solution.

class Tree
  include Mongoid::Document
  include Mongoid::Tree
end

class Group < Tree
end

class People < Tree
end

class Cars < Tree
end

etc...

So they can all belong to each other, be siblings or be children. Would this improve performance as they would all be in the same collection? Compared to if I was to use a habtm relationship between say 2, 3 or 4 models. Not entirely sure if separate models called in the same collection is faster or an appropriate design.

The main reason I tried this design was because I was reading the the idea behind nosql is to use nest objects to minimize calls to the database. Does it make any difference referencing a child object in the same collection compared to a separate collection? Or even across multiple collections?

There’s a few questions here but hopefully someone could help point me in the right direction 🙂

  • 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-26T02:41:33+00:00Added an answer on May 26, 2026 at 2:41 am

    yes, good choice! You want to use Inheritance like this to store them in the same collection.
    You’ll only have to access one collection – which should make it faster accessing children / parents.

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

Sidebar

Related Questions

Just wanted to know how you would do it. I have a webservice that
Just wanted some opinions on the matter. I have always used int flags, and
Just wanted opinions on a design question. If you have a C++ class than
Just wanted some quick help I'm 90% sure i need to use the (this)
Just wanted to know if anyone is really using Objects and Collections in Oracle
Just wanted to write some recursion but can't check if the child is in
Just wanted to know what would happen if in my book database i had
I've run across something that's bugging me just enough that I wanted to come
...just wanted to confirm that since the latest soundcloud api does not provide a
Just wanted a clear answer for a direct question -- google results have been

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.