Menu

Semi‐Structured – CREATE DATABASE dbName; GO

Two problems that have come up regarding relational databases over the years have to do with the complexity of SQL queries and the difficulty of representing objects. The simple structured database you created in the previous exercise contains six tables. Creating a query to join three, four, or even five of those tables together would be long and complex. Further, there is a concept, object relational models (ORMs), that libraries like NHibernate, Hibernate, and Entity Framework work with. However, relational databases do not work optimally with ORMs. Semi‐structured databases, also called NoSQL databases, can resolve both of those situations. Semi‐structured data APIs such as Azure Table, Gremlin (Graph), and Core (SQL) on Azure can be found within an Azure Cosmos DB account.

Azure Table: Key‐Value Database

Key‐value databases store values in pairs. This makes for fast querying using GET, PUT, and DELETE commands instead of SQL‐like queries. Most use cases for key‐value pair databases will have millions if not billions of rows. This scale and the speed at which you can work with data that big is where a lot of the value of this kind of database is found. Take the following table, for example, which illustrates a key‐value pair database:

+—–+—————-+
| KEY | VALUE          |
+—–+—————-+
| 1   | ClassicalMusic |
| 2   | FlipChart      |
| 3   | Meditation     |
| 4   | MetalMusic     |
| 5   | PlayingGuitar  |
| 6   | TikTok         |
| 7   | WorkMeeting    |
| 8   | WorkNoEmail    |
+—–+—————-+


Retrieving data from such a table is commonly performed using REST APIs that are HTTP‐based. HTTP endpoints require an address that is provided when you provision an Azure Cosmos DB Table API. To retrieve, insert, and delete a row of data, you would use the following syntax. Replace * shown in the following endpoint address with the name of your Azure Cosmos DB Table API address. Replace scenario with the name of your table.

GET *.table.cosmos.azure.com/
scenario
/keys/5

PUT *.table.cosmos.azure.com/
scenario
/keys/9/?value=Sleeping

DELETE *.table.cosmos.azure.com/
scenario
/keys/5


Gremlin: Graph Database

Graph databases consist of nodes that contain records that point to other nodes. The relational aspect of a graph database exists between the nodes instead of within a node. This improves query times.

Core (SQL): Document Database

The Core (SQL) API is the main and native API in Cosmos DB. Data in this document database is stored using a markup language like JSON, YAML, or XML. This means you can store any data you need in any format. Instead of using table column names to identify data like you would in the relational context, tags are used to define the data and the hierarchy. To learn more about semi‐structured document databases, perform Exercise 2.2.

Leave a Reply

Your email address will not be published. Required fields are marked *