Multiple values for same attribute

Hi! I want to create a column “productsNumber” and store two values for every product in this column.
I want something like this : productsNumber[“id1”,“quantity1” ; “id2”,“quantity2” ;…;“idn”,“quantityn”]
How should I create this column in the database , and how can I use these values?

It’s a bad design. What qualities are pertinent to the record?

1 Like

you could do this in a columns with type JSON, but i would recommend to use normalization

Yes you can put a json string into the column but you should not. The reason is that you wont be able to query / search or find any of the values that you stored inside your json. So the answer should be: create a new table inside your database and add a foreign key column in the table you already have. The foreign key would reference to the right record in the new table.

Depends. I am the belief of, use a relational table for relational schemes and NoSQL for non relational schemes, but many RDBMS’s have added JSON support including MySQL. It is possible, in 5.7.

https://dev.mysql.com/doc/refman/5.7/en/json.html#json-paths

Sponsor our Newsletter | Privacy Policy | Terms of Service