Normalization exists essentially to solve redundancies. See some redundancy there?
Address
None shown. Is it possible for the customer to have more than one address? Is it possible for more than one customer to have the same address? If you can, maybe makes sense to apply the normalization in this case. With only one address it makes no sense to make this separation. Neither the second nor any normal form applies.
Note that in the second example you created a table called Cliente Endereço
. Why are you putting an agency address on it? It doesn’t make sense.
Let’s assume that in fact it is an address table in general. Then it would even fit to put the address there. But for that?
Nothing prevents you from having a table only for addresses, but if there is no repetition of the data you are not doing this by normalization. This makes sense if entities may have more than one address or more than one of them have the same address.
I did not enter the normalization of the address table because it does not seem to be the focus of the question and in the presented form may even be normalized, has no data indicating what are the columns, not even the types, could well be ids
of standard data. It may also not be that this.
Agency
A table has been created to separate the agency it belongs to. Again, do you have more than one agency that the client might have? It’s the same question as the address. What do I get? What problem do you think you solved? Normalization needs to solve problems, not cause new ones. I saw no advantage.
Best model
Even these cases can be questioned in modern databases. It does not cost so much to maintain space for more than one address in the entity itself. It is not always a problem to have a very possible repetition of address registration when two entities are at the same address. It’s a matter of pragmatism.
If you can have these cases, strictly speaking, you should normalize, but an experienced developer will analyze how much the effort is worth because it complicates the model by making all the code and performance difficult. So you have to think if it pays off, if it’s so necessary.
On the other hand the whole model may be wrong. This idea of separating entities into customer, supplier, bank, etc. is wrong by nature. At least in the form presented.
Entities are natural and legal persons (separate). Customer, supplier, bank, carrier, seller, employee, etc. are roles that these persons exercise in this organization. These tables should only have data about the roles. The data of the person themselves should be in the tables of legal and physical persons. This is the right thing to do, but again it is pragmatically possible to do otherwise if it makes sense. But you need to choose another way because it’s the best way and not because it’s the only way you know how. Not all cases make sense to separate like this, but in general is the most correct.
I could point out other possible errors in this model. But it would be speculation because it is only right or wrong knowing all the requirements. The mistakes I see would be according to my experience, not with the real case, are could be right or not.
To know how to normalize you need to know the objectives. To be the most correct formally, to be the fastest to develop, to be the easiest to maintain, to be the most performative, to be what the teacher taught or the boss ordered even if it’s not the best, or whatever. You can’t normalize blindly. How far to normalize and where to stop is something you’ll learn over time.
"Would like to"... ?
– Jefferson Quesado
Related: https://answall.com/q/151323/64969
– Jefferson Quesado
Whoa, I just finished editing the ending. So I’m wondering if Cpf leaves the table disrespecting transitivity, because despite seeing it this way, some of my team friends have opinions contrary to mine. From this I would like to understand then if I am wrong and who is wrong and why. Thanks for sharing the link, it helps as an additional study material, but I need help in this specific case.
– Gustavo