MySQL Forums
Forum List  »  Newbie

Json or multiple row
Posted by: Phil Siyam
Date: October 02, 2020 11:00AM

Hi,


I need to store following data :

Traditional I used this table structure since we did not have json field data type :

Key_id, Attr , position
1, A , 1
1, B , 2
2, A, 1
2, B, 2
2, A, 3
3, A, 1
4, A, 1
4, B,2
4, C, 3
4, D, 4

Column Attr can have any combination of Alphabets, each unique combination is assigned key_id.


Each time combination is created I need to check, does combination exists in same order if no insert new combination and assign new unique key_id

Occasionally I have to check in which row alphabet A exists or B exist etc

Table may end up having 150000 rows

I have view that coverts above table to horizontal form using group_concat function

Converting above data in horizontal form :-


1, (A,B)
2, (A,B,A)
3, (A)
4, (A,B,C,D)
5, (A,A,Z)
6, (B,A)

Is it better to store data in table with 2 columns Key_id and attr (json type)? Are there any benefits of one approach over other ?


Json approach will end up lot lesser rows may be 40000 rows

MySQL Ver 8

Thanks in Advance

Options: ReplyQuote


Subject
Written By
Posted
Json or multiple row
October 02, 2020 11:00AM
October 02, 2020 11:07AM
October 07, 2020 08:23PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.