@ -46,13 +46,73 @@ NoSQL is an umbrella term for the different ways to store non-relational data an
[Columnar](https://docs.microsoft.com/en-us/azure/architecture/data-guide/big-data/non-relational-data#columnar-data-stores) data stores organizes data into columns and rows like a relational data structure but each column is divided into groups called a column family, where the all the data under one column is related and can be retrieved and changed in one unit.
### Document Data Stores with the Azure Cosmos DB Emulator
### Document Data Stores with the Azure Cosmos DB
[Document](https://docs.microsoft.com/en-us/azure/architecture/data-guide/big-data/non-relational-data#document-data-stores) data stores build on the concept of a key-value data store and is made up of a series of fields and objects. This section will explore document databases with the Cosmos DB emulator.
#### The Cosmos DB Emulator
A Cosmos DB database fits the definition of "Not Only SQL", where Cosmos DB's document database relies on SQL to query the data. The [previous lesson](2-Working-With-Data\06-non-relational) on SQL covers the basics of the language, and we'll be able to apply some of the same queries to a document database here. We'll be using the Cosmos DB Emulator, which allows us to create and explore a document database locally on a computer. Read more about the Emulator [here](https://docs.microsoft.com/en-us/azure/cosmos-db/local-emulator?tabs=ssl-netstd21).
A Cosmos DB database fits the definition of "Not Only SQL" as you have choices on the type of non-relational database you'd like to use. The document database relies SQL to query the data. The previous lesson on SQL covers the basics, and we'll be able to apply these same queries to a document database here. We'll be using the Cosmos DB emulator, which allows us to create and explore a document database locally on a computer.
A document is a collection of fields and object values, where the fields describe what the object value represents. Below is an example of a document.
The fields of interest in this document are: `firstname`, `id`, and `age`. The rest of the fields with the underscores were generated by Cosmos DB.
#### Exploring Data with the Cosmos DB Emulator
You can download and install the emulator [for Windows here](https://aka.ms/cosmosdb-emulator). Refer to this [documentation](https://docs.microsoft.com/en-us/azure/cosmos-db/local-emulator?tabs=ssl-netstd21#run-on-linux-macos) for options on how to run the Emulator for macOS and Linux.
The Emulator launches a browser window, where the Explorer view allows you to explore documents.

If you're following along, click on "Start with Sample" to generate a sample database called SampleDB. If you expand Sample DB by clicking on the arrow you'll find a container called `Persons`, a container holds a collection of items, which are the documents within the container. You can explore the four individual documents under `Items`.

#### Querying Document Data with the Cosmos DB Emulator
We can also query the sample data by clicking on the new SQL Query button (second button from the left).
`SELECT * FROM c` returns all the documents in the container. Let's add a where clause and find everyone younger than 40.
`SELECT * FROM c where c.age < 40`

The query returns two documents, notice the age value for each document is less than 40.
#### JSON and Documents
If you're familiar with JavaScript Object Notation (JSON) you'll notice that documents look similar to JSON. In most instances, APIs that return JSON data can be directly transferred and stored in document databases. Below is another document, it represents tweet from the Microsoft Twitter account that was retrieved using the Twitter API, then inserted into Cosmos DB.
```json
{
"created_at": "2021-08-31T19:03:01.000Z",
"id": "1432780985872142341",
"text": "Blank slate. Like this tweet if you’ve ever painted in Microsoft Paint before. https://t.co/cFeEs8eOPK",
The fields of interest in this document are: `created_at`, `id`, and `text`.
There is a `data.json` file with more Twitter data that you can upload to the SampleDB database. It's recommended that you add it to a separate container.
"text":"The pandemic left thousands at home with no dependable way to shop for food and other necessities. \n\nHere's how Humana's routine customer check-ins became a call to action to feed those in need, using Microsoft solutions. https://t.co/4CGLwhUZdi 🧡"
},
{
"created_at":"2021-09-01T18:03:00.000Z",
"id":"1433128271248609287",
"text":"You: *joins meeting 2 minutes late*\n\nMicrosoft Teams: “There are 13 people here already, so we muted your mic. You’re welcome.”"
},
{
"created_at":"2021-09-01T15:00:18.000Z",
"id":"1433082292663209993",
"text":"You’re invited.\n\nLearn more about the #MicrosoftEvent: https://t.co/tpK3TB8Xxb"
},
{
"created_at":"2021-08-31T22:00:00.000Z",
"id":"1432825525626675206",
"text":"Latino-led businesses have increased by 34% in the past decade. \n\nGet to know four organizations that used technology to drive change in their community: https://t.co/sEydYaY80X 🌎"
},
{
"created_at":"2021-08-31T19:03:01.000Z",
"id":"1432780985872142341",
"text":"Blank slate. Like this tweet if you’ve ever painted in Microsoft Paint before. https://t.co/cFeEs8eOPK"
},
{
"created_at":"2021-08-31T16:00:00.000Z",
"id":"1432734928593096709",
"text":"Public health officials used technology to work, help, and heal during the pandemic with greater accuracy and speed.\n \nCheck out the Microsoft tools used to meet today's challenges: https://t.co/ptz7BOLxpH"
},
{
"created_at":"2021-08-31T13:15:32.000Z",
"id":"1432693540665106438",
"text":"RT @Windows: As perfect as 11.11 *would* be, we just couldn't wait any longer to make #Windows11 available. Get it October 5th, and read al…"
},
{
"created_at":"2021-08-30T20:15:01.000Z",
"id":"1432436715797553154",
"text":"Live your best hybrid work life by showing empathy, practicing active listening, and staying flexible.\n\nFind more tips from six career experts: https://t.co/BfJykUoaGH"
},
{
"created_at":"2021-08-30T17:15:00.000Z",
"id":"1432391416823570437",
"text":"Are you performing under pressure? Microsoft Teams has new built-in tools that promote productivity and balance in learning. \n\nHere are the top five: https://t.co/yn8OTPgfd2"