Skip to content

Commit c31b7aa

Browse files
committed
Changed mapping rules
1 parent 04e3708 commit c31b7aa

12 files changed

+65
-12
lines changed

docs/80-Edit Mapping Rules/10-edit-mapping-books-book-attribute.mdx renamed to docs/80-edit-mapping-rules/10-edit-mapping-books-book-attribute.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ We want to clean up the book_attributes array in our MongoDB schema. We want an
2828
- Uncheck `bookId`. We just want all the attributes, which are key/value pairs.
2929
- Click `Save and close`
3030

31-
Here we've implemented the [Attribute Pattern](https://www.mongodb.com/developer/products/mongodb/attribute-pattern/) for MongoDB.
32-
31+
:::info
32+
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.
33+
:::
3334

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

docs/80-Edit Mapping Rules/100-edit-mapping-issue-detail-issue-detail.mdx renamed to docs/80-edit-mapping-rules/100-edit-mapping-issue-detail-issue-detail.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import Screenshot from "@site/src/components/Screenshot";
22

3-
# 👐 Edit mapping to issueDetails collection (from issue_details table)
3+
# 🦸 Edit mapping to issueDetails collection (from issue_details table)
4+
5+
:::info
6+
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.
7+
:::
48

59
Now we want to remove some unncessary id fields from the issueDetails collection
610

docs/80-Edit Mapping Rules/110-add-mapping-reviews-user.mdx renamed to docs/80-edit-mapping-rules/110-add-mapping-reviews-user.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import Screenshot from "@site/src/components/Screenshot";
22

3-
# 👐 Add mapping to reviews collection (from users table)
3+
# 🦸 Add mapping to reviews collection (from users table)
4+
5+
:::info
6+
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.
7+
:::
48

59
We want to store each user's name against their reviews.
610

docs/80-Edit Mapping Rules/20-edit-mapping-books-book-genre.mdx renamed to docs/80-edit-mapping-rules/20-edit-mapping-books-book-genre.mdx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,30 @@
11
import Screenshot from "@site/src/components/Screenshot";
22

3-
# 👐 Add genres to books (not only genre ids)
3+
# 👐 Change genres in books
44

55
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.
66

7+
We'll go from the proposed array of objects:
8+
9+
```json
10+
bookGenres: [
11+
{
12+
bookId: "Some Book Id",
13+
genres: "fiction"
14+
},
15+
{
16+
bookId: "Some Book Id",
17+
genres: "novel"
18+
}
19+
]
20+
```
21+
22+
to an array of primitive values
23+
24+
```json
25+
genres: [ "fiction", "novel" ]
26+
```
27+
728
- On the MongoDB diagram view, click the `books` collection
829
- On the relational mappings list on the right, click on the edit icon of `book_genre` embedded array
930
- Change the field name from `bookGenres` to `genres`

docs/80-Edit Mapping Rules/30-add-mapping-books-authors.mdx renamed to docs/80-edit-mapping-rules/30-add-mapping-books-authors.mdx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Screenshot from "@site/src/components/Screenshot";
33
# 👐 Add authors details to the books collection
44

55
We want to modify the MongoDB schema so that each book contains an array of its authors.
6-
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`)
6+
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`)
77

88
- On the MongoDB diagram view, click the `books` collection
99
- 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
1313
- Check the `id` and `name` fields and uncheck the rest
1414
- Click `Save and close`
1515

16-
17-
16+
:::info
17+
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`)
18+
:::
1819

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

File renamed without changes.

docs/80-Edit Mapping Rules/50-add-mapping-books-reviews.mdx renamed to docs/80-edit-mapping-rules/50-add-mapping-books-reviews.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import Screenshot from "@site/src/components/Screenshot";
33
# 👐 Add last three reviews to each book (from reviews table)
44

55
We want to modify the MongoDB schema so that each book contains an array of its latest three reviews.
6-
This is actually an implementation of the [Subset Pattern](https://www.mongodb.com/blog/post/building-with-patterns-the-subset-pattern).
6+
7+
:::info
8+
This is an implementation of the [Subset Pattern](https://www.mongodb.com/blog/post/building-with-patterns-the-subset-pattern).
9+
:::
710

811
In this step we will embed the book details into the empty array from the join table.
912

File renamed without changes.

docs/80-Edit Mapping Rules/70-edit-mapping-authors-authorbook.mdx renamed to docs/80-edit-mapping-rules/70-edit-mapping-authors-authorbook.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import Screenshot from "@site/src/components/Screenshot";
22

3-
# 👐 Edit mapping to authors collection (from author_book table)
3+
# 🦸 Edit mapping to authors collection (from author_book table)
4+
5+
:::info
6+
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.
7+
:::
48

59
We want to modify the authors collection to include an array of IDs representing their books.
610

docs/80-Edit Mapping Rules/80-add-mapping-books-issue-detail.mdx renamed to docs/80-edit-mapping-rules/80-add-mapping-books-issue-detail.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import Screenshot from "@site/src/components/Screenshot";
22

3-
# 👐 Add mapping to issueDetails collection (from books table)
3+
# 🦸 Add mapping to issueDetails collection (from books table)
4+
5+
:::info
6+
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.
7+
:::
48

59
Now we want to store more details from each book into the collection tracking library loans.
610

0 commit comments

Comments
 (0)