Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between an ORM and an ODM?

Tags:

database

orm

odm

People also ask

Is Mongoose an ORM or ODM?

Mongoose is an ODM that provides a straightforward and schema-based solution to model your application data on top of MongoDB's native drivers. It includes built-in type casting, validation (which enhances MongoDB's native document validation), query building, hooks and more.

What is ODM framework?

ODM is Object Document Mapping. It is like an ORM for non-relational databases or distributed databases such as MongoDB, i.e., mapping an object model and NoSQL database (document databases, graph database, etc.).

What is object data modeling ODM?

ODM is a new data model thatintegrates the features of object oriented programming languages (e.g. Smalltalk-80) and Relational Data Model (RDM).

Is MongoDB ORM?

Using MongoDB removes the complex object-relational mapping (ORM) layer that translates objects in code to relational tables. MongoDB's flexible data model also means that your database schema can evolve with business requirements.


MySQL is an example of a relational database - you would use an ORM to translate between your objects in code and the relational representation of the data.

Examples of ORMs are nHibernate, Entity Framework, Dapper and more...

MongoDB is an example of a document database - you would use an ODM to translate between your objects in code and the document representation of the data (if needed).

Mandango is an example of an ODM for MongoDB.


An ORM maps between an Object Model and a Relational Database. An ODM maps between an Object Model and a Document Database. MySQL is not an ORM, it's a Relational Database, more specifically, a SQL Database. MongoDB is not an ODM, it's a Document Database.


Essencially, an ORM use a SQL database Driver like ODBC, JDBC or OLEDB to translate the object notation to relational notation and an ODM use a JSON or JSONB api to translate the Object notation to Document notation.

There are different kind of implementations under the hood.

PS: JSONB is a JSON text document notation stored in a binary format as used by MongoDB.


Mongoose is a good example for ODM(Object Data Model) for MongoDB in which you can directly perform operations with objects and that gets translated into the appropriate query and schema. It can be found Here at https://mongoosejs.com/