数据库设计的问题,年月日是三个字段好还是int(eg.20130717)?

浏览:1079 发布日期:2013/07/17 分类:求助交流 关键字: php mysql 数据结构
数据库设计的问题,年月日是三个字段好还是int(eg.20130717)?

目前是这样的需求,就是类似日志的功能,每天一条记录,但是不同类型的对象都有一条记录。
比如id        type        content        date
1        1        success        20130705
2        2        success        20130705
3        1        success        20130706
4        2        failed        20130706
5        1        success        20130707




id        type        content        year        month        day
1        1        success        2013        7        5
2        2        success        2013        7        5
3        1        success        2013        7        6
4        2        failed        2013        7        6
5        1        success        2013        7        7
这两种方式:
1.那种查询效率比较高?经常查询type等于某个值在某个时间段的值
(我经常做的查询就是 SELECT * FROM table_name WHERE tpye='1' AND date>'201307'这样的)
2.哪种比较省空间?
最佳答案
评论( 相关
后面还有条评论,点击查看>>