In this article, we will see the different types of databases but before that, we will first talk about "What the database is?
A database is the organized collection of data, generally stored in the computer system. It is stored in an organized manner so that specified data can easily be accessed.
Why do we need databases
1)To manage large amounts of data we need the database
2)For getting accurate data
3)Easy to update data when we store in database
4)Security of data
Different Types Of Databases
There are different types of databases depending on the properties of data
- Centralized Database
- Distributed Database
- Relational Database
- NoSQL Database
- Object Oriented Database
- Hierarchical Database
So we will briefly cover each types of database :-
The database is stored in a single location such as a mainframe computer or CPU. Due to stored at the one location it can be modified or deleted from only that location. A centralized database is accessed through an internet connection.
Using a centralized database, the integrity of the database can be maximized. Information can be easily accessed at a time. Information or updates from the end-user can be implemented fast and easily.
But, there are some disadvantage of the centralized database
- Database is highly dependent on the network, slower network may result in the longer time needed to access the database. At one time it can be accessed by a single person who is on the system, so this may decrease the efficiency of time.
The data is stored in multiple physical locations or distributed over multiple networks of computers. It may be possible the different computers are at the same physical location (Example like data center).
A distributed database makes a loosely coupled system that means if one of the database computer systems fails then another system will complete the task.
The data can be stored in two ways :
Replication - Several replicas of entire relation(r) stored in two or more than two sites. That means the entire database is replicated and the redundant data is present at each level so whenever the update in the database is required it should be made on all the replicas of the database to maintain the database consistency and integrity.
Fragmentation - The relations r are fragmented into serveral relation r1,r2,r3...etc.The relations are fragmented such that the original relations are retained.
The data is arranged into a table with predefined relation between the data. The tables have a set of columns and rows(or tuples). Each Column in the table store some specific form of data or attributes of the data. Each row in the table represents the uniques values of each object or entity.
See the relation between the Instagram user post profile and his following.
For accessing and managing the data from the relational database, structural query languages(SQL) are used.SQL is an application programming interface for communication between the user and the relational databases.
Example query languages are mySQL,mariaDB,OracleDB,PostgreSQL
Advantages of relational database
Data Integrity Due to strong data type casting ensures the consistency and accuracy of the data.
Scalability New Data can be added to the table easily without affecting the existing records.
Normalization breaking down the data into multiple levels
High-Security: - As data is divided into tables we can make some of the tables confidential so that no outsider can access it. Like Administration and the other user-specific, we can make the permission of the table.
NoSQL refers to "not only SQL" or non-relational database which does not store the data in the form of a table. Depending on the model, NoSQL has a variety of database types to store the data. The main types are document database,key-value pair, wide column, and graph database.
NoSQL database is used in the real-time web application.NoSQL database can easily be scaled with a large amount of data and high user loads. Horizontal scaling to clusters of machines can easily be done.
Different types of NoSQL database:
Document Database - store the data in JSON like format. Different types of data can be stored (strings, numbers, booleans, arrays, or objects).Ex(MongoDB is the example of the document database.)
Key-value Databases - items are stored in the key-value pair. This key is used as a unique identifier. It is simple to retrieve the information from the key-value pair does not require the complex queries. Example -:Redis and DynanoDB are popular key-value databases.
Wide-column Stores - store data in tables ,rows and dynamic columns . It is more flexible than a relational database table because it is not necessary for each row the same set of columns. Wide-column stores are used for storing the IOT data and user profile data. Examples:- Cassandra and HBase fall under this category of databases.
Graph Databases - We know, the graph is made up of two elements node and relationship. The node represents the entity and the edges represent the relationship. These types of databases are generally used for social networks.
Example: - Neo4j and Janusgraph fall under this category.
Object Oriented Database
The database stores the objects rather than the data (string or number). Objects are the same which we used in object-oriented programming. We know, Objects have a member like data fields, methods, and properties. We know in OOP has key characteristics
Inheritance, Encapsulation, and Polymorphism.
The advantage of using an object database is we can directly store the object instead of storing each data field in tables(row and columns) unlike in a relational database, we store the whole objects in a database. We can store the large collection of complex data including user-defined data types. This type of database can easily handle many-to-many relationships.
A data is stored in a tree-like structure means the data relationship between the data is one-to-many. So, the parent node may have one or more than one child node.
A hierarchical database is helpful when we want to store the data in a tree-like hierarchy. Examples of the hierarchical database are the IBM information management system and RDM Mobile.
So in this article, we have discussed about the different types of databases. After this, you can delve into studying each type of database in depth.