I am going to comment on the scenario that I currently have when designing my database.
I have the following tables:
user (id, name, lastname)
role (id, name)
user_role (user_id, role_id, from_date, to_date)
period (id, name, from_date, to_date)
The period table serves as a data master to know the name of the periods that I define in my application.
In this case I mention only the user
, role
and user_role
tables, but there are many more tables that have periods.
The intention of the period table is to act as a labeling system for the different periods that exist in the tables of my model. This table is not related in any way by any foreign key with other tables. To do the searches and relate other tables to this, a join is made using dates from and dates to.
For example, a tuple of the user_role
table can have a date from and a date until that covers several periods defined in the period table, so it would be labeled with the names of the periods it comprises.
Is it okay for the period
table to be an unrelated table? It only serves to give names to the periods, that's why I put it this way. Can you think of another better way to raise it? Should the period table be related to the other tables in some other way?
Thanks in advance.