I create a table or several tables in SQL Server?

1

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

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

I create a table called Custo or create a table for each one 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 more fields: idDono (1-Budget, 2-Machine, 3-Vehicle and 4-Accessory).

I would like to know if in this single table if I have too much data stored it will not be slow to query than if I were to create 4 separate tables, or would I be more organized with 4 than with just one?     

asked by anonymous 08.07.2018 / 17:35

1 answer

1

Each one is valid according to the need that was not specified. Modeling is understanding the problem as a whole, in every detail, in each comma, analyzing what may happen in the future.

Getting slow depends on how you deal with 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 tables is the solution for slowness. If the only reason to separate is to be faster, it is a very wrong decision.

I'm considering the physical model, because the logical should never look this way.

If the doubt was about something else, we can not answer for lacking relevant information to make the decision, but it still does not seem to make sense to have several tables.

    
08.07.2018 / 18:26