Welcome to this tutorial on one of the most commonly used Database Management language, SQL. But before we talk about SQL, we need a basic understanding of What is Data, Database and Database Management System (DBMS) because all of them form the basis of SQL. So let’s dive in.
What is Data, Database and Database Management System (DBMS)?
What is Data?
We all are familiar with Social websites like Facebook & Instagram, E-Commerce websites like Amazon & SnapDeal, Banking websites like Barclays & HDFC or any Education website like ToolsQA, all these websites have a humongous amount of data stored in it. So what is Data?
Data is any sort of information which is stored in computer memory. This information can later be used for a website, an application or any other client to store for future purpose. The most common information is User information in the form of user personal, address and banking information. Let’s consider Facebook, it stores our personal data, images, posts, comments and many more things. Banking application also stores user data, their transactions details, funds summary etc. All this information is data, but when it put together and store in a structural way, it becomes informational data.
But, how do these applications or websites get data? When you post a status on Facebook, perform a banking transaction online or upload a selfie on Instagram, you are actually sending data to the site or to be precise their server. So, we can say any information transmitted or transferred is actually data. Server filter out the necessary data and stores it in Database. Here the concept of Databases come up, let’s take a look.
What is Database (DB)?
So what is a Database? Is it a random collection of stuff all squeezed in together? No, Database (DB) are organized, they have a structure, and all the data they store it fits into that structure. More specifically, a database is an electronic system that allows data to be stored, easily accessed, manipulated and updated.
So, we just saw the definition of databases but where in real life can we see such things? Well, we all are well aware of things like a telephone directory. Well, phonebook/telephone directory actually contains the name of people arranged in order of their last names. So, we are able to store data and search it efficiently using the last name of the person, like it’s really easy if I ask you to search for Tyagi, Vishu. But an issue arrives if I ask you to search for every contact with the first name Martin. The issue here is, names are stored according to last names so searching for the first name is a lot trickier. So, a database is made up of two components mainly, data and a meaningful method for accessing and manipulating data. Without these two, a database is just a random set of data. A more precise example of a database can be a dictionary, which stores a large quantity of data as Key-Value pairs. At the same time, it also has a meaningful method to access data using the Key.
Databases are quite similar to spreadsheets as they are mostly made up of tables which contain rows and columns like a spreadsheet. A database needs to be hosted or created on some special database platform, some of the famous Database platforms are:
- Microsoft Access
We know that when we use any software, like an app, data is either added to the database, updated according to the action or pulled as per the action we perform. But, the computer must have something to perform such action too. A software which can perform the various operations on databases is known as Database Management System.
What is a Database Management System (DBMS)?
A database management system is a software used to perform different operations, like addition, access, updating, and deletion of the data, like adding your name in the database for an online retail store as a customer. A database management system acts as the backbone of a database and makes using a database a cakewalk as it makes access and management of data a lot easier.
One thing we need to understand is the difference between Database and Database Management System.
Database VS Database Management System
Well, you may feel that a database and a database management system is a similar thing but there’s a really big difference. Let’s understand this with the help of an example.
Here, we can see an App or a website with its own database. So, the most function is to connect the database to the App or Website. While database can provide the data to the website and have a meaningful way to access data, it still cannot understand the language or method which a website may use to fetch the data, i.e., it cannot understand the commands on its own. Thus, to tackle this problem, we bring in the concept of Database Management System. A DBMS understand the commands and the queries which define what data is required by the App or Website and thus use the meaningful method of accessing the database to retrieve the information. Therefore, it can be said that a DBMS act as connecting bridge between the database and the user and DBMS actually understand the queries and help database to understand the requirements. So, the above image looks something like this:
Database acting as a connector between both the App and the database. With this basic difference is clear that a database store the data and provide a method to access it, a DBMS actually converts the queries into a meaningful command to invoke the method used to access the database.
Now, we can move forward to understand look at the type of Databases.
Different Types of Database
Databases can be classified into four major types:
- Relational databases
- Hierarchical database
- Network database
- Object-oriented database
The first thing to know is that database which we deal with the most, like SQL, is based upon Relational Databases. The easiest way to put relational databases is: They store data in form of tables which are related to each other.
For a further understanding, the relational database model works on the concept of storing data where data is represented by tuples, grouped into relations. It may occur to you what are tuples, so let’s look at what exactly are tuples:
In mathematics, a tuple is defined as a finite-ordered list of elements. To define in a simple language, a tuple is actually a row in the table of the database. Each row in a table represents a set of related data, and every row in the table has the same structure. While the rows actually contain data in a related fashion, the columns actually contain data of a similar kind,i.e., data in a column is always of a similar kind.
So, we may see that storing the data in form of a table, we have two major attributes, rows and columns.
As you can see in the example below which show the relational database for a library.
In this example, the two tables are connected by the Book No, which acts as a key between the two tables. Here you can see the two tables are related to each other or share a relation defined using Book No.
Each table is related to a certain type of data and thus a table relates all the various data types present inside it. Each data type actually defines a certain new column and thus a new property is given to the table. The table relates or combines all the columns present in the table to each other and thus the data too. This leads to the fact that certain times tables are termed as “relations” also.
The Hierarchical databases are actually databases which follow a tree-like structure. Just imagine a family hierarchy tree, maybe of an Ameoba-like family, i.e., one parent dividing into multiple children. It may look like the picture below:
Network databases are similar to Hierarchical ones, the only difference is one child is connected to many parents. Just take a look at the example of an E-Commerce company, where the children, Seller, and Customer both share common child Product.
We saw that RDBMS actually stores values in form of tables, but what if we make a separate table for each book? This is what Object-Oriented Database is. Look at the table below:
Compare this to the table in RDBMS, you’ll find that we defined the table with the book name and stored the rest of the values as they were. This approach actually defines Book ABC as an object.
So, this is a quick walkthrough of data, databases, database management system and its types. The detailed look over these is coming soon in our upcoming article “Introduction to Database“.
Now, when we know the details of Data, Database and DBMS, it is the time to get you familiar with SQL.