建议的存储股票价格的架构
我已经用尽了我的谷歌搜索功能,但无法得到任何答案,所以我想我应该在这里问。
[背景] 我经营一个以美式橄榄球视频游戏(BloodBowl)为中心的论坛。每个成员都有自己的球队,我们负责联赛和杯赛。我认为为网站编写一些“股票和股票”功能会很有趣,这样每个成员都可以投资其他团队。价格会在每场比赛结束后更新(每周约 100 场比赛),但实际更新将是异步的(我有在正确时间触发的当前代码,因此可以对其进行修改以合并所需的内容。 [/background]
基本上,我需要记录每个团队(资产)每次更改的价格,异步更新,但每周仅更新一次。有 200 支球队,一个赛季有 12 周,我每个赛季都会查看 2400 条记录(这将趋于无穷大,尽管周是现实生活中的周,所以不会太大)。
我的想法是单个表,例如:
[teamID] Int
[价格]整数
[日期]日期
[股息]整数
[增益]整数
[增益%]浮动(2dp)
[comment] Text
哪一行应该是我的主键?
我是不是想太多了?我应该直接编码吗?我担心的是,我希望能够获得历史数据,例如图表等,尽管当玩家交易股票时我会经常点击这个表。我不想对其进行编码,后来意识到我缺少一些字段,这些字段将使我的所有查询变得更加高效。
我想我真正要寻找的是一些数据库所使用的模式,这些数据库实际上将其用于现实生活中的股票,只是以类似的方式对其进行建模。
感谢您的阅读,我希望有人能在这里提供一些意见。
问候, 担
I've exhausted my google-fu and cannot get anything like an answer, so I thought I'd ask here.
[background]
I run a forum centered around an American Football based video game (BloodBowl). Each member has their own team, and we run leagues and cups. I thought it would be fun to write some 'stocks and shares' functionality for a site, so each member can invest in other teams. Prices would update after each game is played (~100 games per week), but the actual update would be asynchronous (I have current code triggering at the correct time, so it can be modified to incorporate what is needed.
[/background]
Basically, I need to record the prices that each team (asset) has at each change, updated asynchronously but only once per week. With 200 teams, and 12 weeks to a season, I'd be looking at 2400 records per season (and this will run into infinity, though weeks are real-life weeks, so not too big).
My thinking is a single table, such as :
[teamID] Int
[price] Int
[date] Date
[dividend] Int
[gain] Int
[gain%] float(2dp)
[comment] Text
Which row(s) should be my primary key?
Am I over-thinking this? Should I just code it? My worry is that I want to be able to get historical data, for example for graphs and such, though I would be hitting this table very regularly as players trade stocks. I don't want to code it and later realise that I'm missing some field that would make all of my queries massively more efficient.
What I suppose I'm really looking for is the schema used by some db that actually uses this for stocks in real life, just to model it in a similar way.
Thanks for reading, and I hope that somebody has some input here.
Regards,
Dan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您看过任何在线投资组合跟踪器吗?
我的有以下列:
希望这对一些人有帮助......
Have you looked at any online portfolio trackers?
Mine has the following columns:
Hope this helps some...