Project electricity supplier Universal user module data table structure design

The user module into a plurality of tables, data separator made of cold

/ * User login table * /

The CREATE TABLE customer_login (
CUSTOMER_ID the INT UNSIGNED the AUTO_INCREMENT the NOT NULL the COMMENT 'user ID',
login_name VARCHAR (20 is) the NOT NULL the COMMENT 'user login',
password CHAR (32) the NOT NULL the COMMENT 'MD5 encrypted password',
user_status TINYINT the NOT NULL DEFAULT 1 COMMENT 'user state',
modified_time the NOT NULL the DEFAULT TIMESTAMP the ON the UPDATE CURRENT_TIMESTAMP CURRENT_TIMESTAMP the COMMENT 'last modified time',
a PRIMARY KEY pk_customerid (CUSTOMER_ID)
) ENGINE = INNODB the COMMENT = 'user registration table';

 

/ * User information table * /

The CREATE TABLE customer_inf (
customer_inf_id the INT UNSIGNED the AUTO_INCREMENT the NOT NULL the COMMENT 'primary key increment ID',
CUSTOMER_ID the INT UNSIGNED the NOT NULL the COMMENT 'customer_login table increment ID',
CUSTOMER_NAME VARCHAR (20 is) the NOT NULL the COMMENT 'user's real name',
identity_card_type TINYINT NOT NULL DEFAULT 1 COMMENT 'identity document types 1, 2 military officer, 3 passport',
MOBILE_PHONE INT UNSIGNED the COMMENT 'phone number',
CUSTOMER_EMAIL VARCHAR (50) the COMMENT 'E-mail',
gender CHAR (1) the COMMENT 'sex',
user_point INT NOT NULL DEFAULT 0 COMMENT 'loyalty points',
register_time the NOT NULL TIMESTAMP the COMMENT 'registered',
birthday datetime the COMMENT 'members birthday',
customer_level TINYINT the NOT NULL the DEFAULT the COMMENT 1 'membership level',
user_money DECIMAL (8,2) NOT NULL DEFAULT 0.00 COMMENT 'user balance',
modified_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT ' last modified time',
a PRIMARY KEY pk_costomerinfid (customer_inf_id)
) ENGINE INNODB the COMMENT = 'user information table';

 

/ * User level information table * /

TABLE customer_leval_inf the CREATE (
customer_level TINYINT the NOT NULL AUTO_INCREMENT the COMMENT 'membership level ID',
level_name VARCHAR (10) the NOT NULL the COMMENT 'membership level name',
min_point INT UNSIGNED the NOT NULL the COMMENT 'This level is the lowest score',
max_point INT UNSIGNED the NOT NULL the COMMENT 'the highest level score',
modified_time the NOT NULL the DEFAULT TIMESTAMP the ON the UPDATE CURRENT_TIMESTAMP CURRENT_TIMESTAMP the COMMENT 'last modified time',
a PRIMARY KEY pk_levelid (customer_level)
) ENGINE INNODB the COMMENT = 'user level information table';

 

/ * User address information table * /

The CREATE TABLE customer_addr (
customer_addr_id the INT UNSIGNED AUTO_INCREMENT the NOT NULL the COMMENT 'auto-increment primary key ID',
CUSTOMER_ID the INT UNSIGNED the NOT NULL the COMMENT 'customer_login table's primary key',
ZIP SMALLINT the NOT NULL the COMMENT 'Zip',
Province SMALLINT the NOT NULL the COMMENT 'Region Table provinces the ID ',
city SMALLINT the COMMENT the NOT NULL' urban area table ID ',
District the COMMENT SMALLINT the NOT NULL' regions of the table region ID ',
address VARCHAR (200 is) the COMMENT the NOT NULL' specific house number ',
the is_default the NOT TINYINT NULL COMMENT 'whether default',
modified_time the NOT NULL the dEFAULT TIMESTAMP the ON the UPDATE CURRENT_TIMESTAMP CURRENT_TIMESTAMP the COMMENT 'last modified time',
a PRIMARY KEY pk_customeraddid (customer_addr_id)
) ENGINE INNODB the COMMENT = 'user address table';

 

/ * The user points the log table * /

The CREATE TABLE customer_point_log (
point_id the INT UNSIGNED the NOT NULL AUTO_INCREMENT the COMMENT 'integral log ID',
CUSTOMER_ID the INT UNSIGNED the NOT NULL the COMMENT 'user ID',
Source TINYINT UNSIGNED the NOT NULL the COMMENT 'integral source',
refer_number the INT UNSIGNED the NOT NULL the DEFAULT 0 the COMMENT 'integral source Related numbers',
change_point the COMMENT SMALLINT the NOT NULL the DEFAULT 0 'to change the number of credits',
the create_time the COMMENT TIMESTAMP the NOT NULL' integration log generation time ',
a PRIMARY KEY pk_pointid (point_id)
) ENGINE = INNODB the COMMENT' integrated user log table ';

 

/ * Changes in the balance of the user * /

The CREATE TABLE customer_balance_log (
balance_id the INT UNSIGNED the NOT NULL AUTO_INCREMENT the COMMENT 'balance log ID',
CUSTOMER_ID the INT UNSIGNED the NOT NULL the COMMENT 'user ID',
Source TINYINT UNSIGNED the NOT NULL the DEFAULT. 1 the COMMENT 'record source',
source_sn the INT UNSIGNED the NOT NULL the COMMENT 'related documents ID ',
the create_time TIMESTAMP the NOT NULL the DEFAULT CURRENT_TIMESTAMP the COMMENT' record generation time ',
aMOUNT DECIMAL (. 8, 2) the NOT NULL the DEFAULT 0.00 the COMMENT' change amount ',
a PRIMARY KEY pk_banlanceid (balance_id)
) ENGINE = INNODB the COMMENT' user balance changes' ;

 

/ * User login log table * /

The CREATE TABLE customer_login_log (
login_id the INT UNSIGNED the NOT NULL AUTO_INCREMENT the COMMENT 'login log ID',
CUSTOMER_ID the INT UNSIGNED the NOT NULL the COMMENT 'login user ID',
login_time TIMESTAMP the NOT NULL the COMMENT 'user login time',
login_ip the INT UNSIGNED the NOT NULL the COMMENT 'login ID' ,
the login_type the COMMENT TINYINT the nOT NULL '0 unsuccessful login result, a success',
a PRIMARY KEY pk_loginid (login_id)
) ENGINE INNODB the COMMENT = 'user login log table'

Guess you like

Origin www.cnblogs.com/yoxuc/p/11100517.html