I have 3 tables that are linked:
1ª tabela:
GRADE (grade de horários)
Campos: ID - GRADE - ESTADO - VALIDADE
2ª tabela:
BLOCOS (blocos de horários da grade)
Campos: ID - ID_GRADE - BLOCO - DIA_SEMANA - DURACAO
3ª Tabela:
COMERCIAIS
resumidamente estes campos: ID, ID_CLENTE, ID_GRADE, ID_BLOCO
I'm using a FK
to bind the IDs to their respective references in the tables.
My question is: In the 3rd table can be to see the foreign key ID_GRADE
, which is also in the 2nd and I put it thinking of reducing the load in the database, because if by chance I try to put the table GRADE in ESTADO-> desativado
, the system will first check if there is any record to run before changing its state to disabled.
I know I could do this using JOIN
in the BLOCKS table, but I think if I can save ID_GRADE
, I avoid using JOIN
, since the COMMERCIAL table will have many records.
Is my thinking correct or am I creating atoa fields?