PHP实战PHP经验分享Phalcon

「PHP开发APP接口实战010」会员系统之数据库设计

2018-03-03  本文已影响88人  一念觀心

今天我们开始讲解会员系统开发。

需求分析

数据库设计

dm_user 用户表
字段 类型 默认值 额外 描述
user_id INT(11) UNSIGNED 0 AUTO_INCREMENT ID
user_mobile VARCHAR(11) UNIQUE KEY 手机号
user_token VARCHAR(32) UNIQUE KEY 身份令牌
user_nickname VARCHAR(50) 昵称
user_avatar VARCHAR(255) 头像
user_gender TINYINT(1) UNSIGNED 0 性别:0 未知, 1 男, 2 女
user_status TINYINT(1) UNSIGNED 0 KEY 状态:0 未激活, 1 已激活
user_addtime INT(11) UNSIGNED 0 KEY 注册时间
user_uptime INT(11) UNSIGNED 0 KEY 更新时间
user_lasttime INT(11) UNSIGNED 0 KEY 最后登陆时间
DROP TABLE IF EXISTS `dm_user`;
CREATE TABLE `dm_user` (
  `user_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `user_mobile` VARCHAR(11) NULL DEFAULT '' COMMENT '手机号',
  `user_token` VARCHAR(32) NULL DEFAULT '' COMMENT '身份令牌',
  `user_nickname` VARCHAR(50) NULL DEFAULT '' COMMENT '昵称',
  `user_avatar` VARCHAR(255) NULL DEFAULT '' COMMENT '头像',
  `user_gender` TINYINT(1) UNSIGNED NULL DEFAULT 0 COMMENT '性别:0 未知, 1 男, 2 女',
  `user_status` TINYINT(1) UNSIGNED NULL DEFAULT 0 COMMENT '状态:0 未激活, 1 已激活',
  `user_addtime` INT(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '注册时间',
  `user_uptime` INT(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
  `user_lasttime` INT(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '最后登陆时间',
  PRIMARY KEY (`user_id`),
  UNIQUE KEY `user_mobile` (`user_mobile`),
  UNIQUE KEY `user_token` (`user_token`),
  KEY `user_status` (`user_status`),
  KEY `user_addtime` (`user_addtime`),
  KEY `user_uptime` (`user_uptime`),
  KEY `user_lasttime` (`user_lasttime`)
) ENGINE=InnoDB AUTO_INCREMENT=1 COMMENT='用户表';
dm_user_authentication 实名认证表
字段 类型 默认值 额外 描述
authentication_id INT(11) UNSIGNED 0 AUTO_INCREMENT ID
user_id INT(11) UNSIGNED 0 KEY 用户ID
authentication_number VARCHAR(18) UNIQUE KEY 身份证号
authentication_realname VARCHAR(50) 真实姓名
authentication_status TINYINT(1) UNSIGNED 0 KEY 状态:0 待审核, 1 未通过, 2 已认证
authentication_addtime INT(11) UNSIGNED 0 KEY 申请时间
authentication_uptime INT(11) UNSIGNED 0 KEY 审核时间
DROP TABLE IF EXISTS `dm_user_authentication`;
CREATE TABLE `dm_user_authentication` (
  `authentication_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `user_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '用户ID',
  `authentication_number` VARCHAR(50) NULL DEFAULT '' COMMENT '身份证号',
  `authentication_realname` VARCHAR(50) NULL DEFAULT '' COMMENT '真实姓名',
  `authentication_status` TINYINT(1) UNSIGNED NULL DEFAULT 0 COMMENT '状态:0 待审核, 1 未通过, 2 已认证',
  `authentication_addtime` INT(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '申请时间',
  `authentication_uptime` INT(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '审核时间',
  PRIMARY KEY (`authentication_id`),
  UNIQUE KEY `user_id` (`user_id`),
  UNIQUE KEY `authentication_number` (`authentication_number`),
  KEY `authentication_status` (`authentication_status`),
  KEY `authentication_addtime` (`authentication_addtime`),
  KEY `authentication_uptime` (`authentication_uptime`)
) ENGINE=InnoDB AUTO_INCREMENT=1 COMMENT='实名认证表';

功能分解

接下来的章节,我将逐一讲解每一个功能的具体实现

上一篇下一篇

猜你喜欢

热点阅读