Databases: SQL and NoSQL
By McDonald, T. | Date 20th of November 2020
What is a database?
A database can be anything that stores collection of information and is often abbreviated to DB. A relational database stores information that is related in some way. For example, a shopping list is a relational database since it is a list of related information.
Other examples include:
- Phone book.
- List of twitter users.
- Your families favourite foods.
Now you have an idea of what a database is we can talk about where to store it. In the examples above, the phone book is a list of numbers and related information that can be stored in a book. The shopping list is stored on paper. We can also store these databases on a computer. Notably, the computer can be in your office or be a dedicated computer in a server room or even stored in a virtual machine in the cloud, which uses dedicated computers. Keeping it simple for now we can just think of a computer hosting the database. Now we have a place to store the database, we need a way to interact with it. This leads us to Relational Database Management Systems or RDBMS for short.
Relational Database Management Systems (RDBMS)
First, why store databases on a computer? When the database becomes large like a phone book, storing it on a computer is great because computers are brilliant at storing large amounts of information and can perform many calculations very quickly. RDBMS is software specifically designed to manage the data in a database; it is used to build and maintain databases on a computer. Advantages of using computers and RDBMS are that it’s possible to store trillions of entries and search the database quickly in most cases. Additionally, RDBMS can interact with other software applications, make backups, can import and export data and deal with security through user permissions.
Obviously, the RDBMS needs to perform certain actions for the prepose of editing. CRUD is an acronym that stands for CREATE, READ, UPDATE and DELETE, which are the four main actions used.
There Are Two Main Types Of DB in Computing
- Relational Databases (SQL)
- Non-Relational Databases (noSQL)
Relational Databases (SQL)Relational databases are the most popular.
- Data is organised into one or more tables.
- Each table has headers columns and rows.
- Each row has a unique key.
Relational databases are a lot like spreadsheets in that they store items of data in cells within columns and rows.
Non-Relational Databases (noSQL)
- Uses key value pairs
- Can store documents (JSON, XML for example)
- Blobs of data
Non-relational databases are any type of database that is not a traditional table.
Structured Query Language (SQL) and RDBMSSQL is a language that allows users to perform operations such as CRUD and administrative tasks on the database. Notably, there are different types of SQL such as mySQL, postgresSQL, MariaDB and others, which means it may not always be portable to another type of SQL. However, SQL is standardised for RDBMS.
- RDBMS is the application (SQL)
- SQL is the language used to interact with those RDBMS (example mariaDB)
Non-Relational Databases (noSQL)As I said earlier, this type of table will store data in anything but a standard table.
Examples of NRDBMS:
Document databases (JSON, blob, XML etc)
"interests" "Fish and birds"
"interests" "Staying away from the cat"
Example 2: Key value pairs, which has a key and a value where the key is mapped to a value.
Whereas RDBMS have a standardised language in SQL, NRDBMS have no standardised language.
What is a Query?
A query is a request for a specific piece of information from the database. These queries can become complex. Queries are the most common interaction with any database.
To conclude, databases are a way of storing information in an organised way making locating retrieving possible. Database have two types SQL and Non-SQL of which SQL is the standardised language for RDBMS. RDBMS use tables while Non-SQL do not, but will likely use key value pairs or JSON. Example of RDBMS are postresSQL or mySQL while NRDBMS might use mongoDB.