Data modelling

Named entity

It is an entity that implements the descript able entity and features a field (string) called name.

Use it to implement Enums (see below).

Enums

Postgres and TypeORM support enums.

Business logic will use Enums in order to identify certain conditions.

There will be 2 main types of Enums:

  • business logic or system enums, used for business logic (example: partner types)
  • user definable enums (example: tags for products)

The system enums will be read only. This type of enum can’t be deleted or edited (excepting translation).

Keep enum collections as short as possible in order to avoid annoying the user with too many values that won’t be used.

When seeding the enum collection, their ids should be in the same order as the options appear in the collection. This will facilitate reads where a specific id exists by accessing only the GetGuidFor(enum.item) function of the entity of the enum, without reading the collection from the database. This behavior should be configurable in order to allow local or DB access.

Another option could be to use the name property as a primary key for enums.

Use the translation service to translate the description. The name field of the enums should be constructed (seeded) from a collection used for business logic and should contain the exact names in the collection.

The field name, should be read-only for the enums used by the business logic.