Skip to content

Commit 3a134b9

Browse files
authored
Update how-to-sqldb-to-cosmosdb.md
1 parent 8a99638 commit 3a134b9

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

articles/data-factory/how-to-sqldb-to-cosmosdb.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Migrate Azure SQL Database tables to Azure CosmosDB with Azure Data Factory
3-
description: Take an existing normalized database schema from Azure SQL Database and migrate to CosmosDB denormalized collection with Azure Data Factory.
3+
description: Take an existing normalized database schema from Azure SQL Database and migrate to an Azure CosmosDB denormalized container with Azure Data Factory.
44
services: data-factory
55
author: kromerm
66

@@ -12,9 +12,32 @@ ms.date: 04/29/2020
1212
ms.author: makromer
1313
---
1414

15-
# Migrate normalized database schema from Azure SQL Database to Azure CosmosDB denormalized collection
15+
# Migrate normalized database schema from Azure SQL Database to Azure CosmosDB denormalized container
1616

17-
By using mapping data flows in Microsoft Azure Data Factory, you can transform data from fixed-width text files. In the following task, we'll define a dataset for a text file without a delimiter and then set up substring splits based on ordinal position.
17+
This guide will explain how to take an existing normalized database schema in Azure SQL Database and convert it into an Azure CosmosDB denomarlized schema in Azure CosmosDB. SQL schemas are typically modeled using third normal form and normalized schemas to provide high levels of data integrity and fewer duplicate data. Queries can join entities together across tables. CosmosDB is optimized for super-quick transactions and querying within a collection or container via denormalized schemas with data self-contained inside a document.
18+
19+
Using Azure Data Factory, we'll build a pipeline that uses a single Mapping Data Flow to read from two Azure SQL Database normalized tables that contain primary and foreign keys as the entity relationship. ADF will join those tables into a single stream using the data flow Spark engine, collect joined rows into arrays and produce individual cleansed documents for insert into a new Azure CosmosDB container.
20+
21+
This guide will build a new container on the fly called "Orders" that will use ```SalesOrderHeader``` and ```SalesOrderDetail``` from the standard SQL Server AdventureWorks sample database. Those tables represent sales transactions joined by ```SalesOrderID```. Each unique detail records has its own primary key of ```SalesOrderDetailID```. The relationship between header and detail is ```1:M```. We'll join on ```SalesOrderID``` in ADF and then roll each related detail record into an array called "detail".
22+
23+
The representative SQL query for this guide is:
24+
25+
```
26+
SELECT
27+
o.SalesOrderID,
28+
o.OrderDate,
29+
o.Status,
30+
o.ShipDate,
31+
o.SalesOrderNumber,
32+
o.ShipMethod,
33+
o.SubTotal,
34+
(select SalesOrderDetailID, UnitPrice, OrderQty from SalesLT.SalesOrderDetail od where od.SalesOrderID = o.SalesOrderID for json auto) as OrderDetails
35+
FROM SalesLT.SalesOrderHeader o;
36+
```
37+
38+
The resulting CosmosDB container will embed the inner query into a single document and look like this:
39+
40+
![Collection](media/data-flow/cosmosb3.png)
1841

1942
## Create a pipeline
2043

0 commit comments

Comments
 (0)