ORM… WTF???

Relational Model

The relational model focuses on data and their representation. Data are organized in rows and tables. This is a low-level model for databases.

Object Model

Object model focuses on in-memory objects associated with references. Class model especially aims at object encapsulation by behavior.

Relational Database

A relational database is a database based on relational model usually managed by SQL. We use it when we need transactional consistency, data integrity and when we need to join data relationally.

Object-relational mapping

ORM is a technique that maps objects to relational data and back.

Requirements

We must have an object model first. If we don’t have object model and object implementation, we can avoid difficult mapping and use the relational model only.

Common misuses

When we shouldn’t use ORM?

ORM not-Responsibility

ORM isn’t responsible for effective database queries. It shouldn’t produce queries at all. If it produces queries and they aren’t effective, we have to use custom queries and don’t blame the ORM.

No Object Model

It may happen that we don’t have an object model. It may have more reasons, but it just happens. Then we must not create artificial objects just because we can. The same situation is when we think in relations.

No Need for Relational Database

It may happen that we have a nice object model and we need just to store objects as they are. There may be no need for inter-aggregate consistency, transactions or joining data.

TL;DR

References

FOOTE, Keith D. A Review of Different Database Types: Relational versus Non-Relational. DATAVERSITY [online]. 2016 [2018–01–23]. Available: http://www.dataversity.net/review-pros-cons-different-databases-relational-versus-non-relational/.

Contact

Do You have troubles with architecture or DDD? Hire me, I can help you. svatasimara.cz

--

--

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
Svaťa Šimara

Svaťa Šimara

Developer interested in Domain-Driven Design & Modeling