2-Tier Architecture vs 3-Tier Architecture in DBMS
This article talks about the architecture of DBMS (Database Management Systems), with their structure, advantages, features, and more.
Join the DZone community and get the full member experience.Join For Free
There are multiple ways to fetch the data stored in the database management system. We have classified the architecture of DBMS based on their structure.
In this article, I will discuss their structure, advantages, features, etc.; multiple architectures are used for various purposes.
Overview of Architecture in DBMS
Understanding 2-tier and 3-tier architecture is quite an important topic, not just for academics or for seeking a good job but also for general awareness related to technology. We will see this difference with the help of real-life examples.
2-Tier Architecture in DBMS
2-tier simple means two layers; here, tier means simply layer. There are 2 layers one is the client layer, The one where the data is stored, i.e., the database server. And another is the Client layer which is basically a machine, That runs the query on the database server and gets the desired data. The client machine has an interface that shows the desired data to the user.
The data from the database server can be fetched using an API in the client machine. Also, API stands for an Application programming interface.
The purpose of API is to get the data from the database server on the interval of pre-defined time and utilize it for various purposes. For example, there are various applications that show the live location of the train, or while using cab services like Ola and Uber, they use google maps API, for which they definitely pay some amount to google. They track the delivery guy or the cab using that API and show it to you. Here you can also observe that the time interval between fetching data using API is very less as we want to get the exact location of our cab. Still, while locating a train, we do not need this high precision so that we can reduce the frequency of data fetching using API.
An API first makes a connection and then writes a query on the interface; a simple query means, I want to fetch a particular data, then the query will go to the database server, and this server will process that query, which means we wrote an application program, an application program means I want to fetch a particular data, and that program can be in any language like simple example if I am writing in Java, then that application program will come to the database server, there it will first get converted to the low-level language because the application program can be in any other language, in high language, we will convert it here, means the server will convert it, process it, and whatever data is demanded in that query, that data Will be given back to the client. This is how the 2-tier architecture actually works. 2-tier is also called client-server architecture.
We have seen the use of the 2-tier architecture in our daily life, like when we book a ticket on Railways, not through the web and other applications. But if I go to the station and fill out the form and reserve the ticket, then the people who are sitting on that side of the window, having a client machine, in that client machine, they will fill the information. They will call the details of that train from the database server about how many seats are available; according to that, whatever the process is, they will process it and make a ticket.
The advantage of this architecture is that it is very simple as there are only 2 layers; maintenance is very easy because there are limited and authorized bank employees, and there is a limited database.
3-Tier Architecture in DBMS
But today, every bank and other organization wants to grow and have more users, manage them with fewer resources, and provide the service 24 X 7. They allow the user to perform all the queries using the web or mobile application. It is quite complex for the database server to process the queries of all the users from high-level language to low-level language and further executing all the queries after authorizing them with this security is another main issue as the user has direct access to the database.
To solve all such problems, we use Tier- 3 architecture. In Tier- 3 architecture, another layer is introduced between the client and server. 3 Tier Architecture means 3 layers arrived. First is the application layer, which we call directly is client layer; the second is the business layer, and the third is the database or data layer.
First of all, the client layer is the same, which means here, all are my users who are normal users like we are also normal users; all of us, by opening the railway's website or the application, our machine, is called a client machine. Now there is an interface running that helps us to make connectivity with the database; An interface is an application that can be in Java, Python, PHP, etc. To support that language or application, there is the business layer, which means that the query from the client machine is processed at the business layer. This reduces the load on the data server.
The request made by us, i.e., the client machine, first goes to the application layer. That application layer verifies it and processes it from the high-level language to the low-level language and then passes that simplified query to the database server. Then the server just gives back the data to the application layer, and it returns the data to the client machine after converting it into the high-level language from the low-level language.
The application layer also avoids the direct interaction of the client machine with the database server, which increases the security of the database server.
After introducing the third layer, i.e., the application layer, the architecture in DBMS has become a little bit complex but efficient and safe. It is a bit harder for us to do the maintenance of the tier 3 architecture. Still, when we are providing service to this user base, we expect to have good resources for maintenance since it is a bit more costly than tier 2 architecture, but still, it is worth the resources.
Opinions expressed by DZone contributors are their own.