ORM explained in 1 minute

Simplification
ORM stands for “Object to Relational Mapping” where

John Hillegass
1 min readOct 15, 2019

Object means the thing that is being held in memory or is in use by your programming language

Relational ( think database ) means the state that it is going to being stored in (table, column, tuple etc.)

Mapping means the translation between the in-memory and the database representation

Programming object being transformed to database object diagram. Example script below.

Example (using Javascript)

function Book(name, author) {
this.title = name,
this.author = author
}
// The object that we will hold in memory
var book = new Book('The Hobbit','JRR Tolkien')
// The database table for storing book data in
CREATE TABLE Books
(
id int NOT NULL AUTO_INCREMENT,
title varchar(255) NOT NULL,
author varchar(255) NOT NULL,
PRIMARY KEY (id)
);
//With an ORM we can easy encapsulate the mapping of each thing and abstract the SQL building//Mapping the person to the books table in DB
orm.save(book)
//Translating intoINSERT INTO Books (title, author) VALUES ('The Hobbit', 'JRR Tolkien');/*
This makes code easy to maintain, read and reason on, though there are some cons as well, such as learning the domain specific language
*/

--

--

John Hillegass
John Hillegass

Written by John Hillegass

DevSecOps @CapitalOne and aspiring coffee roaster. I love playing chess, ukulele and enjoying craft beer. Opinions are my own.

No responses yet