views:

47

answers:

1

I've been creating rpg game and now I'm doing stock-market for my players that they could buy and sell shares. Stock prices are random and stock prices changes every 20 minutes. So, every change I have to save in mysql in one field because I want to show players graph of last month's changes. For example. first stock price is 100$, then, after 2 hours field looks like: "100-105-98-125-149-135". So, for whole month it would be 3*24*30 = 2160 random numbers. I think I can do more optimal, maybe you have any ideas? Because I'm not sure what to do when month pass and etc. Thank you very much.

btw: my English is quite poor, so I can't tell you all my minds very properly, so sorry. But still I hope you understood smth. If not - ask. It will be pleasure to answer.

+4  A: 

I would recommend one table with the stock information and then another table as a transaction log with each stock price change as a record. You can pull all the rows of a stock for the history and the most recent for the current price.

Scott Gottreu
Great idea, thanks. I will absolutely use it if there is no other suggestions.
hey