Vishnu
Vishnu

Reputation: 2452

Ideal ways to store large number of dates and values in mysql

I am developing a tracker application,So user enter y value and it will be inserted in current date and stored in database as json,Below is some example of data.

{x: "2012,02,1", y: 61},    
{x: "2012,03,1", y: 62}, 
{x: "2014,02,1", y: 63},  
{x: "2012,05,1", y: 61}, 

So what is the ideal way to store data like this.For example I may get 1000's of users and each one have 1000's of entries.

Right now I have set 5mb for longtext in a column and storing all this json..Day by day ,Json size is increasing.Am I doing right or wrong.Enlighten me please.Thank you.

P.s : Users may also change y value based on X value

Upvotes: 0

Views: 66

Answers (1)

Dijkgraaf
Dijkgraaf

Reputation: 11527

The best way to store it would be to parse the JSON into separate fields and store those files as correctly typed fields in the database with one row for each entry in your collection. e.g. an int field for the user and a date field for the date component as well as a unique key auto incrementing. Then you can index it and easily query it.

Edit: See related question Is this an reasonable use case for storing JSON in MySQL?

Upvotes: 1

Related Questions