Search This Blog

Wednesday, September 26, 2018

Object Relational Mapping (ORM)


(ORM) is a technique that lets you query and manipulate data from a database using an object-oriented paradigm

An ORM library is a completely ordinary library written in your language of choice that encapsulates the code needed to manipulate the data, so you don't use SQL anymore; you interact directly with an object in the same language you're using

E.G.
book_list = new List();
sql = "SELECT book FROM library WHERE author = 'Linus'";
data = query(sql); // I over simplify ...
while (row = data.next())
{
     book = new Book();
     book.setAuthor(row.get('author');
     book_list.add(book);
}
With an ORM library, it would look like this:

book_list = BookTable.query(author="Linus");

Disadvantage of ORM

·         ORM libraries are not lightweight tools;
·         Performance is OK for usual queries, but a SQL master will always do better with his own SQL for big projects.

Example of ORM
Entity Framework

No comments:

Post a Comment


This is a User Friendly Blog.
Simple Interface and Simple Controls are used.
Post your comments so i can modify blog regarding your wish.