jeudi 16 avril 2020

Inferring state from a DB column which has other purpose

The typical case is when a table has a DATE column named END_DATE that represents the date the entity becomes, let's say, terminated:

CREATE TABLE entity (
id NUMBER GENERATED BY DEFAULT AS IDENTITY,   
start_date DATE,
end_date DATE,
PRIMARY KEY ( id )
);

The implicit state is defined at the code layer which infers from the END_DATE column (which can be null) not only the termination date but also what the current state is (terminated or not).

There's no formal definition in the DB (such as a column or table) to represent what the current state of that entity is unless looking at other purpose columns such as END_DATE and infer the state from there.

What is the name given to this kind of practice/pattern?
Is it a good or bad practice?

Aucun commentaire:

Enregistrer un commentaire