Convert a Relational Schema to MongoDB Schema

Hi, I am new here.
Can someone help me design a MongoDB schema for this relational schema.

Screenshot 2023-01-02 235821


One thing you can do is simply replicate a relational schema as a db of MongoDB collections.
It may not be “sexy” but it works!

1 Like

One thing is missing here is how you intend to query the data. A MongoDB data model should heavily consider the queries, here one strives to provide as much data in a single document (i.e a single query) to avoid “expensive” joins. This library model is very similar to a standard eCom model: customers, products, orders, payments. → students, books, loans, fines. There are plenty of articles on such data models.

However to show how a MongoDB schema might change as compared to RDBMS, I expect that query on loans to be a common need. A simple improvement could be to use imbedding - (duplicate) - to copy all the specific book info in the specific loan document. A query on a specific loan, likely gets the information needed.