You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cosmos-db/sql/modeling-data.md
+13-20Lines changed: 13 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ ms.author: mjbrown
7
7
ms.service: cosmos-db
8
8
ms.subservice: cosmosdb-sql
9
9
ms.topic: conceptual
10
-
ms.date: 08/26/2021
10
+
ms.date: 02/15/2022
11
11
12
12
---
13
13
# Data modeling in Azure Cosmos DB
@@ -113,7 +113,7 @@ Take this JSON snippet.
113
113
}
114
114
```
115
115
116
-
This might be what a post entity with embedded comments would look like if we were modeling a typical blog, or CMS, system. The problem with this example is that the comments array is **unbounded**, meaning that there's no (practical) limit to the number of comments any single post can have. This may become a problem as the size of the item could grow infinitely large.
116
+
This might be what a post entity with embedded comments would look like if we were modeling a typical blog, or CMS, system. The problem with this example is that the comments array is **unbounded**, meaning that there's no (practical) limit to the number of comments any single post can have. This may become a problem as the size of the item could grow infinitely large so is a design you should avoid.
117
117
118
118
As the size of the item grows the ability to transmit the data over the wire as well as reading and updating the item, at scale, will be impacted.
This model has the three most recent comments embedded in the post container, which is an array with a fixed set of attributes. The other comments are grouped in to batches of 100 comments and stored as separate items. The size of the batch was chosen as 100 because our fictitious application allows the user to load 100 comments at a time.
147
+
This model has a document for each comment with a property that contains the post id. This allows posts to contain any number of comments and can grow efficiently. Users wanting to see more
148
+
than the most recent comments would query this container passing the postId which should be the partition key for the comments container.
156
149
157
150
Another case where embedding data isn't a good idea is when the embedded data is used often across items and will change frequently.
0 commit comments