Many things are defined by their identity (uniqueness) and not by their attributes. A very good example is a man with features that can change or disappear completely throughout his life. Both the first and last name as well as the financial status can change, which changes throughout the whole life. The most important feature that can not be changed is the human identity – which is unique. A characteristic property that distinguishes people is the social security numbers (PESEL), through which we define our uniqueness.
In modeling systems, human attributes as an object can be varied. Finally, when a user makes a purchase, a given product may vary depending on his preferences. The application must know which user object has placed the order and inform him about the shipment to a specific e-mail address or phone number. Object modeling forces us to define attributes, but this is not a fundamental concept of entity, which can change forms throughout its lifetime. Two bank transfers for the same amount, to the same bank account are still separate transactions, entities. Defining classes of objects, behaviors and features should indicate their uniqueness. Thus, an entity can be not only a human but an entity with its own identity. An example is a city, a car and a production line.
When creating entity objects, we should pay attention to uncomplicated class definition and to create its uniqueness, while maintaining the possibility of changing its features throughout its life. Behavior should be clear and predictable.
I created an example of a user model in the online store. In Figure 1, Id is the only attribute that defines its uniqueness but after the phone number or contact address – assuming that it can have a maximum of one – we can find it. The diagram should look like in Figure 2
In the second example, the attribute with the contact address and the phone number has been moved to the user object. Is consider to be an attribute thanks to which we can search for a specific object, but everything depends on the domain. If we had a situation where the user may have multiple contact addresses and multiple phone numbers, then the above-mentioned attributes could not be in the user’s class.
Summary
Entity is a unique object located in a system that has its own identity and unique business methods characteristic of it.