Content deleted Content added
No edit summary |
m Disambiguating links to Object-orientation (link changed to Object-oriented programming) using DisamAssist. |
||
(11 intermediate revisions by 10 users not shown) | |||
Line 1:
{{short description|Programming technique}}▼
{{Distinguish|Object–role modeling}}
{{Use dmy dates|date=June 2019}}
{{
'''Object–relational mapping''' ('''ORM''', '''O/RM''', and '''O/R mapping tool''') in [[computer science]] is a [[Computer programming|programming]] technique for converting data between a [[relational database]] and the memory (usually the [[
▲{{short description|Programming technique}}
▲'''Object–relational mapping''' ('''ORM''', '''O/RM''', and '''O/R mapping tool''') in [[computer science]] is a [[Computer programming|programming]] technique for converting data between a [[relational database]] and the [[Memory_management#HEAP|heap]] of an [[object-oriented]] programming language. This creates, in effect, a virtual [[object database]] that can be used from within the programming language.
In [[object-oriented programming]], [[data management|data-management]] tasks act on [[object (computer science)|object]]s that combine [[scalar (computing)|scalar]] values into objects. For example, consider an address book entry that represents a single person along with zero or more phone numbers and zero or more addresses. This could be modeled in an object-oriented implementation by a "Person [[Object (computer science)|object]]" with an [[attribute (computing)|attribute/field]] to hold each data item that the entry comprises: the person's name, a list of phone numbers, and a list of addresses. The list of phone numbers would itself contain "PhoneNumber objects" and so on. Each such address-book entry is treated as a single object by the programming language (it can be referenced by a single variable containing a pointer to the object, for instance). Various [[Method (computer programming)|methods]] can be associated with the object, such as methods to return the preferred phone number, the home address, and so on.
By contrast, relational databases, such as [[SQL]], group scalars into [[tuples]], which are then enumerated in [[Table (database)|tables]]. Tuples and objects have some general similarity, in that they are both ways to collect values into named fields such that the whole collection can be manipulated as a single compound entity. They have many differences, though, in particular: lifecycle management (row insertion and deletion, versus [[
{{cite web |title=What is Object/Relational Mapping? |url=http://www.hibernate.org/about/orm |access-date=27 January 2022 |work=Hibernate Overview |publisher=JBOSS Hibernate |language=en-US}}
</ref>
Line 38:
==Comparison with traditional data access techniques==
Compared to traditional techniques of exchange between an object-oriented language and a relational database, ORM often reduces the amount of code that needs to be written.<ref>
Disadvantages of ORM tools generally stem from the high level of [[Database abstraction layer|abstraction]] obscuring what is actually happening in the implementation code.
==Object-oriented databases==
Line 54:
An alternative to implementing ORM is use of the native procedural languages provided with every major database. These can be called from the client using SQL statements. The [[Data access object|Data Access Object]] (DAO) design pattern is used to abstract these statements and offer a lightweight object-oriented interface to the rest of the application.<ref>{{cite web |last=Feuerstein |first=Steven |author2=Bill Pribyl |date=September 1997 |title=Oracle PL/SQL Programming |url=http://docstore.mik.ua/orelly/oracle/prog2/ch18_05.htm |access-date=23 August 2011 |language=en-US |___location=18.5 Modifying Persistent Objects}}</ref>
ORMs are limited to their predefined functionality, which may not cover all edge cases or database features. They usually mitigate this limitation by providing users with an interface to write raw queries, such as Django ORM.<ref>{{Cite web |title=Performing raw SQL queries {{!}} Django documentation |url=https://docs.djangoproject.com/en/5.1/topics/db/sql/ |access-date=2024-09-08 |website=Django Project |language=en}}</ref>
==See also==▼
▲== See also ==
*[[List of object–relational mapping software]]
*[[Comparison of object–relational mapping software]]
Line 65 ⟶ 67:
*[[Relational model]]
**[[SQL]] (Structured Query Language)
*[[Java Data Objects]] (JDO)
*[[Java Persistence API]] (JPA), now [[Jakarta Persistence]]
*[[Service Data Objects]]
*[[Entity Framework]]
Line 82 ⟶ 85:
{{DEFAULTSORT:Object-Relational Mapping}}
[[Category:
[[Category:Data mapping]]
[[Category:Articles with example C Sharp code]]
|