What is ORM?
An ORM (Object Relational Mapper) is software that helps translate data between relational database and application code. The structure of data in relational database and data used in application code are not natively compatible. For instance, we use SQL to manipulate data in a relational database, whereas we use other programming languages such as Python, Java, etc. for application code.
Advantages of Using ORM
- ORMs provide a high-level abstraction upon a relational database that allows developers to use programming languages such as Python or Java to manipulate data instead of using SQL directly.
- By being able to use the same programming languages that are used for the application code, it can enhance speed and productivity for web application development.
- ORMs are not tied to a specific relational database, so developers can switch between various databases such as SQLite, MySQL, PostgreSQL, etc.
Disadvantages of Using ORM
- Abstraction upon a relational database may make debugging difficult
- Performance may be reduced potentially
- There may be learning curve for ORM
- For instance, Django ORM has
select_related()
function that allows us to query objects inForeignKey
relationship more efficiently. It’d be a good idea to spend time learning about ORM functions for performance improement.
- For instance, Django ORM has