zheng-ucenter.sql 4.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*==============================================================*/
  2. /* DBMS name: MySQL 5.0 */
  3. /* Created on: 2017/4/26 23:13:39 */
  4. /*==============================================================*/
  5. /*==============================================================*/
  6. /* Table: ucenter_oauth */
  7. /*==============================================================*/
  8. create table ucenter_oauth
  9. (
  10. oauth_id int unsigned not null auto_increment comment '编号',
  11. name varchar(20) comment '认证方式名称',
  12. primary key (oauth_id)
  13. );
  14. alter table ucenter_oauth comment '认证方式表';
  15. /*==============================================================*/
  16. /* Table: ucenter_user */
  17. /*==============================================================*/
  18. create table ucenter_user
  19. (
  20. user_id int unsigned not null auto_increment comment '编号',
  21. password varchar(32) comment '密码(MD5(密码+盐))',
  22. salt varchar(32) comment '盐',
  23. nickname varchar(20) comment '昵称',
  24. sex tinyint(4) default 0 comment '性别(0:未知,1:男,2:女)',
  25. avatar varchar(100) comment '头像',
  26. create_time timestamp default CURRENT_TIMESTAMP comment '注册时间',
  27. create_ip varchar(50) comment '注册IP地址',
  28. last_login_time timestamp comment '最后登录时间',
  29. last_login_ip varchar(50) comment '最后登录IP地址',
  30. primary key (user_id)
  31. );
  32. alter table ucenter_user comment '用户表';
  33. /*==============================================================*/
  34. /* Table: ucenter_user_details */
  35. /*==============================================================*/
  36. create table ucenter_user_details
  37. (
  38. user_id int unsigned not null comment '编号',
  39. signature varchar(300) comment '个性签名',
  40. real_name varchar(20) comment '真实姓名',
  41. birthday timestamp comment '出生日期',
  42. question varchar(100) comment '帐号安全问题',
  43. answer varchar(100) comment '帐号安全答案',
  44. primary key (user_id)
  45. );
  46. alter table ucenter_user_details comment '用户详情表';
  47. /*==============================================================*/
  48. /* Table: ucenter_user_log */
  49. /*==============================================================*/
  50. create table ucenter_user_log
  51. (
  52. user_log_id int unsigned not null auto_increment comment '编号',
  53. user_id int unsigned comment '用户编号',
  54. content varbinary(100) comment '内容',
  55. ip varchar(20) comment '操作IP地址',
  56. agent varbinary(200) comment '操作环境',
  57. create_time timestamp default CURRENT_TIMESTAMP comment '操作时间',
  58. primary key (user_log_id)
  59. );
  60. alter table ucenter_user_log comment '用户操作日志表';
  61. /*==============================================================*/
  62. /* Table: ucenter_user_oauth */
  63. /*==============================================================*/
  64. create table ucenter_user_oauth
  65. (
  66. user_oauth_id int unsigned not null auto_increment comment '编号',
  67. user_id int unsigned not null comment '帐号编号',
  68. oauth_id int unsigned not null comment '认证方式编号',
  69. open_id varbinary(50) not null comment '第三方ID',
  70. status tinyint(4) unsigned comment '绑定状态(0:解绑,1:绑定)',
  71. create_time timestamp default CURRENT_TIMESTAMP comment '创建时间',
  72. primary key (user_oauth_id)
  73. );
  74. alter table ucenter_user_oauth comment '用户认证方式表';
  75. alter table ucenter_user_details add constraint FK_Reference_41 foreign key (user_id)
  76. references ucenter_user (user_id) on delete restrict on update restrict;
  77. alter table ucenter_user_log add constraint FK_Reference_44 foreign key (user_id)
  78. references ucenter_user (user_id) on delete restrict on update restrict;
  79. alter table ucenter_user_oauth add constraint FK_Reference_42 foreign key (user_id)
  80. references ucenter_user (user_id) on delete restrict on update restrict;
  81. alter table ucenter_user_oauth add constraint FK_Reference_43 foreign key (oauth_id)
  82. references ucenter_oauth (oauth_id) on delete restrict on update restrict;