Which should we use in desogn Java entity? Logic model? Or physics model?

发布时间 2023-12-18 00:39:02作者: BetterMultiply

Generally, we'll edsign database first so that we can design our system more smoothly. But for the beginner of Java, Database and ORM(Object Relation Mapping), it may be confused to decide which Model of database to use as the basic to design our Java entity. So in the article we'll analyse the which is mostly better to use in Java or say, Object Oriented language.

For the reader who may be lack of patience, we'll reveal the answer right now! In most situations, the logic is better to use in designing Java entity, but in some specially conditions the other play a important role.

There are some aspect we can discuss: Data Structure and Relationships, Separation of Concerns and Maintainability and Flexibility.

LOGIC MODEL

  1. is used to deal with the physical aspects of data storage, like table layouts, indexes, data types, and storage strategies in which there is too much detail that is uncessary.

  2. data model and storage details couple tightly will rise the difficulty of modifications and complexity.

  3. base on the physics model makes the whole project of Java code less readable and adaptable. And modification may introduce additional work and potential inconsistencies.

PHYSICS MODEL

  1. is used to represent the logical structure of data and relation, it is independent of any specific physic storage and details of implementions such as type of database etc. Which makes it easier to understand, maintain, and evolve the data models.

  2. it is benifit for the database and java to develop and maintenance independently which can make changes in the logic model can be readily implemented without affecting the database's physical organization, and vice versa.

  3. the object is store in another object directly instead of like the database using the id (FK), to find the object which offered more convenience and flexibility in Java.

Although the Logic Model has lots of benefit and the Physics Model can even rise the hardness of the application design, the Physics Model may sometimes perform better than the Logic Model. For example, In Performance-Critical Application which every microsecond counts, in Resource-Constrained Environments whose storage space or available memory is limited and in Specific Hardware or Database Platforms.

The last of all, we have to mention that

Remember, whenever you are considering to design a Java entity based on database model, you have to judge which matters more, the potential performance gains or the creased complexity and more of flexibility. The choice can only be determined by the project itself and you willing to do better.