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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:19:23+00:00 2026-05-19T16:19:23+00:00

I have two tables/collections; Users and Groups. A user can be a member of

  • 0

I have two tables/collections; Users and Groups. A user can be a member of any number of groups and a user can also be an owner of any number of groups. In a relational database I’d probably have a third table called UserGroups with a UserID column, a GroupID column and an IsOwner column.

I’m using MongoDB and I’m sure there is a different approach for this kind of relationship in a document database. Should I embed the list of groups and groups-as-owner inside the Users table as two arrays of ObjectIDs? Should I also store the list of members and owners in the Groups table as two arrays, effectively mirroring the relationship causing a duplication of relationship information?

Or is a bridging UserGroups table a legitimate concept in document databases for many to many relationships?

Thanks

  • 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-19T16:19:24+00:00Added an answer on May 19, 2026 at 4:19 pm

    What I’ve seen done, and what I currently use are embedded arrays with node id’s in each document.

    So document user1 has property groups: [id1,id2]

    And document group1 has property users: [user1]. Document group2 also has property users: [user1].

    This way you get a Group object and easily select all related users, and the same for the User.

    This takes a bit more work when creating and updating the object. When you say 2 objects are related, you have to update both objects.

    There’s also a concept DBReferences in MongoDB and depending on your driver, it’ll pull referenced objects automatically when retrieving a document.

    http://www.mongodb.org/display/DOCS/Database+References#DatabaseReferences-DBRef

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

Sidebar

Related Questions

I have two tables: Users and Roles. A user may have more roles, so
I have two relational tables: the Profiles table which contains 3 kinds of user
I have two tables in my database, called ratings and movies . Ratings: |
I have two tables, one stores user sessions and the other stores shopping cart
I have two tables named USER and ROLE with entities as USER and ROLE
I have two tables like User and UserInfo UsersInfo UserId UserName Email Password LastLoginDate
I have two tables User and UserRole which are they connected using a link
I have two classes: User : /** @Entity @Table(name=users) */ class User { /**
I have two tables: Clients, and a join table that has user id, a
I have two tables, and they are using different collations. It is not allowed

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.