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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:28:04+00:00 2026-05-20T11:28:04+00:00

I was curious about how the MongoDB plugin for Grails would handle relationships. In

  • 0

I was curious about how the MongoDB plugin for Grails would handle relationships. In order to test this I made a very simple application with two domain classes:

Authors have two fields: String firstName and String lastName

Books have two fields: String title and Author author

After setting up MongoDB and Grails I made some Authors and Books and took a peek using the MongoDB interactive shell. What I found is that the relationships were being handled the same way they would be handled in a relational database: references to other objects’ id fields.

So now for the questions:

  1. In order for GORM to pull this off, does it need a separate connection to retrieve each document?
  2. If yes, wouldn’t this be better off in a relational database such as PostgreSQL or MySQL?
  3. If the answer to the above two questions is indeed ‘yes,’ then is there a better way to manage relationships in a document database such as MongoDB? I realize MongoDB isn’t supposed to be relational, but there are some things that I don’t see how to get around relationships without duplicating data (thereby making update nightmares).

Edit: I also just noticed that grails is not sorting properly on the ‘id’ property of my authors. Does this have to do with using MongoDB? In the shell I can see that the _id property of all the documents made by Grails is of the datatype NumberLong.

  • 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-20T11:28:05+00:00Added an answer on May 20, 2026 at 11:28 am

    I realize MongoDB isn’t supposed to be relational, but there are some things that I don’t see how to get around relationships without duplicating data

    Then don’t sweat it. MongoDB is not anti-relational, it’s document-oriented.

    In this case, Books and Authors are two top-level objects. It’s not reasonable to nest either of them, they are both core entities in their own right.

    In the case of each Book having only one Author (N:1), it’s completely reasonable for the Book to contain a “Reference To” the Author. Sure you’ll have to do two queries. But is that terribly different from doing a join query? The join query still has to do two index look-ups and two data lookups. So you’re not really costing yourself anything here.

    In the case of each Book supporting multiple Authors (M:N), then you have several options based on your needs.

    I don’t like to think of MongoDB as “not relational”, I think it’s cleaner to think of MongoDB as query-optimized.

    I also just noticed that grails is not sorting properly on the ‘id’ property of my authors…

    I would check directly with the Grails author. Sounds like they may be storing “strings” instead of actual ObjectIds (or MongoIDs). While not critical this may be a bug.

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

Sidebar

Related Questions

Curious about how developers more experienced with Django than I might handle this: I
I'm curious about this quote from Kyle Banker's MongoDB In Action: It’s important to
I'm curious about the correct way to architect an application that consists of the
I am curious about git add action, so I do some test. create a
I am a bit curious about how this works - if I have 5
I'm curious about what be the best way to model this for optimized performance...
I'm curious about what I'm not understanding in this code snippet... Why does this
Curious about user notification techniques. Referring to simple stuff. For example, a user submit's
Curious about how the handle STDERR works? Lets keep it down to say Batch
Just curious about which of these would be faster? $('ul.dropdown a').first().click(function(event) { event.stopPropagation(); return

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.