Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is difference between a Model and an Entity

I am confused to understand what is the meaning of this words:

Entity, Model, DataModel, ViewModel

Can any body help me to understanding them please? Thank you all.

like image 459
amiry jd Avatar asked Jan 05 '12 14:01

amiry jd


People also ask

Is model and entity are same in spring boot?

Model refers fields bind at UI side while entity represent that fields at DB side like Hibernate have.

What is an entity in data modeling?

An entity represents a specific object (such as a specific customer or order). Each entity must have a unique entity key within an entity set. An entity set is a collection of instances of a specific entity type. Entity sets (and association sets) are logically grouped in an entity container.

What is the difference between an object and an entity?

An entity is something that exists in itself, actually or potentially, concretely or abstractly, physically or not. It needs not be of material existence. In computer science, an object is a location in memory having a value and possibly referenced by an identifier.

What is the difference between an entity and a class?

A class is a template for an object (among other things), and is a very general concept. An entity has more semantic significance and is usually tied to a concept (possibly about a real object for example, an Employee or a Student or a Music Album) and is linked to business logic.


1 Answers

The definition of these terms is quite ambiguous. You will find different definitions at different places.

Entity: An entity represents a single instance of your domain object saved into the database as a record. It has some attributes that we represent as columns in our tables.

Model: A model typically represents a real world object that is related to the problem or domain space. In programming, we create classes to represent objects. These classes, known as models, have some properties and methods (defining objects behavior).

ViewModel: The term ViewModel originates from the MVVM (Model View ViewModel) design pattern. There are instances in which the data to be rendered by the view comes from two different objects. In such scenarios, we create a model class which consists of all properties required by the view. It’s not a domain model but a ViewModel because, a specific view uses it. Also, it doesn’t represent a real world object.

DataModel: In order to solve a problem, objects interact with each other. Some objects share a relationship among them and consequently, form a data model that represents the objects and the relationship between them.

In an application managing customer orders, for instance, if we have a customer and order object then these objects share a many to many relationship between them. The data model is eventually dependent on the way our objects interact with each other. In a database, we see the data model as a network of tables referring to some other tables.

To know more about object relationships visit my blog post: Basics of Object Relationships

For more details visit my blog post: Entity vs Model vs ViewModel vs DataModel

like image 84
Gaurav Gahlot Avatar answered Sep 28 '22 10:09

Gaurav Gahlot