Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
[第2回 Azure Cosmos DB 勉強会] Data modelling and partitioning in Azure Cosmos DB (Azure Cosmos DB でのデータモデリングとパーティション分割)
Search
SATO Naoki (Neo)
September 13, 2020
Technology
0
790
[第2回 Azure Cosmos DB 勉強会] Data modelling and partitioning in Azure Cosmos DB (Azure Cosmos DB でのデータモデリングとパーティション分割)
https://satonaoki.wordpress.com/2020/09/13/jcdug-cosmos-db-data-modeling/
SATO Naoki (Neo)
September 13, 2020
Tweet
Share
More Decks by SATO Naoki (Neo)
See All by SATO Naoki (Neo)
LLMOps with Azure Machine Learning prompt flow
satonaoki
1
240
マルチクラウド時代の企業における生成AIとデータベースの関係 (Oracle Technology Day)
satonaoki
0
450
Microsoft Copilot, your everyday AI companion (Machine Learning 15minutes! Broadcast #82)
satonaoki
0
850
Microsoft Build 2023 Updates – Copilot Stack and Azure OpenAI Service (Machine Learning 15minutes! Broadcast #78)
satonaoki
2
810
Microsoft + OpenAI: Recent Updates (Machine Learning 15minutes! Broadcast #74)
satonaoki
1
920
30分でわかるマイクロサービスアーキテクチャ 第2版
satonaoki
9
5.5k
[Machine Learning 15minutes! Broadcast #67] Azure AI - Build 2022 Updates and more...
satonaoki
0
300
[Machine Learning 15minutes! #61] Azure OpenAI Service
satonaoki
0
420
[第50回 Machine Learning 15minutes! Broadcast] Azure Machine Learning - Ignite 2020 Updates
satonaoki
0
710
Other Decks in Technology
See All in Technology
プロデザ! BY リクルート vol.18_リクルートのリサーチ実践組織「リサーチブーストコミュニティ」
recruitengineers
PRO
3
240
KubeCon EU 2024 Recap “Kubernetes Policy Time Machine: Where to Next?”
ryysud
0
120
カオナビの利用実績をアウトカムへつなげる旅 / example-of-data-management-startup-in-kaonavi
kaonavi
0
120
レガシーをぶっ壊せ。AEONで始めるDevRelの話 / Qiita Night 2024-2-22
aeonpeople
3
150
クラウドサインにおけるプロダクトマネージャーの役割と開発プロセス / 20240410_cloudsign-PdM
bengo4com
1
680
疲弊しない!AWSセキュリティ統制の考え方 #devio_osakaday1
masahirokawahara
6
5.9k
Microsoft Cloudで開発ライフサイクルを保護する
kkamegawa
0
140
株式会社EventHub・エンジニア採用資料
eventhub
0
1.9k
[2024年3月版] Databricksのシステムアーキテクチャ
databricksjapan
8
1.9k
キャラクター制御のためのプロンプト術 for LINE Bot
uezo
0
520
転移学習とドメイン適応の基礎
kmatsui
2
570
Next'24 事例セッションの紹介とクラウド資格を活用したキャリア形成について語りMuscle
yasumuusan
1
340
Featured
See All Featured
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
1
3.4k
Code Reviewing Like a Champion
maltzj
513
39k
GraphQLとの向き合い方2022年版
quramy
31
12k
The Mythical Team-Month
searls
215
42k
Testing 201, or: Great Expectations
jmmastey
27
6.3k
How to Ace a Technical Interview
jacobian
272
22k
It's Worth the Effort
3n
180
27k
Designing with Data
zakiwarfel
95
4.8k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
104
6.6k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
186
16k
The Cost Of JavaScript in 2023
addyosmani
14
3.8k
Fontdeck: Realign not Redesign
paulrobertlloyd
76
4.9k
Transcript
Data modelling and partitioning in Azure Cosmos DB (Azure Cosmos
DB でのデータ モデリングとパーティション分割)
Session's objectives
What is Azure Cosmos DB? Non-relational and horizontally scalable
What is Azure Cosmos DB? horizontally scalable
What is Azure Cosmos DB? non-relational
What is Azure Cosmos DB? non-relational and horizontally scalable
So is Azure Cosmos DB suitable for relational workloads?
Let's look at a concrete example
Identifying the operations we have to serve
Now let's implement this model on Azure Cosmos DB!
Starting with the Customer entity
Starting with the Customer entity
To embed or to reference?
To embed or to reference? - - - - -
-
Our first entity: Customer
Customer customers PK: ?
What is partitioning?
What is partitioning? logical partitions
What is partitioning? Andrew Theo Mark Tim Deborah Luis
What is partitioning? Max size: 20 GB Max size: 2
MB
What is partitioning?
What is partitioning?
What is partitioning?
What is partitioning? Andrew Theo Mark Tim Deborah Luis SELECT
* FROM c WHERE c.username = 'Mark' our partition key
What is partitioning? Andrew Theo Mark Tim Deborah Luis SELECT
* FROM c WHERE c.favoriteColor = 'orange' ?
Choosing a partition key for customers customers PK: ?
Choosing a partition key for customers customers PK: ?
Choosing a partition key for customers customers PK: id
Choosing a partition key for customers customers PK: id
Next: product categories
Product categories
Product categories productCategories PK: ?
Product categories productCategories PK: ? SELECT * FROM c
Product categories productCategories PK: type
Next: product tags
Product tags
Product tags productTags PK: ?
Product tags productTags PK: ?
Product tags productTags PK: type
Next: products
Products
Products
Products products PK: ?
Products products PK: ? CategoryA CategoryC CategoryB SELECT * FROM
c WHERE c.categoryId = 'CategoryA'
Products products PK: categoryId category name? tag names?
Products: how to return category and tag names? products SELECT
* FROM c WHERE c.categoryId = 'CategoryA' productCategories SELECT c.name FROM c WHERE c.id = 'CategoryA' productTags SELECT * FROM c WHERE c.id IN ('<tagId1>', '<tagId2>', '<tagId3>')
Introducing denormalization
Products: denormalizing category and tag names products PK: categoryId
Products: keeping everything in sync productCategories productTags products
Cosmos DB's change feed
Products: keeping everything in sync productCategories productTags products
Next: sales orders
Sales orders
Sales orders
Sales orders salesOrders PK: ?
Sales orders salesOrders PK: ?
Sales orders salesOrders PK: ? CustomerA CustomerC CustomerB SELECT *
FROM c WHERE c.customerId = 'CustomerA'
Sales orders salesOrders PK: customerId
Sales orders salesOrders PK: customerId customers PK: id
Mixing entities in the same container?
Sales orders salesOrders PK: customerId customers PK: id
Sales orders: mixing with customers customers PK: id
Sales orders: mixing with customers customers PK: customerId
Sales orders: mixing with customers customers PK: customerId
Sales orders: mixing with customers CustomerA CustomerC CustomerB customer sales
orders customers PK: customerId
Sales orders customers PK: customerId SELECT * FROM c WHERE
c.customerId = 'CustomerA' AND c.type = 'salesOrder'
Sales orders customers PK: customerId
Denormalizing the count of sales orders per customer
Denormalizing the count of sales orders per customer
Denormalizing the count of sales orders per customer CustomerA CustomerC
CustomerB customer sales orders customers PK: customerId
Denormalizing the count of sales orders per customer CustomerA CustomerC
CustomerB update the customer add a sales order customers PK: customerId
Denormalizing the count of sales orders per customer CustomerA CustomerC
CustomerB update the customer add a sales order
Sales orders customers PK: customerId SELECT * FROM c WHERE
c.type = 'customer' ORDER BY c.salesOrderCount DESC
Our final design customers PK: customerId productCategories PK: type productTags
PK: type products PK: categoryId
Our final design, optimized! customers PK: customerId productMeta PK: type
products PK: categoryId
Key takeaways
Going further https://docs.microsoft.com/azure/cosmos-db/modeling-data https://docs.microsoft.com/azure/cosmos-db/how-to-model-partition-example https://devblogs.microsoft.com/cosmosdb/data-modeling-and-partitioning-for-relational-workloads/ https://github.com/AzureCosmosDB/labs/blob/master/readme.md https://github.com/AzureCosmosDB/labs/blob/master/decks/Data-Modeling.pptx