From c31b7aa7f7e3a058b0ab4b6ceeb719579cf0fde4 Mon Sep 17 00:00:00 2001 From: Diego Freniche Date: Wed, 9 Oct 2024 21:11:56 +0200 Subject: [PATCH] Changed mapping rules --- .../10-edit-mapping-books-book-attribute.mdx | 5 ++-- ...edit-mapping-issue-detail-issue-detail.mdx | 6 ++++- .../110-add-mapping-reviews-user.mdx | 6 ++++- .../20-edit-mapping-books-book-genre.mdx | 23 ++++++++++++++++++- .../30-add-mapping-books-authors.mdx | 7 +++--- .../40-edit-mapping-books-author-book.mdx | 0 .../50-add-mapping-books-reviews.mdx | 5 +++- .../60-edit-mapping-authors-alias.mdx | 0 .../70-edit-mapping-authors-authorbook.mdx | 6 ++++- .../80-add-mapping-books-issue-detail.mdx | 6 ++++- .../90-add-mapping-issue-detail-users.mdx | 6 ++++- docs/80-edit-mapping-rules/_category_.json | 7 ++++++ 12 files changed, 65 insertions(+), 12 deletions(-) rename docs/{80-Edit Mapping Rules => 80-edit-mapping-rules}/10-edit-mapping-books-book-attribute.mdx (91%) rename docs/{80-Edit Mapping Rules => 80-edit-mapping-rules}/100-edit-mapping-issue-detail-issue-detail.mdx (74%) rename docs/{80-Edit Mapping Rules => 80-edit-mapping-rules}/110-add-mapping-reviews-user.mdx (74%) rename docs/{80-Edit Mapping Rules => 80-edit-mapping-rules}/20-edit-mapping-books-book-genre.mdx (70%) rename docs/{80-Edit Mapping Rules => 80-edit-mapping-rules}/30-add-mapping-books-authors.mdx (62%) rename docs/{80-Edit Mapping Rules => 80-edit-mapping-rules}/40-edit-mapping-books-author-book.mdx (100%) rename docs/{80-Edit Mapping Rules => 80-edit-mapping-rules}/50-add-mapping-books-reviews.mdx (88%) rename docs/{80-Edit Mapping Rules => 80-edit-mapping-rules}/60-edit-mapping-authors-alias.mdx (100%) rename docs/{80-Edit Mapping Rules => 80-edit-mapping-rules}/70-edit-mapping-authors-authorbook.mdx (77%) rename docs/{80-Edit Mapping Rules => 80-edit-mapping-rules}/80-add-mapping-books-issue-detail.mdx (74%) rename docs/{80-Edit Mapping Rules => 80-edit-mapping-rules}/90-add-mapping-issue-detail-users.mdx (74%) create mode 100644 docs/80-edit-mapping-rules/_category_.json diff --git a/docs/80-Edit Mapping Rules/10-edit-mapping-books-book-attribute.mdx b/docs/80-edit-mapping-rules/10-edit-mapping-books-book-attribute.mdx similarity index 91% rename from docs/80-Edit Mapping Rules/10-edit-mapping-books-book-attribute.mdx rename to docs/80-edit-mapping-rules/10-edit-mapping-books-book-attribute.mdx index 0782494..5a41e9f 100644 --- a/docs/80-Edit Mapping Rules/10-edit-mapping-books-book-attribute.mdx +++ b/docs/80-edit-mapping-rules/10-edit-mapping-books-book-attribute.mdx @@ -28,8 +28,9 @@ We want to clean up the book_attributes array in our MongoDB schema. We want an - Uncheck `bookId`. We just want all the attributes, which are key/value pairs. - Click `Save and close` -Here we've implemented the [Attribute Pattern](https://www.mongodb.com/developer/products/mongodb/attribute-pattern/) for MongoDB. - +:::info +Here we've implemented the [Attribute Pattern](https://www.mongodb.com/developer/products/mongodb/attribute-pattern/) for MongoDB. This will allow for easy indexing, querying based on attributes and extension of attributes. +::: diff --git a/docs/80-Edit Mapping Rules/100-edit-mapping-issue-detail-issue-detail.mdx b/docs/80-edit-mapping-rules/100-edit-mapping-issue-detail-issue-detail.mdx similarity index 74% rename from docs/80-Edit Mapping Rules/100-edit-mapping-issue-detail-issue-detail.mdx rename to docs/80-edit-mapping-rules/100-edit-mapping-issue-detail-issue-detail.mdx index 4369cfd..e5dafa3 100644 --- a/docs/80-Edit Mapping Rules/100-edit-mapping-issue-detail-issue-detail.mdx +++ b/docs/80-edit-mapping-rules/100-edit-mapping-issue-detail-issue-detail.mdx @@ -1,6 +1,10 @@ import Screenshot from "@site/src/components/Screenshot"; -# 👐 Edit mapping to issueDetails collection (from issue_details table) +# 🦸 Edit mapping to issueDetails collection (from issue_details table) + +:::info +Extra activity! Do it if you have extra time or are following along at home. It won't be covered during the hands-on lab. +::: Now we want to remove some unncessary id fields from the issueDetails collection diff --git a/docs/80-Edit Mapping Rules/110-add-mapping-reviews-user.mdx b/docs/80-edit-mapping-rules/110-add-mapping-reviews-user.mdx similarity index 74% rename from docs/80-Edit Mapping Rules/110-add-mapping-reviews-user.mdx rename to docs/80-edit-mapping-rules/110-add-mapping-reviews-user.mdx index e715ab3..00c22e7 100644 --- a/docs/80-Edit Mapping Rules/110-add-mapping-reviews-user.mdx +++ b/docs/80-edit-mapping-rules/110-add-mapping-reviews-user.mdx @@ -1,6 +1,10 @@ import Screenshot from "@site/src/components/Screenshot"; -# 👐 Add mapping to reviews collection (from users table) +# 🦸 Add mapping to reviews collection (from users table) + +:::info +Extra activity! Do it if you have extra time or are following along at home. It won't be covered during the hands-on lab. +::: We want to store each user's name against their reviews. diff --git a/docs/80-Edit Mapping Rules/20-edit-mapping-books-book-genre.mdx b/docs/80-edit-mapping-rules/20-edit-mapping-books-book-genre.mdx similarity index 70% rename from docs/80-Edit Mapping Rules/20-edit-mapping-books-book-genre.mdx rename to docs/80-edit-mapping-rules/20-edit-mapping-books-book-genre.mdx index b9aece5..0946217 100644 --- a/docs/80-Edit Mapping Rules/20-edit-mapping-books-book-genre.mdx +++ b/docs/80-edit-mapping-rules/20-edit-mapping-books-book-genre.mdx @@ -1,9 +1,30 @@ import Screenshot from "@site/src/components/Screenshot"; -# 👐 Add genres to books (not only genre ids) +# 👐 Change genres in books We want to modify the MongoDB schema so that each book's genres are represented as an array of strings. We'll have data duplication, as genres will get copied on each book. This is a good strategy if the duplicated data does not change often. +We'll go from the proposed array of objects: + +```json +bookGenres: [ + { + bookId: "Some Book Id", + genres: "fiction" + }, + { + bookId: "Some Book Id", + genres: "novel" + } +] +``` + +to an array of primitive values + +```json +genres: [ "fiction", "novel" ] +``` + - On the MongoDB diagram view, click the `books` collection - On the relational mappings list on the right, click on the edit icon of `book_genre` embedded array - Change the field name from `bookGenres` to `genres` diff --git a/docs/80-Edit Mapping Rules/30-add-mapping-books-authors.mdx b/docs/80-edit-mapping-rules/30-add-mapping-books-authors.mdx similarity index 62% rename from docs/80-Edit Mapping Rules/30-add-mapping-books-authors.mdx rename to docs/80-edit-mapping-rules/30-add-mapping-books-authors.mdx index e3cbd41..d8eff43 100644 --- a/docs/80-Edit Mapping Rules/30-add-mapping-books-authors.mdx +++ b/docs/80-edit-mapping-rules/30-add-mapping-books-authors.mdx @@ -3,7 +3,7 @@ import Screenshot from "@site/src/components/Screenshot"; # 👐 Add authors details to the books collection We want to modify the MongoDB schema so that each book contains an array of its authors. -In this step we will embed the book details into the empty array from the join table (which right now only contains `authorId` and `bookId`) +In this step we will embed the book details into the empty array created from the join table (which right now only contains `authorId` and `bookId`) - On the MongoDB diagram view, click the `books` collection - On the relational mappings list on the right, click `+ Add` @@ -13,8 +13,9 @@ In this step we will embed the book details into the empty array from the join t - Check the `id` and `name` fields and uncheck the rest - Click `Save and close` - - +:::info +This is a perfect example of the [Extended Reference Pattern](https://www.mongodb.com/blog/post/building-with-patterns-the-extended-reference-pattern). When we read a book, we have some of the author's data (`name` in this case) but we still have the author's id in case we need all the author's attributes (we can then do a join on read using `$lookup`) +::: diff --git a/docs/80-Edit Mapping Rules/40-edit-mapping-books-author-book.mdx b/docs/80-edit-mapping-rules/40-edit-mapping-books-author-book.mdx similarity index 100% rename from docs/80-Edit Mapping Rules/40-edit-mapping-books-author-book.mdx rename to docs/80-edit-mapping-rules/40-edit-mapping-books-author-book.mdx diff --git a/docs/80-Edit Mapping Rules/50-add-mapping-books-reviews.mdx b/docs/80-edit-mapping-rules/50-add-mapping-books-reviews.mdx similarity index 88% rename from docs/80-Edit Mapping Rules/50-add-mapping-books-reviews.mdx rename to docs/80-edit-mapping-rules/50-add-mapping-books-reviews.mdx index c33da33..219bfea 100644 --- a/docs/80-Edit Mapping Rules/50-add-mapping-books-reviews.mdx +++ b/docs/80-edit-mapping-rules/50-add-mapping-books-reviews.mdx @@ -3,7 +3,10 @@ import Screenshot from "@site/src/components/Screenshot"; # 👐 Add last three reviews to each book (from reviews table) We want to modify the MongoDB schema so that each book contains an array of its latest three reviews. -This is actually an implementation of the [Subset Pattern](https://www.mongodb.com/blog/post/building-with-patterns-the-subset-pattern). + +:::info +This is an implementation of the [Subset Pattern](https://www.mongodb.com/blog/post/building-with-patterns-the-subset-pattern). +::: In this step we will embed the book details into the empty array from the join table. diff --git a/docs/80-Edit Mapping Rules/60-edit-mapping-authors-alias.mdx b/docs/80-edit-mapping-rules/60-edit-mapping-authors-alias.mdx similarity index 100% rename from docs/80-Edit Mapping Rules/60-edit-mapping-authors-alias.mdx rename to docs/80-edit-mapping-rules/60-edit-mapping-authors-alias.mdx diff --git a/docs/80-Edit Mapping Rules/70-edit-mapping-authors-authorbook.mdx b/docs/80-edit-mapping-rules/70-edit-mapping-authors-authorbook.mdx similarity index 77% rename from docs/80-Edit Mapping Rules/70-edit-mapping-authors-authorbook.mdx rename to docs/80-edit-mapping-rules/70-edit-mapping-authors-authorbook.mdx index de49aa7..ffdaee7 100644 --- a/docs/80-Edit Mapping Rules/70-edit-mapping-authors-authorbook.mdx +++ b/docs/80-edit-mapping-rules/70-edit-mapping-authors-authorbook.mdx @@ -1,6 +1,10 @@ import Screenshot from "@site/src/components/Screenshot"; -# 👐 Edit mapping to authors collection (from author_book table) +# 🦸 Edit mapping to authors collection (from author_book table) + +:::info +Extra activity! Do it if you have extra time or are following along at home. It won't be covered during the hands-on lab. +::: We want to modify the authors collection to include an array of IDs representing their books. diff --git a/docs/80-Edit Mapping Rules/80-add-mapping-books-issue-detail.mdx b/docs/80-edit-mapping-rules/80-add-mapping-books-issue-detail.mdx similarity index 74% rename from docs/80-Edit Mapping Rules/80-add-mapping-books-issue-detail.mdx rename to docs/80-edit-mapping-rules/80-add-mapping-books-issue-detail.mdx index fc7b1ad..0ee2503 100644 --- a/docs/80-Edit Mapping Rules/80-add-mapping-books-issue-detail.mdx +++ b/docs/80-edit-mapping-rules/80-add-mapping-books-issue-detail.mdx @@ -1,6 +1,10 @@ import Screenshot from "@site/src/components/Screenshot"; -# 👐 Add mapping to issueDetails collection (from books table) +# 🦸 Add mapping to issueDetails collection (from books table) + +:::info +Extra activity! Do it if you have extra time or are following along at home. It won't be covered during the hands-on lab. +::: Now we want to store more details from each book into the collection tracking library loans. diff --git a/docs/80-Edit Mapping Rules/90-add-mapping-issue-detail-users.mdx b/docs/80-edit-mapping-rules/90-add-mapping-issue-detail-users.mdx similarity index 74% rename from docs/80-Edit Mapping Rules/90-add-mapping-issue-detail-users.mdx rename to docs/80-edit-mapping-rules/90-add-mapping-issue-detail-users.mdx index 8301cec..2bad5a1 100644 --- a/docs/80-Edit Mapping Rules/90-add-mapping-issue-detail-users.mdx +++ b/docs/80-edit-mapping-rules/90-add-mapping-issue-detail-users.mdx @@ -1,6 +1,10 @@ import Screenshot from "@site/src/components/Screenshot"; -# 👐 Add mapping to issueDetails collection (from users table) +# 🦸 Add mapping to issueDetails collection (from users table) + +:::info +Extra activity! Do it if you have extra time or are following along at home. It won't be covered during the hands-on lab. +::: Now we want to store more details from each user into the collection tracking library loans. diff --git a/docs/80-edit-mapping-rules/_category_.json b/docs/80-edit-mapping-rules/_category_.json new file mode 100644 index 0000000..d323057 --- /dev/null +++ b/docs/80-edit-mapping-rules/_category_.json @@ -0,0 +1,7 @@ +{ + "label": "👐 Edit Mapping Rules", + "link": { + "type": "generated-index", + "description": "." + } +} \ No newline at end of file