Data modeling for products

0

ImadeadiagramintheWorkbenchaccordingtotheaboveinstructions,it'saboutcontrollingsalesatagrocerystore.

My database teacher said something about not being able to see the price differentiation of products of the same type but different brands. For example: An instant noodle of 2 different brands, in this table, would have the same price (according to him). How can I solve this? A table only for price and an N-M relationship between it and the product table?

    
asked by anonymous 11.11.2018 / 19:47

2 answers

0

Modeling is something that depends on concrete requirements. With artificial requirements anything can be right or wrong. Within my actual experience making systems your model is right because if the brand is different the product is different and must have another registration. It does not make the least sense to try to control objects with different specifications (however minimal, and this is not even minimal, is practically maximal) as if it were one thing.

To do it differently you would need clarity and precision of requirements showing exactly what needs to be done, after all what is being asked is not intuitive and is not what you will have to do in a real scenario. So I preferred to justify this rather than redo the model. It may be that you only needed to justify how registration was best and why this model is appropriate, then your teacher is right, because although it is true that you understood why he is right, it is the same as you do not know, and he wants you know, not only present the result. On the other hand, your teacher may also be wanting to impose his vision and it would only make sense if he had given very clear requirements. He may have given you and you have not asked the question so we can help you more.

If you do not want to confront him, do what he seems to imply just to please you, even though it is probably a mistake. Then I would not even know exactly what to do, a lot could be different, but since they all look wrong, it would be a kick to offer any of them.

I think I would have a 1: N relationship with marcas and everything but id , nome (wow, that sounds so wrong) and categoria would move to this table. To tell you the truth if I take the name, I would take it because the Nissin brand has a name and the brand name Renata has another name, then this product table in the background happens to be a category table and the mark table goes from new be a product table. Something like:

produto
-------
id
nome
categoria

marca
-----
id
produto_id
preço
quantidade
fornecedor_id

Even in real scenario, there is a difference between manufacturer and supplier.

Anyway if I do something right I see several errors in this model, some because it is an exercise and it is not complete. So it needs to be looked at differently. Curiously it seems to accept these various errors of what would be the real scenario, but want to introduce a conceptual error.

I take everything I said if the question is not clear enough.

    
11.11.2018 / 20:32
0

A good strategy is to create a price table, it can contain a brand, but since this is a product attribute, the correct one should be, each product, have a brand, and the same have a reference in the price table, with the id of the product as foreign key the price, and some eventual attribute.

An example of a somewhat more complex database I did:

    
11.11.2018 / 20:31