Skip to content

Commit

Permalink
Added some explanation to relational and MongoDB schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreniche committed Jul 1, 2024
1 parent 4f476bb commit 75c987b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/30-schema-in-postgresql.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import Screenshot from "@site/src/components/Screenshot";

# 📘 Schema in PostgreSQL

The following screenshot shows an Entity-Relationship diagram of the relational database we wish to migrate.
The following screenshot shows an Entity-Relationship diagram of the relational database we wish to migrate. This is a Library management app, that stores information about Books, where a Book can have many Authors, an Author can write many books, users can borrow books and leave reviews.

This is the sample schema we use during our [Developer Days's Intro Lab](https://mongodb-developer.github.io/intro-lab/docs/importing-data/intro).

<Screenshot url="https://www.mongodb.com/products/tools/relational-migrator" src="img/30-image-001.png" alt="Screenshot of the connect modal" />
5 changes: 5 additions & 0 deletions docs/40-desired-schema-mongodb.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ that data that is frequently accessed together is stored together by using embed
The following screenshot shows the MongoDB schema we will be creating in this lab.

<Screenshot url="https://www.mongodb.com/products/tools/relational-migrator" src="img/40-image-001.png" alt="Screenshot of the connect modal" />

A few key points:
- books will contain an array of authors with author id and name for fast retrieval. This is using the [Extended Reference Pattern](https://www.mongodb.com/blog/post/building-with-patterns-the-extended-reference-pattern) to reference a separate Collection (Authors) but having in books enough information aubout the author.
- reviews are not included in the books collection as they can grow and become an [unbounded array](https://www.mongodb.com/developer/products/mongodb/schema-design-anti-pattern-massive-arrays/), an atipattern in Schema Design.
- an author can have several aliases, we just store those strings in an array.

0 comments on commit 75c987b

Please sign in to comment.