Let's make a complex dataset simple using Azure Cosmos DB Hansamali Gamage Senior Engineer (TIQRI) ● Blogger ● Speaker ● Traveler Let's make a complex dataset simple using Azure Cosmos DB
Azure Cosmos DB
Azure Cosmos DB Not a database, It’s a database service Low latency Multi model & Multi API support Global Distribution Elastic scale out Multiple data models & APIs Global distribution Scaling throughput & storage Service level agreements Comprehensive SLAs
Why Azure CosmosDB Difference in Azure SQL database vs Azure Cosmos DB
Partitioning & Global Distribution R/W R South East Asia Product Category = ‘A’ Product Category = ‘B’ Product Category = ‘C’ R R/W Central US Data partitioning and sectioning Product catalog Fail over regions R R/W East Europe
Consistency vs Availability vs Response Time Data Distribution Consistency Availability Can’t achieve both Data availability & consistency Shopping cart application Consistency levels Session consistency Change consistency programmatically
Scale throughput and storage Low response time Per application requirements Scale throughput & storage Throughout in seconds and minutes If host in a physical server Per second & per minute granularities
RU (Request Units) & Pricing RU is the Currency Control RU when you scale your apps RU is the currency Based on the calculations need to process the request Remodel your database Throttled database requests Notifcation for throttled requests calculated based on the computation per request
Cosmos DB is a database service Azure Cosmos DB Cosmos DB is a database service Key - value Column family Documents Graph DB
Azure Document API De-normalized data Document is a JSON object Flexible schema Azure Document API De-normalized data Stores data in documents Document is a JSON object Can have mixed data in a document Data stored as documents JSON object Data types in Document API Referential Integrity Referential integrity is not enforced
Database Schema & Index Management in Document API Schema free Scheme free Automatically indexed all the paths Properties automatically indexed
Modeling data for a document database Data modeling is important as in a relational DB Important Enforcement of schema is a need by the developers
Are You Non-relational
ORM Normalized data What you store is what you get
Modeling the data in relational way Order Order Item Customer Product
Modeling the data in document way Order Id (key) Customer Items Item Product Item Product
Embed or Reference
Embed vs Reference
DEMO
Connect the dots You can try it yourself, check this article, Azure Cosmos DB: Designing your data structure
Thank you hansamaligamage@gmail.com http://hansamaligamage.blogspot.com/ https://goo.gl/DWDzdg https://goo.gl/7Pa5X8 @hansamaligamage