OR Mapping
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<message>Write the content here to display this box</message>
<message>Write the content here to display this box</message>
Object-relational mapping (also ORM and O/R Mapping) is a technique used in software engineering to bridge the gap between '''object-oriented programming (OOP)''' and '''relational databases'''. OR Mapping converts data between a database and an object-oriented programming language.
Object-relational mapping (also ORM and O/R Mapping) is a technique used in software engineering to bridge the gap between object-oriented programming (OOP) and relational databases. OR Mapping converts data between a database and an object-oriented programming language.


ORM allows developers to work with database records as if they were '''objects''' in their programming language, abstracting away the complexities of SQL queries and database interactions.
ORM allows developers to work with database records as if they were objects in their programming language, abstracting away the complexities of SQL queries and database interactions.


==== How Does ORM Work? ====
=== How Does ORM Work? ===
 
* '''Mapping''': ORM maps database tables to classes (objects) in the application code.
* '''Mapping''': ORM maps '''database tables''' to '''classes''' (objects) in the application code.
* '''CRUD Operations''': Developers can perform '''CRUD (Create, Read, Update, Delete)''' operations on objects, and the ORM translates these actions into corresponding SQL statements.
* '''CRUD Operations''': Developers can perform '''CRUD (Create, Read, Update, Delete)''' operations on objects, and the ORM translates these actions into corresponding SQL statements.
* '''Relationships''': ORM handles '''relationships''' (such as one-to-many, many-to-many) between objects and their associated database tables.
* '''Relationships''': ORM handles relationships (such as one-to-many, many-to-many) between objects and their associated database tables.
 
==== Benefits of ORM: ====


=== Benefits of ORM: ===
* '''Productivity''': Developers can focus on business logic rather than writing raw SQL queries.
* '''Productivity''': Developers can focus on business logic rather than writing raw SQL queries.
* '''Portability''': ORM makes it easier to switch between different database systems (e.g., MySQL, PostgreSQL, SQLite) without changing application code.
* '''Portability''': ORM makes it easier to switch between different database systems (e.g., MySQL, PostgreSQL, SQLite) without changing application code.
Line 18: Line 16:
ORM simplifies database interactions by allowing developers to work with objects in their code, while the ORM handles the underlying database operations. It’s a powerful tool for building robust and maintainable software systems.  
ORM simplifies database interactions by allowing developers to work with objects in their code, while the ORM handles the underlying database operations. It’s a powerful tool for building robust and maintainable software systems.  


==== Other OR mappers ====
=== Other OR mappers ===
[https://learn.microsoft.com/en-us/aspnet/entity-framework Entity framework] from Microsoft, [https://hibernate.org/orm/ Hibernate] for Java or .net or Django's ORM are all OR mappers, although simpler than MDriven's OR mapper and all lacking modelling support.
[https://learn.microsoft.com/en-us/aspnet/entity-framework Entity framework] from Microsoft, [https://hibernate.org/orm/ Hibernate] for Java or .net or Django's ORM are all OR mappers, although simpler than MDriven's OR mapper and all lacking modelling support.


'''Learn more here:''' [[wikipedia:Object–relational_mapping|Object–relational mapping on Wikipedia]]  
'''Learn more here:''' [[wikipedia:Object–relational_mapping|Object–relational mapping]]


See also: [[Documentation:Type mapping, OR-Mapping|Type mapping, OR-Mapping]], [[Documentation:Working with Code and Persistence Mapping|Working with Code and Persistence Mapping]]
See also: [[Documentation:Type mapping, OR-Mapping|Type mapping, OR-Mapping]], [[Documentation:Working with Code and Persistence Mapping|Working with Code and Persistence Mapping]]
[[Category:Advanced]]
[[Category:Database]]
[[Category:Database]]
[[Category:ORMapping]]

Latest revision as of 05:57, 24 June 2024

Object-relational mapping (also ORM and O/R Mapping) is a technique used in software engineering to bridge the gap between object-oriented programming (OOP) and relational databases. OR Mapping converts data between a database and an object-oriented programming language.

ORM allows developers to work with database records as if they were objects in their programming language, abstracting away the complexities of SQL queries and database interactions.

How Does ORM Work?

  • Mapping: ORM maps database tables to classes (objects) in the application code.
  • CRUD Operations: Developers can perform CRUD (Create, Read, Update, Delete) operations on objects, and the ORM translates these actions into corresponding SQL statements.
  • Relationships: ORM handles relationships (such as one-to-many, many-to-many) between objects and their associated database tables.

Benefits of ORM:

  • Productivity: Developers can focus on business logic rather than writing raw SQL queries.
  • Portability: ORM makes it easier to switch between different database systems (e.g., MySQL, PostgreSQL, SQLite) without changing application code.
  • Security: ORM helps prevent SQL injection attacks by parameterizing queries.
  • Abstraction: Developers work with objects, abstracting away low-level database details.

ORM simplifies database interactions by allowing developers to work with objects in their code, while the ORM handles the underlying database operations. It’s a powerful tool for building robust and maintainable software systems.

Other OR mappers

Entity framework from Microsoft, Hibernate for Java or .net or Django's ORM are all OR mappers, although simpler than MDriven's OR mapper and all lacking modelling support.

Learn more here: Object–relational mapping

See also: Type mapping, OR-Mapping, Working with Code and Persistence Mapping

This page was edited 5 days ago on 06/24/2024. What links here