Table of Contents
What is a DataBase
A database is a system which in a software Architecture assumes the resposibility of storing and protecting the data, helping in fast retrieval, and ensure access control over the data. As per the definition, here are some examples of databases : exam cheat paper, deadman’s will, someone’s tattoo, etc. but, here we are going to talk about databases in software engineering context.
Does storing info in a file counts?
Yes, storing any information and saving it in the file do count as database but it will only take care of storing part, other criterias are still not fulfilled. A modern database is very well researched and designed which not only take care of retrieval and updates but also structure of storing the information at a very grounded level.
But, my game is not in any database. it is in my laptop.
Every long term data storing in this world is done in a disk. now, that can be a disk or a Hard disk or some other form which internally is storing in disks. Irrespective of the type of your file, all the information is stored in the form 1 and 0 in a disk.
So, database is just a Fancy Software on top of a CD?
Not exactly, there are many modern databases who along with retrieval, updating, deleting and access of data, also takes care of how the data will store so that they can retrieve it faster and ensure high availability.
Types of Database
There are many ways to actually group databases in different groups. each differentiation helps in a unique way, developer needs to choose with whom he can spend a night banging (his head while debugging).
The basic requirement of a database is to hold data, second basic requirement is to perform operations(C.R.U.D) on it. So, it becomes necessary that we differentiate between the rabbits(Transactional) and turtles(Analytical) when it comes to frequency.
-
Transactional Database(OLTP): It is built to perform high amount of operations. when a system has a need to do high amounts of CRUD operations frequently, this type of database is used. There are certain things which helps in creating such type of databases.
-
Row-Oriented storage: Data is stored in the form of Row. This helps in retrieving all the information about a particular
id and hence updating it.
-
ACID properties: These types of databases obey ACID (Atomicity,Consistency,Isolation,Durability).
-
High-availability: It is necessary to ensure high-availability of these databases so that they can perform operation almost real-time without fail.
-
Use-Cases: These type of DBs are used for maintaining a source of truth in the system.
-
Example: MySQL, PostgreSQL.
-
Analytical Database(OLAP): It is built to retrieve high amount of data and run complex queries mainly for analysis of data. There are certain things which helps in creating such type of databases.
-
Column-Oriented storage: Data is stored in the form of Columns. This helps in fetching only the required information and hence performs better than row-oriented ones.
The reason column oriented works is:
When Database reads a data it picks a record from the disk and stores it in the RAM. now, a record in Row-oriented db is the complete row which includes all the data for one entry. but, a record in a column-oriented db is the column which has all the data for that coulmn for multpile entries. Now, imagine a use-case when the trend of marks in maths is needed from a database of students.
Now if the db was row-based then for every record one would have fetched student name, age, english marks, height, weight, etc.
| Name |
Age |
Math |
English |
Height |
Weight |
| Alice |
14 |
88 |
92 |
160cm |
50kg |
| Bob |
15 |
75 |
85 |
165cm |
60kg |
| Charlie |
14 |
93 |
89 |
158cm |
48kg |
but, in case of column-based db it will only fetch all the marks in maths. this would save so much of space, time and resources.
| Field |
Values |
| Name |
Alice, Bob, Charlie |
| Age |
14, 15, 14 |
| Math |
88, 75, 93 |
| English |
92, 85, 89 |
| Height |
160cm, 165cm, 158cm |
| Weight |
50kg, 60kg, 48kg |
-
Complex Queries and aggregations: These types of databases lets us perform very complex joins, aggregations, computations.
-
Batch data processing: It processes data in batches and uses parallel processing.
-
Horizontal scaling: It is scaled horizontay as it is responsible for holding high amounts of data.
-
Use-Cases: These type of DBs are used for Analytics, Insights and warehousing purposes.
-
Example: ClickHouse, Amazon Redshift.
Data Model or Structure : Relational Vs NoSQL Vs Hierarchical Vs Network Vs OODb
How data is stored in a particular db is also very important way to categorize it as how its is stored also determines how it is retrieved, hence deciding overall performance.
-
Relational(RDBMS): It stores data in the form of tables and columns and maintains relations between them. This helps in storing very organised data. It follows
ACID properties and has SQL as query language. maintains relationships with the help of concept of primary key, foreign key. Used for banking, enterprise application, etc.
-
NoSQL: It is schema less hence helps in changing the structure anytime and removes reposibility of imposing a schema. It does not follow
ACID properties but believes in BASE (Basically available, Soft state, eventual consistency). Used for unstructured and semi-structured data where requirement for the db is to be highly available. major use cases include Big data, real-time application and content management. It stores data in the form of :
-
Documents and collections
- Stores data in the form of documents(JSON/BSON/XML).
- Documents are stored in the form of collections.
-
Use Cases: Content storing, blogs, user details.
-
Example: MongoDB, Amazon DocumentDB
-
Key-value pair
- Stores data in the form of key-value pairs.
- Keys are generally uuids, value can be anything JSON/Blobs.
-
Use Cases: Caching, session management, quick access.
-
Example: Redis, Memcached
-
Graph
- Stores data in the form of nodes and edges.
- highly interconnected data with properties on nodes and edges.
-
Use Cases: Social networks, Recommendation system, relationship unifications.
-
Example: Neo4j, Amazon Neptune
-
Column-Family Stores
- Stores data in the form of tables, rows and columns (way more flexible than RDBMS).
- Each row can have different number of columns. columns are grouped as families.
-
Use Cases: Analytics Workload, logging.
-
Example: Apache Cassandra, ScyllaDB
-
Hierarchical: It stores data in the form of Tree with parent-child relationships. Each child has only one parent i.e. one-to-one relationship (thats what makes it different from graph dbs). It is best suited when data can be structured in to heirachies like manager reporter in a company, telecommunication.
-
Network Databases: It stores info in the form of nodes and edges. while it supports many-to-many, its structure is rigid and hence cannot be changed (thats what makes it different from graph dbs and heirarchical dbs). It is used in Transaction systems, manufacturing management.
-
Object Oriented Databases: It stores info in the form of objects and objects may contain data and methods inside it. Easily integrates with Object-Oriented programming languages. It is used in Scientific applications, tightly coupled applications.
Storage Location : Centralized Vs Distributed Vs Cloud
It is very inmportant to differentiate on how the data is stored and in what geographical places it is stored. This lets one evaluate latency and also impose some policy on the data access and evaluate their Data security and overall Risk.
-
Centralized Databases: Data is stored in a single location. This is mainly used for highly secured and fast access Data over LAN,WAN. As everything is centralized, It reduces redundancy, imposes security, reduces management cost. It is made for low traffic and has sigle-point of failure issue.
-
Example: College Db, Corporate Db(ERP).
-
Distributed Databases: Data is stored in multiple locations. This is mainly used for highly available and reachable Data. As everything is distributed, It increases redundancy, increases scalability, increases management cost. It is made for high traffic and does not have a sigle-point of failure issue.
-
Cloud Databases: Data is stored in cloud(It does not come down when it rains). This is mainly used for highly available and reachable Data with flexible costs. One can use db from cloud and access it over internet. Generally offered as DaaS. With cloud no one has to manage their database and everything is self manageable with a price on it. Many people don’t prefer because they dont have control over the privacy of data(but Daas Companies promise they don’t sell it in such a way that they get caught).
Licensing Model : Open source Vs Commercial
It is very important to see what type of license is their on Db, because it helps one evaluate the type of maintainance one needs to do for it, how many updates and new features will be added to Db, Privacy and risk evaluation.
-
Open source Databases: Dbs whose source code in openly available. One can download and modify it as per their needs. Generally free to use, and has community support with the help of dev forums and discussion boards. One can contribute and help grow the DB. It is ideal for small range businesses whose main concern is to set up a tranparent and customizale DB at a lower cost.
-
Commercial Databases: Companies own these DBs and has pay-to-use subscription plans. Has a setup cost as their is an upfront licensing cost. Vendor provide support so it takes the worry of searching through open source discussions. Ideal for those who prefer all the compliance checks performed on the DBs. Generally used by big enterprises.
Summary
This page give a very brief study of Database and its types. This topic is very big and deep, and whatever written here is not even 0.0001% of that. for more understanding refer(Hell Naah!!) Database internals.
|