我应该如何整理库存历史数据 [英] How should I orginize stocks history data

查看:51
本文介绍了我应该如何整理库存历史数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是将股票的全部历史记录存储在全球数据库中.

My goal is to store the whole history of the stocks in the global in database.

历史记录是每天的,每只股票的每一行都应包含日期,开盘价,收盘价,最高价,最低价和交易量.

the history is daily and each row of each stock should contain the date, open, close, high, low and volume.

我首先创建一个表,如下所示:

I first though to create a table that will be something like:

id,股票代码,日期,开盘价,收盘价,低价,高价,成交量

id, stock symbol, date, open, close, low, high, volume

但是它将是一个包含数百万行的表,我认为我需要防止这种情况.

but it will be a table with millions of rows what I think I need to prevent.

我认为的另一种解决方案是为每行创建一个表,但是通过这种解决方案,我将获得一个包含数千个表的数据库,这是我认为不对的.

another solution I thought is to create a table for each rows, but with this solution I will get a database with thousands of tables, what I think is wrong to.

推荐答案

绝对符合您的第一个想法-包含数百万行的单个表.尽管听起来很多,但是如果正确使用,任何值得赞扬的数据库软件都应该能够应对.单表方法还具有简单性的优点,并且使一次查询所有数据变得容易.

Definitely go with your first idea - a single table with millions of rows. Although it sounds like a lot, any database software worth its salt should be able to cope with this, if used correctly. The single table approach also has the benefit of simplicity, and makes it easy to query all of your data at once.

相反,如果您有很多表,这将使查询所有数据变得更加复杂,并且可能还要求您随着数据集的扩展而进行正在进行的模式更改,这可能是不希望的.

Conversely, if you had many tables, this would make querying all your data much more complicated, and would also perhaps require you to make ongoing schema changes as your data set broadens, which probably isn't desirable.

这篇关于我应该如何整理库存历史数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆