How to save in a database, clashes between teams?

2

I would like to know how to save in a table in the database clashes between teams, for example:

TIME A x TIME B
TIME A x TIME C
TIME B x TIME C
    
asked by anonymous 29.07.2015 / 19:11

1 answer

4

An associative table, I believe, would be the most interesting alternative:

CREATE TABLE CONFRONTOS 
(
    ID_CONFRONTO INT PRIMARY KEY,
    ID_TIME_1 INT NOT NULL,
    ID_TIME_2 INT NOT NULL,
    DATA_CONFRONTO DATETIME NOT NULL,
    GOLS_TIME_1 INT NOT NULL,
    GOLS_TIME_2 INT NOT NULL
    -- Aqui você pode colocar FKs, algumas outras coisas de verificação, etc.
)

I made a generic SQL. I do not know what bank you're using, but it's a start.

EDIT

I have no idea what framework you are using, but according to your comment, a join link is missing:

$cons = $fcrud->select('t1.nome, t2.nome, confrontos.gols_time_1, confrontos.gols_time_2', 'confrontos c JOIN times t1 ON t1.id_time = confrontos.id_time_1 JOIN times t2 ON t2.id_time = confrontos.id_time_2', 'ORDER by confrontos.id_confronto DESC',array()); 
$ver = $cons->fetchAll(PDO::FETCH_OBJ); 
    
29.07.2015 / 19:17