I'm not sure about Object-relational_impedance_mismatch?

http://en.wikipedia.org/wiki/Object-relational_impedance_mismatch

I worked with several projects, and all of them used a database-oriented design, and it seems to work fine.

It seems that the new idea is flourishing, and now it seems beautiful, but its value is being tested or am I mistaken?

+4
source share
3 answers

The idea of ​​an object-relational mismatch arises from problems that arise when trying to use the object-oriented programming approach supported by a relational database. The problem arises because object models usually contain hierarchies of objects that need to be shredded and rebuilt from several tables, rather than storing the whole object.

However, the argument that usually arises at this point is that if you did not find a problem, then this is your mistake because you are not following the β€œcorrect” object-oriented orientation and that you will find a mismatch when you learn to do object orientation "right". And we all know that object orientation is the only "right" development paradigm.

Oh wait.

Many systems are not suitable for modeling as object-oriented systems. In fact, for things like web applications that have low overall complexity (with a localized high degree of complexity) and require high concurrency and scalability, using service-oriented and messaging methods may be the best option. When the application is written in this way, you find that there is not too much relational object mismatch, because you are not using things like lazy loading and complex object hierarchies, and your objects are immutable, so they do not need to be chopped back to the database.

So, is there an object-relational mismatch? Yes, if you try to use object-oriented methods with a relational database. But you can soften it by not using object-oriented methods if other approaches are better suited to your application.

+3
source

The mismatch in the impedance of object relations is due to the difference between relational databases and object-oriented software models. If you do not see any inconsistency, it is because your code does not really perform OO properly.

When you start OO correctly and try to map these relationships to an RDBMS, you will understand the problem.

0
source

If your domain model is simple and has no deep inheritance, you will never feel the impedance mismatch.

As an example, suppose that the class Foo defines the foo property. Bar subclasses Foo and introduces the property bar. How do you store Foos and Bars in a database?

You may have a table Foo that contains the fields foo and bar ... and each Foo will satisfy "bar IS NULL". But if your subclass introduces a whole bunch of properties, it is wasteful.

So, maybe you have two tables Foo and Bar. Do you copy all the columns in Foo to Bar so that you can load the entire panel into a single SELECT? Or do you need to JOIN Foo using Bar to load a panel?

Resistance refers to the fact that you have to think about all these small details about how you β€œcloned” (use the term Greg Beach) into one or more tables.

0
source

Source: https://habr.com/ru/post/1302213/


All Articles