Transcript for:
Understanding 2 and 3 Tier Architectures

Hello friends, welcome to Gate Smashers The topic is 2 tier and 3 tier architecture in DBMS. Before we start with the topic, I just want to request you all to please subscribe my channel, if you have not subscribed. And please press the bell button, so you will get the latest notifications about my videos. So here we are talking about 2 tier and 3 tier architecture, which is quite an important topic. & many times it is generally asked in theory, but as a CSE student, you should know how actually it works. & We will explain this from the real life example, so here first i am talking about 2 tier architecture. 2 tier simple means two layer, here tier means simply layer. There are 2 layers one is client layer, another one is database server. Client layer means client is a machine, one machine is a client, actually what's in that machine, interface. There is an interface which is helping me to fetching the data from this database server, so that means some API is running on the client machine, which we call in technical term API, So that API, a interface is running here and that API creates a connection to the database through JDBC-ODBC, because if this machine and this database server, not necessarily wired, means they are directly connected, maybe the client is at different location And the server is at different location. So both of them will first make a connection and then write a query on the interface, 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, 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, it will process and execute there, why? 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 & 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 also called client server architecture. Here i am telling you a simple example where you must have seen about. Almost you all saw the 2 tier architecture. if I give a simple example of Indian Railways, in today's time, if we use this application or by using web browser, by using web application, we get our ticket reservation done. But if I go to the station & fill the form and reserve my ticket, then the people who are sitting on that side of the window, What they are doing? they have a machine, what is that machine, client machine, in that client machine, they will fill my information, date of journey etc. Whatever I have in that particular slip. After filling that information, they will call the details of that train from the database server, how many seats are available, according to that whatever the process is, they will process make a ticket and give it to me, Similarly, if we talk about bank, in the bank, if I go there physically and fill the form in the bank and do credit or debit, then when we fill the form and give it to the tailer or clerk, then that clerk also fill that information on their machine, that machine is client machine, that information will go to whom, to server. what is in the server? my account details. Now I want to withdraw ₹ 10000 from my account. So first check will be done whether there is ₹10000 in the account or not. So it will be the check first, how will it be checked? same way, the request will be the responsed and then the finally my transaction or query will be completed. Now if we see the advantage of this architecture, it is a very simple architecture, there are 2 layers, maintenance which is very easy because there is limited client & they are limited clients or authorized clients, authorized means because those who are working in the bank, they have come only through particular job, means they have been properly recruited. So there is limited clients, there is limited database, we are accessing them, that is why maintenance is very easy. But if we talk about today's time, then What is the problem with the scalability, which means my users are not limited. My users are in huge amount, at that time this architecture fails, where my number of users are in huge amount in huge number, and they are accessing the data at any time means 24*7 they can access the data at any time, from any location, and can access any amount of data. So when all these values, all these rules comes, then at that time this architecture failed. Apart from this, security, First is scalability, Second what, i told Security. These are the problems. & what is the advantage in it, Maintenance Maintenance is the biggest advantage in this, maintenance is an advantage. So here if we talk about security how security is the disadvantage here because the client is directly interacting with the database and that is vulnerability, because if the client will directly interact with the database, then definetly they can create a problem, That's why in today's time, we have shifted from 2 tier architecture to 3 tier architecture, it doesn't mean that it is not used, it is still used but which is more used 3 Tier Architecture. 3 Tier Architecture means 3 layers arrived. First is application layer, which we are call client layer, second is a business layer and third is database or data layer. First of all, client layer are same, means here all are my users who are normal users like we are also normal users, All of us by opening the irctc website or the application, when we access our machine, that is called a client machine. Now What's actually going on in that machine, an interface is running. What is that interface helping me, that interface is helping me to make connectivity with the database, that means getting me interacting with the database, so when the interface is open, in which I check the information of the train Or if I talk about banking, then my account number comes there, whether to add beneficiary or transfer the amount, then everything my interface provides to me. Now that interface is an application that application can be in java also, it can be in PHP also, there are lots of languages. To support that languages or applications, there is business layer, means here is interface but who is supporting that interface, business layer. Means whatever the query I am writing here, where will that query be processed, at the business layer. Here, where was the query being processed, here on the database server. So here the database server is at little Risk, risk means or we can say it is in bottle neck state, bottle neck means have given a lot of load, There are lots of load, all the clients asking to data server, to do my query, process my query. The database server is processing the query and also picking up the data and give, so because of this, what can be the problem here, that it can come in the bottle neck state. But here No matter the number of users here, we are not giving load to the database server. We have put a business layer in the middle, as many as we are writing application programs here, as many as I am writing application programs here. Nowadays There is no need to write application programs, we use the interface. When you use the interface of IRCTC or banking, have you ever write programs there, No. There are checkboxes, there are buttons attached, there are boxes, there you fill in the simple information, your query automatically generated there. You don't even know that it is going in the form of a query. when you open the interface and there you fill the account number, amount, OTP etc., then that query in form of an application program comes to the business layer. Business layer processes that application program means it's works as an intermediator. So the database server Direct gets fully cooked question mean it gets proper answer, that yes I want this particular data. So we have reduced the load on the database server. There is no need to process it. The query properly processed, all the checks are being done, after converting it into complete low level language, by converting it into machine language, we are giving to the data layer. Now we will pick up that particular information or data from the data layer and give it to the business layer and that business layer again that value, because the user in the same form in which the user is demanding data, has to show the output. When you use the interface, the interface you are using, information should also come on the same interface and in the same format, so for that here business layer is working as an intermediator. So that's why here is the biggest advantage of scalability, as many as users are there, who will process the query of all the users, Business layer or application server. We put a dedicated application server, that application server will process all the queries, after processing, to whom will it give to the data layer, all the data is here. If we talk about relational database, then we can say that the data is in the form of the table, from there we will pick the data and give that data back to the user, so here we also got the advantage of scalability. Second is security, look at the security, the user is here and the data is there. So the data is never directly interacted with the user, there is a business layer in the middle, which means that the user does not know actually where is the data? And this is the biggest advantage here, we can also compare it with cloud computing. But I don't want to confuse you too much So let me give you a simple example, Gmail, you keep your mails, etc., you are logged in to IRCTC, you know where are your data?, where is the location, No and we don't even know about this thing, why? Because what we are, a normal user, when we go to our mail, in the application, whenever we want to fetch our data, our data is shown to us in a very short time, when we want to transfer the data with a very small amount of time, data has been transferred, so That's what users want. So that's why we did not get the user interacted directly with the data, they interacts only through the business layer. So here scalability also my advantage, security is also my advantage. But yes, Maintenance which was the advantage here, that's a bit of a problem here because you increase the number of devices, the more layers you increase, the more complex the system will become. This system becomes a bit complex because 3 layers come, so when three layers come, then your maintenance will also be alittle more. But in today's time, we are keeping security and scalability at high end, for maintenance we are thinking that we have enough man power, enough money, so we don't have any problem with that but user data is 24 *7 should be available, should be secure. This is the biggest demand of the user in today's time. So that's why whatever the 3 tier architecture you are using, all the web applications are kind of 3 tier architecture And if you are getting any work done by going to the bank or you are getting some work done by going to IRCTC or Indian Railways then you can simply call it 2 tier architecture. So this is the main difference between 2 tier architecture and 3 Tier Architecture. Thank you