OOP and RDBMS do not match, who is to compromise, or find some and spute?

xiaoxiao2021-03-06  15

OOP and RDBMS do not match OOP-oriented theory and RDBMS based on the relationship theory is not a matter, the theory is different, and the mismatch is normal. It mainly has the following performance:

The granularity is a single, and the design of the object is fine. For example, a User object contains an Address object, and attributes such as Country, City, Street in Address. However, for performance, the design particle size of the database table is relatively thick. In the above example, there may be only a USER table, address, and street, etc. as a field.

Polymorphism is the characteristics of OO, inheritance structure is very common, but RDBMS has no polymorphism.

The identification is for Java, the object identifier is Reference, and the general judgment object is the same as the equals () method, and the logo of the line in the database table is the primary key

Association an object is associated with other objects, which is represented by holding other objects, and there is a direction, or a two-way, one-to-one, one-to-many, more. The two table associations in RDBMS are through foreign bids, and only one direction, only one or more, if you need more, you need to add relationships.

The contradiction between OOP and RDBMS is inevitable, just like two brothers quarrel, the days still have to pass, our procedures still have to write. Solve the problem of mismatch, usually the following three strokes:

Coping to RDBMS This is the most common, since you are a "relationship" database, then I don't have OO? The database table structure is built, and I am programmed around these tables. Regardless of the direct SQL or a large number of VOs contain only data, in sum, the process. The advantage is that it is easy to understand so that the programmer is best to find; not enough, there are too many repetition code on the business, it is difficult to maintain, there is no aesthetic, only fatigue. To the OOP compromise, use the object-oriented database, I haven't seen the legendary database, and continue to see in the foreseeable future. Using and sputen mud, appease the two parties, the OOD / OOP is also OO, which is also used in the relational database, find an ORM tool to make the two parties. This may be the best solution, even if you can't solve all the problems, you can solve the problem of 90%, it greatly saves our time and greatly improves the maintenanceability of the system. Everyone knows that the standard in the Java world, ORM practical things is hibernate.

转载请注明原文地址:https://www.9cbs.com/read-44859.html

New Post(0)