Choosing your Database

Timi - Nov 14 '23 - - Dev Community

In every functioning application, there is a database, whether it is an eCommerce, movie, icon, chat, or health app you would need a database to hold records. Sometimes a database can even be used for the lightest application. But the art of choosing your database is where the role of an engineer comes in.

Developers often argue and boast about their database, which is fun but knowing your database, with their strengths and weaknesses is what makes you a developer. Today we're going to look at some databases and we will discuss how to choose the right database for your next project, without any further interruptions let's begin.


First I'd start with what a database is. Google described a database as an organized collection of data or a type of data store based on the use of a database management system. To make you understand it better, a database is a collection of organized data.

Think of a database as a locker full of records of stuff you love, or your favorite movie.

Databases are used in every application you use on a daily basis. Imagine clicking on save to save your file or going to YouTube to watch a video, right? Well without a database all those won't be possible, no 1. You can't save your file without a database, and YouTube can't store billions if not trillions of videos without a database. Okay, we understand what a database is now, let me walk you through choosing the right database for your next application.


When it comes to picking the right database a lot has to be put into consideration, it takes long planning and engineering work. Let me walk you through a list of plans I made when choosing a database.


Understanding Your App's Requirement.

In order to have a database you need to understand your app, ask yourself these four questions

  1. Would I need to scale this on a daily basis?
  2. How many users do I have right now?
  3. How many users would I be expecting for such an app?
  4. Who is this app for?

Once you're done asking yourself these questions now let's move to the plan.


  1. Database Structure: Evaluate the nature of your data. Is it relational or non-relational? MongoDB with its flexibility, is great for non-relational data, while databases like PostgreSQL excel in handling relational data.

  2. Scalability: Another thing to consider is the scalability requirements of your app. Will it experience significant growth in users? MongoDB's horizontal scaling makes it a strong contender for applications with scalability demands.

  3. Query Complexity: Now consider complex queries... Access the types of queries your app will frequently perform. Some databases, like MySQL, are optimized for complex queries, while others like Redis are designed for quick key-value lookups.

Now that you've understood your app's requirements, there are many more things we need to address like the elephant in the room which is performance. Ah, we all hate it when we open an app or try to perform a search and it takes like up to 4hours to query and retrieve our data. Performance is a great one to look at, so let's address that right now.


Performance Metrics

In performance metrics, we have two lists to look at here, which are read and write speeds and latency tolerance. These two keys play a valuable role in a database. Let's dive in.


  1. Read and Write Speeds: We all know MongoDB is known for its fast write speeds, making it suitable for write-intensive applications. On the other hand, databases like Redis shine in read-intensive scenarios.

  2. Latency Tolerance: If your app requires low-latency data access, you should probably consider databases like Cassandra, designed for distributed, low-latency environments.

Okay, we've dealt with performance metrics, yikes that was some spicy one, but do take time to do your own research and find out everything about your database, we will move on to deployment and maintenance.


Development and Maintenance

Is it easy to deploy and maintain, that's a great question you should ask yourself before choosing a database, most databases are even more complex to set up in a production environment than development, while some are very easy, databases like MongoDB, PlanetScale, Redis, ScallaDB, Firebase Firestore, Supabase PostgreSQL database are easy to setup.

Another thing to put into consideration is, whether is it easy to maintain, what can you do when things start to get rough, when you start experiencing high spikes, and what can you do, you should ask yourself these questions.


Another important subject to note is to choose a database with a driven and active community, you don't want to choose a database only to find out no one is using it, what then would you do when you face issues, who would you ask questions?


Security and Compliance

Always use a secure database, choose a database that is up-to-date with the latest security updates, and so on. Don't say because because of SQL injection is why you are going for NoSQL like MongoDB, The funny thing someone can still exploit a malicious attack on your MongoDB database. Always watch out and keep yourself up to date.


Conclusion

So yeah that's it, make sure to take your time, and do your research before choosing a database for any application you want to build.


Handles


const getSocials = () => {

return {
   X: "https://twitter.com/timi_networks"
   Linkedin: "https://www.linkedin.com/in/treasure-alekhojie/"
}

}

console.log(getSocials())

Enter fullscreen mode Exit fullscreen mode
. . . . . . . . . . . .