Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql key/value store problem

I'm trying to implement a key/value store with mysql

I have a user table that has 2 columns, one for the global ID and one for the serialized data.

Now the problem is that everytime any bit of the user's data changes, I will have to retrieve the serialized data from the db, alter the data, then reserialize it and throw it back into the db. I have to repeat these steps even if there is a very very small change to any of the user's data (since there's no way to update that cell within the db itself)

Basically i'm looking at what solutions people normally use when faced with this problem?

like image 420
TwentyTwo Avatar asked May 12 '26 09:05

TwentyTwo


1 Answers

Maybe you should preprocess your JSON data and insert data as a proper MySQL row separated into fields.

Since your input is JSON, you have various alternatives for converting data:

You mentioned many small changes happen in your case. Where do they occur? Do they happen in a member of a list? A top-level attribute?

If updates occur mainly in list members in a part of your JSON data, then perhaps every member should in fact be represented in a different table as separate rows.

If updates occur in an attribute, then represent it as a field.

I think cost of preprocessing won't hurt in your case.

like image 111
faraday Avatar answered May 13 '26 23:05

faraday



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!