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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:22:57+00:00 2026-05-21T11:22:57+00:00

For a library, I need to keep track of users and books. Basically I

  • 0

For a library, I need to keep track of users and books. Basically I need to be able to know:

  • the list of books currently borrowed by a user
  • the current borrower of a given book

The app is done with node.js and mongoDB (with moogoose). I have the following schema:

BookSchema = new Schema({
  title        : String,
  author : String,
  current_borrower_email: String,
});
mongoose.model('Book', BookSchema);

// Define User model
UserSchema = new Schema({
  lastname  : String,
  firstname  : String,
  email     : String,
  books    : [BookSchema]  // Books the user is borrowing
});
mongoose.model('User', UserSchema);

I guess this would be simplier to set this up in a relational DB where I could easily use many to many relation ships with foreign keys but I wanted to give a try to MongoDB.

Do you think this solution could work ? Also, if I delete a Book object, it seems I will have to remove it manually from the array of the user who borrowed it, it that right ?

  • 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-21T11:22:57+00:00Added an answer on May 21, 2026 at 11:22 am

    In general mongodb will be good replacement of relational database for above task.

    So some basics:
    1.Once some one take a book you just need to copy book into the nested collection of user and user to the Book.
    2.Once user has updated his profile you need aslo update information about user within Book.
    3.Once book data was changed you also need update info about book within user.
    4.If you trying to delete some book and current borrower exists you should say that book was borrowed by ‘User’ and not delete it.

    I just suggest to add into your schema instead of current_borrower_email entire User object -> current_borrower: UserSchema.

    So with such denormalized schema you will able easy show(within one request to mongodb):

    • the list of books currently borrowed by a user.
    • the current borrower of a given book
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some library which would be able to keep my urls Indexed and
I need OCR library(preferably in Java), which will be able to determine digit visualized
I'm writing an application that keep track of a library of music, and I
I'm relatively new to Ruby. I need to keep track of a day of
I am thinking of creating a video library software which keep track of all
I need a library to handle JSON objects in Ruby. There are two gems
I need a library to read 2D barcode (datamatrix) from images on C# project
I need a Java library to convert PDFs to TIFF images. The PDFs are
I need a C# library to deal with matrices. It should implement singular value
I need a Python library that supports PEM files and both RSA signing and

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.