I am creating a model for a web application. Tables have identifier fields as primary keys. My question is, should the identifier be defined as a property of the class?
I am sharing the problem because it is not clear to me whether I should consider the object as a representation of the structure of the table or whether I should consider the table as a means to save the object.
If I take the previous route, then the identifier becomes a property because it is part of the database table structure, however, if I use the latter approach, then the identifier can be considered as a fragment of metadata belonging to the database, which is not strictly part of the object model.
And then we reach the middle. Although the identifier is not actually part of the object I'm trying to model, I understand that the objects are retrieved and stored in the database and that the identifier of the object in the database is crucial for many system operations, so it would be useful to include it to facilitate interaction in which the identifier is used.
I am a solo developer, so I really like some other, perhaps more experienced, perspectives on this issue.
source share