什么是数据库中statictics字段的最佳格式 [英] what is best format for statictics field in database

查看:114
本文介绍了什么是数据库中statictics字段的最佳格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

主要问题是



我可以在product_price表中使用的最佳归档类型是什么?



日期时间



时间戳



或者......



哪种格式最适合它?



我有3张桌子



The main question is

What is best filed type that i can use in table "product_price" ?

Datetime

Timestamp

Or ...

And which format is best for it ?

I have 3 table

1 ) group -----> (group_id,group_name)

2 ) product --->(group_id,product_id,product_name)

3 ) product_price ----> (product_id,price_id,price_value,price_date)





注意:可能在一天内保存多条记录。所以时间也必须以日期格式保存。



表product_price中日期的最佳归档是什么?



我想根据数据库中的日期显示任何图表



(例如参见http://www.kitco.com/charts/livegold.html [ ^ ])



我希望我可以在第一个和最后一个记录之间得到不同(基于日期字段)来自表product_price然后生成用户可以看到图表的可用日期。



示例1)



假设第一个和最后一个记录之间的差异是35天,在这种情况下可用的图表是:





Note : maybe in one day multi records saved . so time must save in date format ,too.

What is best filed(s) for Date in table "product_price" ?

I want to display any charts based on date from my database

(for example see http://www.kitco.com/charts/livegold.html[^])

I want that i can get different between first and last record(based on date field) from table "product_price" And then generate available date that user can see chart .

Example1)

Suppose different between first and last record is 35 days , in this case available chart is :

Today

Yesterday

Last week

Last month





注:最近3个月不可用



例2)



假设第一个和最后一个记录之间的差异是253天,在这种情况下可用的图表是:





Note : Last 3 month not available

Example2 )

Suppose different between first and last record is 253 days , in this case available chart is :

Today

Yesterday

Last week

Last month

Last 3 month

Last 6 month





注:去年不可用



例3)



假设第一个和最后一个记录之间的差异是900天,在这种情况下可用的图表是:





Note : Last year not available

Example3 )

Suppose different between first and last record is 900 days , in this case available chart is :

Today

Yesterday

Last week

Last month

Last 3 month

Last 6 month

Last year

Last 2 year





注:最后3年不可用



最后我再说一遍:主要问题



什么是最好的归档类型我可以在表product_price中使用吗?



日期时间



时间戳



或者...



和哪种格式最适合它?



Note : Last 3 year not available

And Finaly I say Again : The main question

What is best filed type that i can use in table "product_price" ?

Datetime

Timestamp

Or ...

And which format is best for it ?

推荐答案

The DATETIME type is used when you need values that contain both date and time information. MySQL retrieves and displays DATETIME values in 'YYYY-MM-DD HH:MM:SS' format. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'.

...

The TIMESTAMP data type has a range of '1970-01-01 00:00:01' UTC to '2038-01-09 03:14:07' UTC. It has varying properties, depending on the MySQL version and the SQL mode the server is running in.









MySQL中的时间戳通常用于跟踪记录的变化,并且每次更改记录时都会更新提到你必须将字段设计为非null。如果要存储特定值,则应使用日期时间字段。





Timestamps in MySQL generally used to track changes to records, and are often updated every time the record is changed mention that you have to design field as not null. If you want to store a specific value you should use a datetime field.


这篇关于什么是数据库中statictics字段的最佳格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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