What Does Impedance Mismatch Mean?
An object-relational impedance mismatch refers to a range of problems representing data from relational databases in object-oriented programming languages. The term is used by analogy with the electrical engineering term "impedance managing," where the optimal design is in most cases to have the input impedance match the output impedance for maximum power flow.
Techopedia Explains Impedance Mismatch
An impedance mismatch can occur when accessing a relational database in an object-oriented programming language. Problems can arise because object-oriented programming languages like C++ or Python have very different approaches to accessing data.
Some of these differences include:
- Type references. Object-oriented languages make heavy use of by-reference attributes, while this is typically prohibited in relational databases. Scalar types also often differ between database and OO languages.
- In OO languages, objects can be made up of other objects, while this is impossible in relational database languages for integrity.
- Relational databases have well-defined primitive operations for manipulating and querying data, while OO languages have lower-level operations.
- Relational databases have more robust approaches to transactions to preserve atomicity and consistency. The only way to guarantee this through an OO language is at the level of primitive-typed fields.
Methods to mitigate impedance mismatch include using NoSQL databases and designing relational databases with object-oriented programming languages in mind, as well as paying attention to differences between OO languages and relational databases when coding a project.