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 pa...
Search
SATO Naoki (Neo)
September 13, 2020
Technology
0
990
[第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)
Build enterprise-grade AI agents with Azure AI Agent Service
satonaoki
1
530
Microsoft Build 2024 Updates
satonaoki
0
340
LLMOps with Azure Machine Learning prompt flow
satonaoki
1
880
マルチクラウド時代の企業における生成AIとデータベースの関係 (Oracle Technology Day)
satonaoki
0
1k
Microsoft Copilot, your everyday AI companion (Machine Learning 15minutes! Broadcast #82)
satonaoki
0
1.3k
Microsoft Build 2023 Updates – Copilot Stack and Azure OpenAI Service (Machine Learning 15minutes! Broadcast #78)
satonaoki
2
1.3k
Microsoft + OpenAI: Recent Updates (Machine Learning 15minutes! Broadcast #74)
satonaoki
1
1.2k
30分でわかるマイクロサービスアーキテクチャ 第2版
satonaoki
9
7.3k
[Machine Learning 15minutes! Broadcast #67] Azure AI - Build 2022 Updates and more...
satonaoki
0
400
Other Decks in Technology
See All in Technology
vLLM Community Meetup Tokyo #3 オープニングトーク
jpishikawa
0
190
「ストレッチゾーンに挑戦し続ける」ことって難しくないですか? メンバーの持続的成長を支えるEMの環境設計
sansantech
PRO
3
360
Datadog の RBAC のすべて
nulabinc
PRO
2
270
プロジェクトマネジメントをチームに宿す -ゼロからはじめるチームプロジェクトマネジメントは活動1年未満のチームの教科書です- / 20260304 Shigeki Morizane
shift_evolve
PRO
1
130
オンプレとGoogle Cloudを安全に繋ぐための、セキュア通信の勘所
waiwai2111
3
1.1k
クラウド時代における一時権限取得
krrrr38
1
170
GitLab Duo Agent Platform + Local LLMサービングで幸せになりたい
jyoshise
0
170
モブプログラミング再入門 ー 基本から見直す、AI時代のチーム開発の選択肢 ー / A Re-introduction of Mob Programming
takaking22
1
250
開発組織の課題解決を加速するための権限委譲 -する側、される側としての向き合い方-
daitasu
5
280
Agentic Software Modernization - Back to the Roots (Zürich Agentic Coding and Architectures, März 2026)
feststelltaste
1
200
Introduction to Sansan Meishi Maker Development Engineer
sansan33
PRO
0
370
20260305_【白金鉱業】分析者が地理情報を武器にするための軽量なアドホック分析環境
yucho147
1
190
Featured
See All Featured
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
81
Darren the Foodie - Storyboard
khoart
PRO
3
2.7k
Side Projects
sachag
455
43k
The Cult of Friendly URLs
andyhume
79
6.8k
A better future with KSS
kneath
240
18k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
130
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.4k
Git: the NoSQL Database
bkeepers
PRO
432
66k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Between Models and Reality
mayunak
2
230
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.4k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.7k
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