数据库架构
数据字典定义
1.数据库开发和设计工具:
MySQL workbench
http://www.mysql.com/products/workbench/
- install
- click DataModel
你可以点击add EER diagram创建ER图或者导入ER图
点击AddTable添加table
2.用户行为数据库如何构建
扫描二维码关注公众号,回复:
1349428 查看本文章
- 分析服务器消息日志
- 用户行为属性的确定
- 使用动态建表技术建立数据仓库
解决方案:现在把每条消息进行解析,然后存入数据库作为rawdata,然后对这种数据进行数据挖掘,建立数据仓库
3.数据类型
varchar vs char
相同点:
- InnoDB or MyISAM
- comparison by padding values with spaces as needed
不同点:
varchar
- variable-length(UTF-8, variable length)
- varchar use extra bytes to store the length(1-2 bytes)
- varchar cause extra work when you update the row
- preserve any trailing spaces
char
- fixed-length
- remove any trailing spaces
- MD5 for password
Blob vs TEXT(SMALLTEXT)
分别存binary和大字符串
- sort需设置max_sort_length或者order by substring(column,length)
- InnoDB external storage area
- avoid using
Whole number
tinyint(8) smallint(16) mediumint(32) bigint(64)
DateTime vs TimeStamp
DateTime
- 8 bytes text representation
Timestamp
- 4 bytes number of seconds representation
- multiple zones access
- 为了精确到ms,可以再加一个smallint字段timestampms
4.密码存储
MD5 char(32)