R
R
rkfddf2021-02-24 17:06:37
SQL
rkfddf, 2021-02-24 17:06:37

What is this type of sql query called?

Through phpmyAdmin I made such a request (football teams and games between them) - 60365c8a82697483204964.png

and this is in the code

CREATE TABLE `game` (
  `id_game` int(11) NOT NULL,
  `date` date NOT NULL,
  `place` varchar(255) NOT NULL,
  `score` varchar(25) NOT NULL,
  `fid_team1` int(11) NOT NULL,
  `fid_team2` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `team` (
  `id_team` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `leaque` varchar(255) NOT NULL,
  `coach` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `game`
  ADD PRIMARY KEY (`id_game`),
  ADD KEY `game_ibfk_1` (`fid_team1`),
  ADD KEY `game_ibfk_2` (`fid_team2`);

-- Индексы таблицы `team`
--
ALTER TABLE `team`
  ADD PRIMARY KEY (`id_team`);


Is this one-to-many relationship? Or is it some other kind of connection?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mletov, 2021-02-24
@rkfddf

Just 2 1-to-many relationships

D
dzmitryIhnatau, 2021-02-26
@dzmitryIhnatau

It is more correct to make an intermediate table for games, in this table create three connected fields, two of them with the id of the teams and the third field to connect with the game

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question