Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Object-Relational Mapping vs Database Abstraction Layer

I'm using Doctrine which provides both ORM and DBAL.

What is difference between them?

How should one decide when to use which?

like image 436
Mohammed H Avatar asked Feb 28 '13 04:02

Mohammed H


People also ask

Is ORM an abstraction?

ORM is a classic example of having leaky abstraction. What are ORMs? Object Relational Mapper is a software framework that implements an object oriented interface (an abstraction) to relational databases.

What is object relational mapping used for?

An object-relational mapper provides an object-oriented layer between relational databases and object-oriented programming languages without having to write SQL queries. It standardizes interfaces reducing boilerplate and speeding development time.

What is ORM database layer?

ORM (Object/Relational Mapper): It is a library/tool that executes the input SQL query (some ORMs also generate the query for you) and converts (maps) output DataReader (or equivalent in other languages) to your strongly typed objects. This is basic feature of any ORM.

What is ORM and give some examples for ORM tools?

ORM stands for Object-Relational Mapping (ORM) is a programming technique for converting data between relational databases and object oriented programming languages such as Java, C#, etc. Sr.No. Let's business code access objects rather than DB tables. Hides details of SQL queries from OO logic.


1 Answers

The DBAL (DataBase Abstraction Layer) is a piece of software that simplifies interaction with SQL databases, by allowing you to use them without worrying about the specific dialects or differences of the different DBMS vendors. It basically allows you to run SQL queries against the DBMS without writing vendor specific SQL.

The ORM (Object Relational Mapper) is a tool that gives you the impression of working with an in-memory data structure represented as an object graph with associated objects. It simplifies application logic related with SQL operations by removing all the SQL and abstracting it into OOP logic. Doctrine 2 ORM simply handles loading and persisting of POPO (Plain Old PHP Objects).

You can find more about this topic on the DBAL documentation and the ORM documentation.

like image 193
Ocramius Avatar answered Oct 04 '22 05:10

Ocramius