Object-relational mapping

Object-relational mapping (English object- relational mapping, ORM) is a technique of software development, with a program written in an object-oriented programming language application program can store its objects in a relational database. The program appears then the database as an object- oriented database, which facilitates the programming. This technique is usually implemented with class libraries, such as the ADO.NET Entity Framework, Hibernate Java Language or SQLAlchemy for Python. For Java, there is also a standardized interface, the Java Persistence API.

Principle

Object-oriented programming ( OOP) encapsulate data and behavior in objects, however, put data in relational database tables. The two paradigms are fundamentally different. To encapsulate objects change their state and behavior behind an interface and have a unique identity. Contrast, Relational databases are based on the mathematical concept of the relational algebra. This conceptual opposition was known in the 1990s as object - relational impedance mismatch ..

To resolve the contradiction, or at least mitigate, various solutions have been proposed, such as object-oriented databases or the expansion of programming to relational concepts (eg embedded SQL). The direct object-relational mapping of objects to relations has the advantage that on the one hand, the programming language itself does not need to be extended and on the other relational databases are available as sophisticated software as an established technology in all environments. Disadvantage of this the OOP paradigm oncoming approach is the non- utilization of the strengths and capabilities of a relational database, which is reflected in suboptimal performance.

Basic Techniques

In the simplest case, classes are mapped to tables, each object corresponds to a table row and column for each attribute of a table is reserved. The identity of an object corresponds to the primary key of the table. If an object has a reference to another object, it can be represented by a foreign key relationship to the primary key of the database.

The term shadow information ( " information shadow " ) refers to additional data that requires an object to be stored persistently. These include primary key - especially if it is surrogate key without technical significance - as well as auxiliary data for access control, such as a time stamp.

Mapping of inheritance hierarchies

There are essentially three different methods for mapping inheritance hierarchies to database tables. Some frameworks provide further variations and mixtures of these three basic methods.

Another method is the mapping of structures (relationships, inheritance) and data in general General Tables Tables. The entire database contains exactly 5 tables: one for classes, one for relationships (including inheritance relationships ), one for attributes, one for instances ( of classes ) and one for values ​​( the attributes). However, this method has little practical significance.

611839
de