4
I have a supermarket box application in which after the end of the sale need to insert a record with data related to this sale in a table, in this record must be included the code of the products purchased and the quantity of each.
Since I am using a Mysql database there are no vectors (arrays), how should I proceed in a situation like this? There is a good practice that can be applied to this case?
Here’s what I thought I’d do, but I think this is a scam:
codigo vendedor cod_produtos quant_produtos data
1 3 "1,5,3,6,9" "5,10,7,13,2" 12/12/2013
In this case the fields cod_products and quant_products are of the char/varchar/nvarchar type and if you need to get the data to generate a report or something would use something like string[] codigos = codProdutos.Split(',');
(in C#), to obtain the data in vector form.
You can modify your database?!
– Felipe Oriani
@Felipeoriani yes, anything.
– Zignd
Good practice is to follow the normal forms http://www.luis.blog.br/primeira-forma-normal-1fn-normalize-data.aspx
– rray
There is something called "Normalization". Have a look at: http://www.macoratti.net/cbmd1.htm
– Ecil
Vlw for the tip and @Ecil.
– Zignd
What you would like to do is possible in Nosql banks. In them you can store collections in a field. Relational databases require improved modeling techniques.
– Ecil