1、顾客user(顾客id,姓名、性别、会员卡号、手机号、卡内余额、可用积分、上次消费时间) CREATE TABLE USER( uid INT PRIMARY KEY AUTO_INCREMENT COMMENT'顾客id', uname VARCHAR(20) NOT NULL COMMENT '姓名', sex CHAR(2) COMMENT '性别', card_number VARCHAR(20) COMMENT '会员卡号', phone VARCHAR(20) COMMENT '电话号码', card_balance DECIMAL(10,2) DEFAULT 0 COMMENT '卡内余额', points INT COMMENT '积分' DEFAULT 0, last_purchase_date DATE COMMENT '上次消费时间' )AUTO_INCREMENT=10000 ENGINE=INNODB DEFAULT CHARSET=utf8;
2、货品名称表goods(货品id,货品名称,计量单位,货品条码,零售价,促销价,名称缩写(由触发器自行维护),货品状态) CREATE TABLE goods( gid INT AUTO_INCREMENT PRIMARY KEY COMMENT '货品id', gname VARCHAR(20) NOT NULL COMMENT '货品名称', unit VARCHAR(20) NOT NULL COMMENT '计量单位', barcode VARCHAR(20) NOT NULL COMMENT '货品条码', retail_Price DECIMAL(10,2) COMMENT '零售价', promotional_Price DECIMAL(10,2) COMMENT '促销价', abbreviations VARCHAR(20) NOT NULL COMMENT '名称缩写', STATUS TINYINT COMMENT '货品状态(0正常,1暂停进货(不能购进,但可以销售),2不再进货(不能购进,也不能销售))' )ENGINE=INNODB DEFAULT CHARSET=utf8;
3、供应商信息表supplier(供应商id,供应商名称,联系人,联系电话,供应商状态) CREATE TABLE supplier ( supplierID INT AUTO_INCREMENT PRIMARY KEY COMMENT '供应商id', supplier_Name VARCHAR(64) NOT NULL COMMENT '供应商名称', contact_Person VARCHAR(20) NOT NULL COMMENT '联系人', contact_Number VARCHAR(20) NOT NULL COMMENT '联系电话', supplier_Status TINYINT COMMENT '供应商状态0正常往来,1暂停来往,2,不再来往)') ENGINE=INNODB DEFAULT CHARSET=utf8;
4、收银员(收银员id、收银员姓名、收银员手机号) CREATE TABLE cashier (cashierid INT AUTO_INCREMENT PRIMARY KEY COMMENT '收银员id', cashier_Name VARCHAR(20) NOT NULL COMMENT '收银员姓名', phone VARCHAR(20) NOT NULL COMMENT '收银员电话') ENGINE=INNODB DEFAULT CHARSET=utf8;
5、货品库存表stock(库存id,货品id,(当前)库存数量,昨日库存(用于日清),月初库存(用于月结)) CREATE TABLE stock( stockid INT AUTO_INCREMENT PRIMARY KEY COMMENT '库存id', gid INT COMMENT '货品id', quantity DECIMAL(18,3) COMMENT '(当前)库存数量', yesterday_quantity DECIMAL(18,3) COMMENT '昨日库存(用于日清),系统自动维护', month_quantity DECIMAL(18,3) COMMENT '月初库存(用于月结),系统自动维护', FOREIGN KEY(gid) REFERENCES goods(gid) )ENGINE=INNODB DEFAULT CHARSET=utf8;
6、扎帐记录表settle_accounts(扎帐id,收银员id,扎帐时间,应收金额(由系统计算),实收金额(由收银员输入),差错原因) CREATE TABLE settle_accounts( settle_accountsid INT AUTO_INCREMENT PRIMARY KEY COMMENT '扎帐id', cashierid INT COMMENT '收银员id', settle_accounts_time DATETIME COMMENT '扎帐时间' DEFAULT CURRENT_TIMESTAMP, amount_money DECIMAL(18,3) COMMENT '应收金额', actual_money DECIMAL(18,3) COMMENT '实收金额', errorReason VARCHAR(100) NOT NULL COMMENT '差错原因', FOREIGN KEY(cashierid) REFERENCES cashier(cashierid) )ENGINE=INNODB DEFAULT CHARSET=utf8;
7、收银记录表cashaccount(收银id,收银员id,顾客id,扎帐id,收银时间,支付方式,应收金额,实收金额,优惠金额,销售状态(正常 ,已退货)) CREATE TABLE cashaccount( cashaccountid INT AUTO_INCREMENT PRIMARY KEY COMMENT '收银id', cashierid INT COMMENT '收银员id', uid INT COMMENT '顾客id', settle_accountsid INT COMMENT '扎帐id', cashier_time DATETIME COMMENT '收银时间' DEFAULT CURRENT_TIMESTAMP, payment TINYINT COMMENT '支付方式', amount_money DECIMAL(18,3) COMMENT '应收金额', actual_money DECIMAL(18,3) COMMENT '实收金额', discount_money DECIMAL(18,3) COMMENT '优惠金额', sales_status TINYINT COMMENT '销售状态(0正常 ,1已退货)', FOREIGN KEY(cashierid) REFERENCES cashier(cashierid), FOREIGN KEY(settle_accountsid) REFERENCES settle_accounts(settle_accountsid) )ENGINE=INNODB DEFAULT CHARSET=utf8;
8、收银明细表cashaccount_detil(收货明细id,收银id,货物id,销售数量,零售价、促销价) CREATE TABLE cashaccount_detail( cashaccountdetailid INT AUTO_INCREMENT PRIMARY KEY COMMENT '收银明细id', cashaccountid INT COMMENT '收银id', gid INT COMMENT '货品id', salesquantity DECIMAL(18,3) COMMENT '销售数量', retailprice DECIMAL(18,3) COMMENT '零售价', promotionalprice DECIMAL(18,3) COMMENT '促销价', FOREIGN KEY(cashaccountid) REFERENCES cashaccount(cashaccountid), FOREIGN KEY(gid) REFERENCES goods(gid) )ENGINE=INNODB DEFAULT CHARSET=utf8;
9、一个辅助表Hzpyb(汉字拼音表) 辅助表 汉字拼音表Hzpyb(汉字,简拼,拼音) CREATE TABLE hzpyb( hz CHAR(2), jp CHAR(1), py VARCHAR(10), INDEX (hz) )