Databases
When you're building a new system, you need to decide what kind of "filing cabinet" to use. This "filing cabinet" is called a database. A database is a tool that helps you store and find information easily. Just like a toy box where you can put all your toys in different compartments and find them easily, a database helps you put all your information in different sections and find it easily.
There are different types of databases, and each one is good for different things. It's important to choose the right one for your system because it can affect how well your system works and how easily it can grow. Imagine you have a toy box and you want to organize all your toys inside it. Some toys are small and you need to access them quickly like marbles, some toys are big and you want to keep them safe, like a big Lego building, and some toys you want to search through quickly like finding a specific car in a big collection of cars. In this scenario, the toy box is your database and the different types of toys are different types of data. Just like you would use different compartments or drawers in the toy box for different types of toys, you would use different types of databases for different types of data.
- Caching databases, like Redis/Memcached etc, are good for storing information that you need to access quickly, like the score of a game or a news article. You can use it when you need to show the most recent information in real-time. But, it's not good for storing large amounts of data, like all the sales data for a company, because it would be too big to fit in the "filing cabinet". An example of this type of database is Redis. It can handle a lot of requests at the same time, making it very fast. When your system needs to scale, Redis can help by storing the most important information in its memory for quick access, reducing the load on other databases.
- File storage databases, like S3, are good for storing big files like pictures and videos, where idea is to serve the data as it is. Such type of storage is callled Blob srorage.You can use it when you need to store large multimedia files. But, it's not good for storing small pieces of information, like the score of a game, because it's not designed for that. An example of this type of database is S3. It can store very large files and it can be accessed by many people at the same time. When your system needs to scale, S3 can help by distributing the files to multiple servers, so more people can access them at the same time. It can be used with a CDN to deliver the files all over the world.
- Text searching databases, like Elasticsearch, are good for searching for words or phrases in large amounts of text. You can use it when you need to search through a lot of text and find what you're looking for quickly. But, it's not good for storing information that you don't need to search, like the score of a game, because it's not designed for that. An example of this type of database is Elasticsearch. It can search through a lot of text very quickly and it can be accessed by many people at the same time. When your system needs to scale, Elasticsearch can help by distributing the text to multiple servers, so more people can search at the same time.
- Metric databases, like Influx or OpenTSDB, are good for storing information about how a computer or system is working, like how fast it's running or how hot it's getting. You can use it when you need to store and analyze system performance data. But, it's not good for storing information that doesn't change over time, like the score of a game, because it's not designed for that. An example of this type of database is InfluxDB. It can store and analyze performance data very quickly and it can be accessed by many people at the same time. When your system needs to scale, InfluxDB can help by handling a large number of data points, so you can analyze your system's performance in real-time.
- Data for analytics databases, like Hadoop, are good for storing a lot of information that you want to analyze or make reports from, like all the sales data for a company. You can use it when you need to store and analyze large amounts of data. But, it's not good for storing real-time information, like the score of a game, because it's not designed for that. An example of this type of database is Hadoop. It can store and analyze very large amounts of data and it can be accessed by many people at the same time. When your system needs to scale, Hadoop can help by distributing the data to multiple servers, so more people can analyze it at the same time.
- DocumentDB databases, like MongoDB or Couchbase, are good for storing large amounts of unstructured data, like customer information, in a way that can be easily searched and updated. You can use it when you need to store a lot of unstructured data and search through it quickly. But, it's not good for storing structured data, like financial transactions, because it's not designed for that. An example of this type of database is MongoDB. It can store and search through large amounts of unstructured data very quickly and it can be accessed by many people at the same time. When your system needs to scale, MongoDB can help by distributing the data to multiple servers, so more people can access it at the same time.
It's important to note that within each type of database, there are different variations and specific use cases that they excel at. For example, Redis can be used for caching in-memory data, while MongoDB can be used for storing and querying large amounts of semi-structured data. Also important to consider the data structure it follows and the type of database it is, whether it's SQL or NoSQL. SQL databases are more structured and typically use tables, while NoSQL databases are more flexible and can handle unstructured data. Time-series databases are specialized for storing and analyzing time-series data, which is data that is collected at regular intervals.
Another important consideration is the functionality that the database provides, such as indexing, querying, and data manipulation capabilities. For example, a text searching database like Elasticsearch provides powerful search capabilities etc as some points shared above.
In summary, when deciding what database to use for your system, you need to think about the type of data you'll be storing, how you'll be using it, and how big your system will be. Different types of databases are better suited for different types of data and use cases. It's also important to consider the data structure and type of database, as well as the functionality it provides. By considering these factors, you can make an informed decision on which database is the best fit for your system.