What is ORM tool ?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
object with you and you simply say Hey you know I want to save this object and automatically there's there should be some magical things happening behind the scene who will say okay you're storing this object I will store that data in the database without you I have to write the SQL query come back aliens my name is David ready and in this video we'll talk about o r m which stands for object relational mapping now this concept is there in multiple languages if you work on Java python.net doesn't matter this is available the only thing is should we use it and why do we even have to use orm concept now before we talk about when to use it let's talk about what is orm now think about this if you talk about any object oriented programming language or maybe a language which supports object oriented Concepts the most important thing there is object right an object knows something an object does something now when you say object knows something it does that with the help of variables and when you say the object does something it does that with the help of methods now let's talk about the variables here so why do we use variable we use variable to store data of course right the entire software industry is working for information right to store it to retrieve it to process is it now let's say if you store this data in the variable of course you are basically using an object to store that and then while you are using the application the data is there but what if you want to make that data persistent you want to store that data somewhere so that you can use it for a long time and that's where we have a concept of databases right so you want to store this data in the database it can be any relational database it can be Oracle MySQL postgres it doesn't matter if you can store data which is therefore permanent we say that is persistent storage so how do you store this data which is in the object into a database now one of the way you can store data is something called SQL right now when you talk about dbms if you want to work with them specif specifically rdbms we use a language called SQL Now using SQL you can retrieve data you can store data you can update data you can alter the structure of a table you can do everything with the SQL language and it's a very powerful language right that means if you want to be a software developer you need to focus on a language let's say Java or C sharp and in the back end you have to also learn how to work with database with the help of SQL but what if we can just move this part so let's say if we talk about SQL what you normally do is if you want to store a particular object in the database or let's say object details in the database you first of all take all the values in the variable so let's say you have student object in which you have student ID student which is row number and then you have a name you have address let's say favorite subject now all this thing are available in the object format right in the variables format now you want to store that in database so you will use a SQL SQL query you will say insert into student in the bracket you will specify the values let's say roll number 25 name Naveen my favorite subject is let's say Java so you will store everything in this table with the help of SQL query not just for inserting for fetching data as well you will say select query to update something you will use update query right so that means you have to learn SQL as well but what if I say you don't have to learn SQL what if in Java let's start any any programming language you have object with you and you simply say Hey you know I want to save this object and automatically there's there should be some magical things happening behind the scene who will say okay you're storing this object I will store that data in the database without you I have to write the SQL query so basically as a programmer you don't have to write a skill query but behind the scene someone will do it right so your dbms only works with SQL queries so you can't say there's no SQL there is SQL but you as a programmer not writing it so someone has to help us right and that's where we have some tools available now these tools are called orm tools which stands for object relational mapping so use this tool in between you have a Java framework or any any language for that matter and then you have a tool here and then you have a database so you are actually talking to the tool and Tool will store the data in the database who is responsible to make the queries the SQL queries this tool right you don't have to do that but is it really possible can we just save the data in database just by using this object the answer is yes you know if you try to map think about this how do you create object so let's let's talk about Java here in Java if you want to create the object you need a class now this this class is your design the object is the instance for one class you can have multiple object let's say if you talk about students you will create only one student class and you will be having multiple objects so let's say in a classroom you have 20 students you will be having different object for each student will they have a different role number they will have a different name and they will also they might also have a different subject which they like right and if you try to understand the table structure how do you create a tables in database basically you have a box in which you have multiple columns and multiple rows right but if we talk about at the start of the application education you don't have any data right you just have a column structure you have your roll number column you have your name column you have your favorite subject column right so can you say this class and this table they are relatable because the class name is your table name the class variables or the variables you have mentioned there are your columns what about the objects see every time you get a new object they will have different data right so can I say each object becomes one row so let's say if you have 20 objects you got 20 rows here so we are basically trying to relate the object oriented concepts with the database Concepts and that is what called object relational mapping okay so you don't have to do anything as a programmer you will simply say hey orm tool maybe if you talk about Java we have hibernate if you talk about Django which is for python they also have orm concept if you talk about dotnet also they have Entity framework so basically you use this tool in between and you say hey tool this is my object save that in database or then we'll say okay done it or it's done okay so that's how they do it so they they write all the queries for you so behind this and if you check they actually create a select query so if you say hey what I'm framework I have this roll number I want data so basically we use some let's say get methods in this case it will fire a seller query when you say save it will fire a insert query when you say let's just say but the data is already there it will fire the update query okay and what if you say you want to say delete it will fire the delete query so everything is done everything will be done by your orm tool now it's great right it has a lot of flows because as a programmer you are saving your time do we have any cons of this do we have any drawbacks and the answer is yes see the thing is initially when you start using orm you will be very happy but then as your project becomes more complex you will write some you need some complex queries you need to do some complex tasks at that point maybe some orm will not give you that feature of doing extra things and actually you can write the SQL queries as well so example if we talk about JPI which is a specification for Java you can write jpql or hql for hypertainty which is hibernate query language which looks like SQL but then we talk about objects and classes there so yes if you have some customized query you can do that but that's also drawback right ultimately you need to write some queries if you want to do some complex tasks and there is also a debate on speed yes it orm will help you to make your project faster in terms of development but not in terms of running it because every time you call the orm it is taking extra time to create the queries for you so again that's a debate will it really slow down but if you really think about it it might slow down your application but again that's a fraction of second it will not even you will not even realize when you are using it but yes if you do a performance test which a lot of people do where you will hardly see a difference of milliseconds in that is debatable now but yes SQL SQL queries are faster if you write it by yourself and maybe there are some good way of writing SQL queries so let's say if you have experience of let's say 10 years in the SQL or database thing you know what type of query you can write to fetch the data faster but then when you use orm they have their own way of building queries maybe that is not completely optimized again those are debitable but should we really use orm I would say yes is because it helps you to build a product faster and with less bugs because the moment you start writing code as a human you can make mistakes and then ultimately you will spend time resolving it and it's good to save time right so yeah that's about overtime which stands for object relational mapping there are multiple implementations as I mentioned for Java we can use hibernate or any JPI implementation for that matter for Django we have Django or M for dotnet also we have ND Entity framework so basically if you want to know more I will put the links in description for the hibernet for Java and Django orm in the description I hope you enjoyed this video let me in the comment section and do subscribe for the videos bye
Info
Channel: Telusko
Views: 33,727
Rating: undefined out of 5
Keywords: telusko, navin, reddy, tutorial, java, python, blockchain, django
Id: wIp3veR_9Ag
Channel Id: undefined
Length: 9min 59sec (599 seconds)
Published: Sun Feb 26 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.