ORM -Object Relational Mapping
Hi everyone, In this blog we are going to see about what is an ORM.
Object Relational Mapping (ORM) is a technique used in creating a bridge between object-oriented programs and the relational databases.
Wile interacting with a database using OOP languages, we will have to perform different operations like create, read, update and delete(CRUD) data from a database. To do this we will SQL queries to communicate with the database.
For example,
If we have retrieve a user with the id=34 from the USERS table, then the SQL query for that record would be
“SELECT * FROM USERS WHERE ID=34”
The above record is retrieved using the WHERE clause in the SQL query.
The same can be written using the ORM as
users.GetByID(34)
ORM vs SQL:
Web developers use object relational mappers or ORMs to create an abstract layer without modifying the object-oriented paradigm, which reduces the burden of adapting to a storage format’s database specifications.
- Hands-On Management: When it comes to hands-on management, SQL is higher than ORM. It is important to know how to use SQL in order to maximise the benefits and performance of the database.SQL optimisation can be done by learning the various SQL statements like INSERT, CREATE, SELECT, and so on.
- Level of Abstraction: The level of abstraction refers to the system’s complexity when it is programmed or viewed. The higher the abstraction level is, the less detail the databse contains. The level of abstraction is higher in ORM as compared to SQL. It is one of the key principles of ORM along with inheritance and encapsulation.
- Level of Complexity: ORM is more complex than SQL because it has high level of abstraction and less hands-on management.
Advantages of using ORM:
- Speeds-up Development — eliminates the need for repetitve SQLcode.
- Reduces Development Time.
- Reduces Development costs
Disadvantages of Using ORM:
- ORM fails to compete against complex SQL queries.
- ORM has a tendency to be slow.
Hope You find it Useful!! Thank You!!