Problem with tables

1

I'm trying to make a series site, but I'm suffering to hit the logic of the tables, first I'll explain how I want it to work, the person enters the site, there are the series that pulls the following information from the% so my link that accesses the selected string is thus id(int), id_temp(int, id_temporada), nome_serie, lancamento, audio, thumb_serie , then on page <a href="seriado.php?id=1&id_temp=1">Ver Série</a> I've created two more tables in the database, which are seriado.php and episodios , in the temporadas I have the following fields episodios and in the id(int), id_temp(int), nome_episodio, sinopse, link_video table I have the following fields temporadas

My id(int), id_temp(int), nome_temporada(int) is thus select , (series) select * from series , (episodios) select * from episodios where id = $id or id_temp = $id_temp

    
asked by anonymous 15.05.2018 / 20:36

1 answer

1

Better Normalize the bank as follows:

Series Table : IDSeries Name

As the spy is of the season, soon:

Seasons table: EventID, EventID (FK)

The episode is linked to the season, so:

Episodes table : IDEpodes, Timestamp (FK)

So if you want to select could use the example innerJoins:

Select s. * from series as s inner join seasons t ON s.IDSerie = t.IDSerie left join Episodes E on t.Temporary = e.Temporary.

I used the left join at the end due to the possibility of existing series with no episodes yet.

This is one way to do it.

    
15.05.2018 / 21:57