When designing a modern application, chances are that you will need a database to store data. There are many ways to architect software solutions that use a database, depending on how your application will use this data. In this article, we will cover the different types of database architecture and describe in greater detail a three-tier application architecture, which is extensively used in modern web applications.
Database architecture describes how a database management system (DBMS) will be integrated with your application. When designing a database architecture, you must make decisions that will change how your applications are created.
First, decide on the type of database you would like to use. The database could be centralized or decentralized. Centralized databases are typically used for regular web applications and will be the focus of this article. Decentralized databases, such as blockchain databases, might require a different architecture.
Once you’ve decided the type of database you want to use, you can determine the type of architecture you want to use. Typically, these are categorized into single-tier or multi-tier applications.
When we talk about database architectures, we refer to the number of tiers an application has.
In 1-tier architecture, the database and any application interfacing with the database are kept on a single server or device. Because there are no network delays involved, this is generally a fast way to access data.
An example of a 1-tier architecture would be a mobile application that uses Realm, the open-source mobile database by MongoDB, as a local database. In that case, both the application and the database are running on the user’s mobile device.
2-tier architectures consist of multiple clients connecting directly to the database. This architecture is also known as client-server architecture.
This architecture used to be more common when a desktop application would connect to a single database hosted on an on-premise database server—for example, an in-house customer relationship management (CRM) that connects to an Access database.
Most modern web applications use a 3-tier architecture. In this architecture, the clients connect to a back end, which in turn connects to the database. Using this approach has many benefits:
Security: Keeping the database connection open to a single back end reduces the risks of being hacked.
Scalability: Because each layer operates independently, it is easier to scale parts of the application.
Faster deployment: Having multiple tiers makes it easier to have a separation of concerns and to follow cloud-native best practices, including better continuous delivery processes.
An example of this type of architecture would be a React application that connects to a Node.js back end. The Node.js back end processes the requests and fetches the necessary information from a database such as MongoDB Atlas, using the native driver. This architecture is described in greater detail in the next section.
The most common DBMS architecture used in modern application development is the 3-tier model. Since it’s so popular, let’s look at what this architecture looks like with MongoDB Atlas.
As you can see in this diagram, the 3-tier architecture comprises the data, application, and presentation levels.
As the name suggests, the data layer is where the data resides. In the scenario above, the data is stored in a MongoDB Atlas database hosted on any public cloud—or across multiple clouds, if needed. The only responsibility of this layer is to keep the data accessible for the application layer and run the queries efficiently.
The application tier is in charge of communicating with the database. To ensure secure access to the data, requests are initiated from this tier. In a modern web application, this would be your API. A back-end application built with Node.js (or any other programming language with a native driver) makes requests to the database and relays the information back to the clients.
In this article, you’ve learned about the different types of database architecture. A 3-tier architecture is your go-to solution for most modern web applications. However, there are other topologies that you might want to explore. For example, the type of database you use could be a dedicated or a serverless instance, depending on your predicted usage model. You could also supplement your database with data lakes or even online archiving to make the best use of your hardware resources. If you are ready to concretize your database architecture, why not try MongoDB Atlas, the database-as-a-service solution from MongoDB? Using the realm-web SDK, you can even host all three tiers of your web application on MongoDB Atlas.
When we talk about database architectures, we refer to the number of tiers an application has. Database architectures can have a single tier or multiple tiers.
In a 3-tier database architecture, the different layers are:
There are many different ways to architect a DBMS solution. Generally, the architecture would be one of the following: