Jump to content
RAGE Multiplayer Community

JSON string vs multiple rows in MYSQL


Recommended Posts

I am working on a phone system.

I've decided to save phone contacts as JSON string in the phone table, cuz its no heavy overload.

When it comes to messages between players, I am not quite sure if I should store huge JSON strings.

What would you do? Something like JSON:

messages: [
	sender: 01234567
    messages: [
    	timestamp: x,
        message: 'xyzxyzxyzxyz'
     	timestamp: x2,
        message: 'xyz2xyz2xyz2',
     }, .....]
	sender: 76543210,
    messages: ....

or would you store multiple rows in database like:


- ID (PK, AI): int
- sender_phone (FK): int
- receiver_phone (FK): int
- timestamp: DateTime
- message: string


With multiple rows its quite easier to maintain when it comes to filter and max limit while a JSON always needs to be deserialized, serialized, ...


Link to comment
Share on other sites

Why you would store JSON Strings to a database when MySQL is made for massive data flows? Even it it makes no difference for you, because your database will never be that huge like a big online portal.. But tell me why you would store them in plain?


Just create different tables at mysql.. eg. "phone_messages", "phone_whatever".. and use your queries or orm's to receive them. After this you create a JSON string at the server side and send it over to the client.


And if you open your messages.. make sure you load up just 5 and if you scroll up or down in your phone.. you load up the next ones.

Edited by DevGrab
  • Like 1
Link to comment
Share on other sites

  • 2 years later...

Multiple rows with dynamic loading as mentioned in one of the previous comments. Use JSON for less important areas of your application. You'll have an easier, faster and more secure experience with RDBs.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...