0
I have a situation that I need to ask a question. I have a table as below:
CREATE TABLE confrontos(
id_confrontos INT AUTO_INCREMENT NOT NULL,
dt_confronto DATE NOT NULL,
id_estadios INT NOT NULL,
***id_clubes*** INT NOT NULL,
***id_clubes*** INT NOT NULL,
id_treinadores INT NOT NULL,
escore1 INT NOT NULL,
escore2 INT NOT NULL,
CONSTRAINT PK_confrontos PRIMARY KEY(id_confrontos),
CONSTRAINT FK_confrontos_estadios foreign key (id_estadios)
REFERENCES estadios (id_estadios),
CONSTRAINT FK_confrontos_clubes foreign key (id_clubes)
REFERENCES clubes (id_clubes),
CONSTRAINT FK_confrontos_treinadores foreign key (id_treinadores)
REFERENCES treinadores (id_treinadores)
);
I have seen that Mysql does not allow creating this table by duplicity in the field id_clubes
. What would be the best way to create this table?
It depends on what you need to do. Why the table would have two columns with
id_clubes
? Why not rename columns toclube_a
andclube_b
, for example?– Woss
do as you did with the
escore
.. useid_clube1
orid_clube_mandante
or something like..– rLinhares
in case the problem is the duplication of the name... you can change to Ex: id_clube_sending and id_clube_visitor
– Leandro Angelo
Or... you create a relationship chart
[Id_Confronto | id_Clube]
and so you can haveN
clubs in the same match :P– Leandro Angelo
Thanks guys for the tips, I’ll test here
– Carlos Henrique Eltz