Top Banner
Introduction to DocumentDB By Ike Ellis
22
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Introduction to Azure DocumentDB

Introduction to DocumentDBBy Ike Ellis

Page 2: Introduction to Azure DocumentDB

Agenda

• Introduction

• Configuration

• Finding and Saving a Document• Two APIs

• Advanced Querying

• Stored Procedures, Triggers, Functions

Page 3: Introduction to Azure DocumentDB

Introduction

• Loose Outline• JSON Document

• Collections

• Different APIs• Python

• REST

• SQL

• .NET/LINQ

• Not available in all regions• Central US, West US, North Europe, West Europe

Page 4: Introduction to Azure DocumentDB

JSON Document• Standard for passing data between a server and a web application

• Replacement for XML

• Hierarchical

• Terse

• Simple data types

Page 5: Introduction to Azure DocumentDB

DocumentDB in the landscape

Page 6: Introduction to Azure DocumentDB
Page 7: Introduction to Azure DocumentDB

Database

Account

A database account is associated with one or more capacity units representing

provisioned document storage and throughput, a set of databases and blob storage.

You can create one or more database accounts using your Azure subscription. Each

database account has a unique DNS name.

Database A database is a logical container of document storage partitioned across collections.

Collection A collection is a container of JSON documents and associated JavaScript application

logic. Queries and transactions are scoped to collections.

Page 8: Introduction to Azure DocumentDB
Page 9: Introduction to Azure DocumentDB

DocumentDB Limits

• Max Document Size – 512K

• DocumentDB Account – 100 databases per account * 10GB each = 1TB

Page 10: Introduction to Azure DocumentDB

Configuration

• Configured with the new portal (try preview)

• Switch Location to Western US (or wherever)

Page 11: Introduction to Azure DocumentDB

Once Created

• Get your DocumentDB URI and Key• Needed in code to begin saving documents

Page 12: Introduction to Azure DocumentDB

Testing Connectivity

Page 13: Introduction to Azure DocumentDB

Demo

Page 14: Introduction to Azure DocumentDB

Modeling Data - RDBMS

SELECT p.FirstName, p.LastName, a.City, cd.DetailFROM Person p JOIN ContactDetail cd ON cd.PersonId = p.IdJOIN ContactDetailType on cdtON cdt.Id = cd.TypeIdJOIN Address a ON a.PersonId = p.Id

Page 15: Introduction to Azure DocumentDB

Modeling in DocumentDB{

"id": "1",

"firstName": "Thomas",

"lastName": "Andersen",

"addresses": [

{

"line1": "100 Some Street",

"line2": "Unit 1",

"city": "Seattle",

"state": "WA",

"zip": 98012

}

],

"contactDetails": [

{"email: "[email protected]"},

{"phone": "+1 555 555-5555", "extension": 5555}

]

}

Reading is one operation

Writing is one operation

No assembly de-assembly

Page 16: Introduction to Azure DocumentDB

When to embed

• There are contains relationships between entities.

• There are one-to-few relationships between entities.

• There is embedded data that changes infrequently.

• There is embedded data won't grow without bound.

• There is embedded data that is integral to data in a document.

Examples of when not to embed

• Like a blog post comments or customer orders for the enterprise

Page 17: Introduction to Azure DocumentDB

Common Error

Local clock is not synced to Azure

Page 18: Introduction to Azure DocumentDB

Query Playground

• http://www.documentdb.com/sql/demo

Page 19: Introduction to Azure DocumentDB

Pricing

Page 20: Introduction to Azure DocumentDB

ConsistencyConsistency Level Description TradeOff

Strong a write is only visible after it is committed durably by the majority quorum of replicas

Absolute guarantees on data consistency, but offers the lowest level of read and write performance.

Bounded staleness a write is only visible after it is committed durably by the majority quorum of replicas

more predictable behavior for read consistency while offering the lowest latency writes

Session ability to read your own writes. . A read request for session consistency is issued against a replica that can serve the client requested version (part of the session cookie).

predictable read data consistency for a session while offering the lowest latency writes. Reads are also low latency as except in the rare cases, the read will be served by a single replica.

Eventual Eventual consistency is the weakest form of consistency wherein a client may get the values which are older than the ones it had seen before

the weakest read consistency but offers the lowest latency for both reads and writes

Page 21: Introduction to Azure DocumentDB

Indexing

• Everything is indexed by default

• Opt-in or out at collection creation

• Range – Good for numbers that need where filters with >=, >, <, <=

• Hash – Good for strings

Page 22: Introduction to Azure DocumentDB

Ike Ellis

• Crafting Bytes• Small Software Studio• Modern web, mobile, Azure, SQL Server• Looking for future teammates!

• Book: Developing Azure Solutions

• www.craftingbytes.com

• blog.ikeellis.com

• www.ikeellis.com

• Ike Ellis, MVP

• @ike_ellis

• 619.922.9801

[email protected]