1
Considering a scenario where a member has a account, personal profile, academic profile and may vary between status (between pre-defined status: teacher, student and collaborator) within the system. For each status, the academic profile is different.
Following (theoretically) the tables:
MEMBRO
id (PK)
MEM_CONTA
membro_id (PK) (FK) // referencia id em MEMBRO
email (string)
username (string)
senha (string)
MEM_PERFIL
membro_id (PK) (PK) // referencia id em MEMBRO
MEM_PER_PESSOAL
perfil_id (PK) (FK) // referencia membro_id em MEM_PERFIL
nome (string)
descricao (string)
Now my problem: how to allow a member alter your status (for the possible status pre-registered) and thus create a new record for academic profile (concerning your status new) and add additional fields in personal profile?
For that, I imagined:
STATUS
id (PK)
titulo (string)
descricao (string)
MEMBRO_STATUS
membro_id (PK) (FK) // referencia id em MEMBRO
status_id (PK) (FK) // referencia id em STATUS
id (FK)
MEMBRO_PERFIL_PROFESSOR
id (PK) (FK) // referencia id em MEMBRO_STATUS
MEMBRO_PERFIL_PROFESSOR_ACADEMICO
perfil_id (PK) (FK) // referencia id em MEMBRO_PERFIL_PROFESSOR
curso (string)
nivel (string)
entrada (timestamp)
saida (timestamp)
MEMBRO_PERFIL_PROFESSOR_PESSOAL
perfil_id (PK) (FK) // referencia id em MEMBRO_PERFIL_PROFESSOR
url_lattes (string)
MEMBRO_PERFIL_ALUNO
id (PK) (FK) // referencia id em MEMBRO_STATUS
MEMBRO_PERFIL_ALUNO_ACADEMICO
perfil_id (PK) (FK) // referencia id em MEMBRO_PERFIL_ALUNO
bolsa (string)
MEMBRO_PERFIL_ALUNO_PESSOAL
perfil_id (PK) (FK) // referencia id em MEMBRO_PERFIL_ALUNO
url_pessoal (string)
To identify the latter status (active status) of a member, then:
MEMBRO
id (PK)
status_id (FK) // referencia id em MEMBRO_STATUS
About this practice, I have several questions:
Use a third key (such as id) in a relationship table, it is correct?
What data normalization says about this?
There is another way out of this situation?
If you are confused, write in a way that is not confusing. Think, detail the problem. Who knows when you are doing this the answer comes naturally. If it doesn’t come up at least we will have less confusing information to help you. The secret to modeling correctly is to have clarity and only those who know the problem can have it. Think of it as an algorithm. Describe the problem step by step, think about everything that is relevant. Have space, do not save. Give a general description of the problem because it may be that everything is wrong.
– Maniero
The thing I don’t understand is this
id (FK)
. Allid
are confused about what is, the relationship between them, because they have a house that doesn’t follow the pattern of others.– Maniero
@bigown added comments explaining the reference of each
– Alexandre Thebaldi