Categories
English OOP

General Fields for class or database-table definition

When I start to design some table in the database or a class in my solution I always keep thinking if I have forgot some important field that I will need it later during development or it may be needed by my client. So the following fields represents a general view to define anything in the life, to describe it by a name, number, status, dates and other fields:

  • Name (for humans, cars, plants, genes … etc.).
  • ID (even if there’s no ID in reality).
  • A Number. There’re things that have an identification numbers rather than the ID, like car number that would contain non-numeric variables. It’s not recommended to use these keys as primary key and to use it instead of the sequential identity number for many reasons:
    1. Numbers are simpler, narrower and favored in creating clustered indices than characters.
    2. Real life ids are vulnerable to changes, your passport number changes, your car number may change and your identity number may change as well, so you cannot depend on them.
  • Types and classifications, there’re limitless ways to classify objects, the most common is “gender” for humans and majority of popular animals. Sometimes and where classifications are more complicated, then it could be separated in a different object or database table to insure adding details. Types and classification of the object is very wide and diverse but usually, the nature of the system helps in defining it better. It may not useful to save the personality type in the table of personnel in a database of salaries.
  • Status: there should be a status of the object in the system, if it is an object of a user then it could be enabled, disabled. If it’s an object for a student then he/she could be graduated, expelled, stopped or continuing. But for some cases, status would be separated in a different table or object with more date details to have a better idea about it.
  • Date: humans have birthdate, cars have manufacture date…etc.
  • Location: for humans it’s the address, phone number or email, for items in a store it’s the location on the shelf.
  • Description field: a general text field to write description is important for many types of objects.
  • Notes: Although notes are better to be separated in a different field, but it still useful to have a field for notes within the object or database table.

Leave a Reply

Your email address will not be published. Required fields are marked *