This post has been republished via RSS; it originally appeared at: Microsoft Tech Community - Latest Blogs - .
When building your application, you are bound to meet with databases at one point or another. Databases are where information about your application is stored and managed. For example, if you are registering new users, you will need to store data on their username, password, and other details. Other than just storage, you may need to ensure your data is safe and easily scalable. This is where database systems come in handy. The two most used are relational databases and NoSQL databases. While this post will cover the basic differences between relational and NoSQL databases, you can read more about what to consider when deciding which database to use.
Relational databases have been in existence for the longest time, for over 50 years. They organize data in tables that consist of rows and columns such as an excel sheet and manage data through the relationship between the different tables. If you are using a relational database as users create and login to their accounts, you can have two tables, one consisting of creating new account details and another for login. The username might then be used to define the relationship between the two tables as it will be unique to different users.
One drawback of relational databases is the rigid structure it has as data must fit into different rows and columns. The rigid structure is however useful in transactional systems such as e-commerce platforms as it ensures data consistency and integrity is maintained.
Unlike relational databases, NoSQL databases are more flexible and do not follow the rigid structure of tables as in relational databases. The database system came as the need for more flexible and scalable database models arose. Some of the models NoSQL databases use include key-value, document based, column family and graph-based models.
Image source: Relational vs. NoSQL data | Microsoft Learn
An example of NoSQL model is key value, where data is represented in a collection of pairs standing for a key and a value. Each item in the database has a unique key associated with a value. Key-value databases are fast and can be used for easy data retrieval such as processing real time data.
Once the user is using your application, you might have different use cases for instance if your app has a chat system, you may need to manage user data, comments, replies as well as handle real-time interactions, which is easier done with a NoSQL database.
Comparisons between relational and NoSQL Databases
As you have probably noticed, relational and NoSQL databases can differ quite a bit. Here’s some differences to consider:
- Data structure: A data table will be organized by tables, rows, and relationships. NoSQL databases do not follow a tabular structure and can be organized into a variety of models.
- Flexibility: Relational databases follow a schema, which describes how the data is structured. Schemas determine what should be stored in the table and are bound to its defined and predetermined rules. This makes adding additional data, like a new column to a table,
- Scalability: When it comes to quickly working with large amounts of data, NoSQL databases adopt horizontal scalability, which helps store and access large amounts of data by splitting it across multiple servers. Relational databases typically adopt vertical scalability, where the data is stored in one location and computing resources are increased to meet high demands of data storage and access.
- Relationships: A table in a relational database can use columns that have unique data to define relationships between other tables and data in their columns. Because NoSQL does not use tabular data, describing relationships will depend on the data model being used.
Azure Cosmos DB
What advantages does Azure Cosmos DB offer to you? The main advantage is security, as your data is encrypted, data access is also secured as well as its compliant to multiple industry and government standards. Other advantages include its high-performance, scalability, variety in terms of models available and its availability globally.
Getting started with Azure Cosmos DB
The two best things about Azure Cosmos DB are that it has a free tier and once you create an Azure Cosmos DB service using your Microsoft Azure work or student account you can access it directly at: Azure Cosmos DB Explorer
Let us get experimenting on Azure Cosmos DB with the demo below.
NoSQL in Action with Azure Cosmos DB
Storing data in Azure Cosmos DB begins with creating an Azure Cosmos DB account. An account stores all the database resources within the account. To create an account, you’ll need to decide which API you want to use. If you’re familiar with SQL, then Azure Cosmos DB for NoSQL is a great starting point, because you can use SQL with the data. Keep in mind that the API cannot be changed in the account once it’s created. For example, a NoSQL database and a MongoDB database can’t be under the same account.
Image source: Try Azure Cosmos DB for NoSQL
Resources within an Azure Cosmos DB account is organized in a hierarchy, which starts at the account level.
Image source: Try Azure Cosmos DB for NoSQL
Within an account are databases, which organize data into containers. Containers store items, which are individual units of data. An account can have many databases, a database can contain many containers, and a container stores all items.
You’ll need to provide a name for each account, database, and container you create.
When you create an account in Azure Cosmos DB, you can get started with a sample database by selecting “Launch quick start” in the overview, which will create a container and set some default values. The quickstart wizard will walk you through the various features within Azure Cosmos DB, including the Data Explorer where you can view items within the container.
Within Data Explorer, you can create, and update items and run queries. The image below is making queries in Data Explorer, using the sample data created from the quickstart wizard to find all addresses that contain an avenue. To create a new query, select the New SQL query icon, which is also highlighted in the image below.
You have seen what Azure Cosmos DB can do, what next?
Azure Cosmos DB has been tried and tested in industries such as retail where customers need real-time access to resources to mission-critical applications where it has proved to have high availability. Below are some resources to help you continue building with Azure Cosmos DB:
- Try Azure Cosmos DB for NoSQL - Training | Microsoft Learn
- Data Science for Beginners Lessons
Get Started with Azure Cosmos DB
Azure Cosmos DB is a fully managed NoSQL database for modern app development with SLA-backed speed and availability, automatic and instant scalability, and open-source APIs for MongoDB, Cassandra, and other NoSQL engines. Discover features or capabilities at www.AzureCosmosDB.com or get started for free. For up-to-date news on all things, Azure Cosmos DB be sure to follow us on Twitter, YouTube, and our blog.