Information on multiple tables or just one?

Asked

Viewed 43 times

0

I have a lot of information I need stored in the database. Some of that information is something very identical:

Example: hora1, hora2, hora3, ... hora10.

My question is whether I should save everything in the same table or create a table for the information and another one specific to save the hours by placing a Foreign key of the first table in the table of hours.

Later create a view with everything.

What will be better?

1 answer

1

Creates another table to register the hours, since it can be taken into account that the amount of fields would be hora1 .. Horan, so if in a future you need to create another "time" it will just be add a line..

And create another table by making the relationship between your table and the table of hours.

For example

Tabela nome

Id |  Nome
01 | XXXXXX
02 | YYYYYY
03 | WWWWWW

Tabela horas

Id |  Hora
01 | Hora1
02 | Hora2
03 | Hora3


Tabela Relacao NomeHoras

Id | IdNome | IdHora | Valor
01 |   01   |   01   | '00:00'
02 |   01   |   02   | '01:00'
03 |   01   |   03   | '02:00'
04 |   02   |   01   | '03:00'
05 |   03   |   01   | '04:00'

I hope I’ve helped!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.