To register the games of a football league the following tables have been defined:
Time (
id int primary key,
nome char(20),
pontos int,
nroVitorias,
golsMarcados int,
golsSofridos int )
Jogo (
idTime1 int,
idTime2 int,
golsTime1 int,
golsTime2,
primary key (idTime1, idTime2) )
The Time table is preloaded with the data id
and nome
of all the teams that participate in the championship and with all the
remaining zero values. The Games table is empty.
Type the SQL commands to resolve the following requests:
The idTime1
and idTme2
columns should be set to foreign keys by referencing the Time table.
Type the commands to set these 2 foreign keys so that a team that already has some game registered can not be deleted and if the id of a team is changed, their games are preserved.
Is it possible to create a foreign key from a column in a table (Time), referencing two columns in another table (Games)?
Thank you.