Why should we prefer Django ORM rather than SQL/MySQL

Introduction

ORM Features and Advantages

  • SQL/MySQL Database creation through MySQL or SQL Server;
  • four-tier architecture (i.e. frontend, login, application and database);
  • easy to use and learn; support for JOIN operations;
  • relational data model (1: many, many: 1 relations);
  • a constraint-based approach to enforce business rules by means of unique keys, primary keys, foreign keys, and referential integrity. No need to modify your models when you change the database structure. Django ORM Create tables in the underlying DBMS through a set of shell commands;
  • deploy in three-tier architecture (i.e. frontend, login, application, and database);
  • restrict data access to the web tier;
  • a declarative approach to define business rules and validation through model classes;
  • automatically generates SQL code to manipulate database and stores in an intermediate cache layer;
  • allow changes to the database and models without requiring a change in code.
  • SQL/MySQL High performance, scalable;
  • easy to use. Django ORM Manage complex business rules through a class-based approach.

Disadvantages/Caveats

  • SQL/MySQL Requires time-consuming middleware development. Requires effort to extend database schema when models change. Django ORM is Quite slow for objects that require many queries (e.g. many-to-many relationships);
  • difficult to modify database structure; doesn’t support transactions or foreign keys.
  • Since we already mentioned that SQL/MySQL is quite slow for objects that require many queries, Django ORM is an ideal choice for these types of applications. But, as illustrated above, there are some disadvantages and caveats that you should consider before declaring your final decision.
  • Django ORM has a lot of advantages compared to the SQL approach: a declarative approach to define business rules and validation through model classes;
  • automatically generates SQL code to manipulate database and stores in an intermediate cache layer;
  • allow changes to the database and models without requiring a change in code.

The Good: MySql/SQL

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store