Create a table or several in SQL Server?

Asked

Viewed 75 times

1

I have tables in my database: Orcamento, Maquinas, Veiculos and Acessorios.

I need to record the costs of each of them, for example each table will be recorded a daily cost

I create a table called Custo or create a table for each for example Custo_Orcamento, Custo_Maquina, Custo_Veiculo, Custo_Acessorios?

Each of the 4 tables will have the following fields:

idCusto, dataCadastro, idProduto, qtd, vlUnitario

I was thinking of making a single table called Custo and with the same fields plus fields: idDono (1-Budget, 2-Machine, 3-Vehicle and 4-Accessories).

I wanted to know if in this table if you have lots of data stored will not be slow to query than if I created 4 separate tables, or if it would be more organized with the 4 than with just one?

1 answer

1


Each is valid according to the need that has not been specified. Modeling is understanding the problem as a whole, in every detail, in every comma, analyzing what can happen in the future.

Slowing down depends on how you handle it. Even if your tables have several terabytes it will be slow if you know what you are doing, which may be the case since you think separating into tables is the solution for slowness. If the only reason to break up is to be faster, it’s a very wrong decision.

I’m considering the physical model, because logic should never look that way.

If the question was about something else, then we have no answer for missing relevant information to make the decision, but it still doesn’t seem that it makes sense to have several tables.

  • Cool, I’ll make a single table, Thank you

Browser other questions tagged

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