细化迭代四------退货用例完整数据库

/*
Navicat MySQL Data Transfer


Source Server         : mysql
Source Server Version : 60011
Source Host           : localhost:3306
Source Database       : post


Target Server Type    : MYSQL
Target Server Version : 60011
File Encoding         : 65001


Date: 2015-05-16 10:42:35
*/


SET FOREIGN_KEY_CHECKS=0;


-- ----------------------------
-- Table structure for bill
-- ----------------------------
DROP TABLE IF EXISTS `bill`;
CREATE TABLE `bill` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `productno` varchar(36) NOT NULL,
  `productname` varchar(36) NOT NULL,
  `price` double(50,5) NOT NULL,
  `discount` double(50,3) NOT NULL,
  `saleprice` double(50,5) NOT NULL,
  `quantity` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


-- ----------------------------
-- Table structure for customer
-- ----------------------------
DROP TABLE IF EXISTS `customer`;
CREATE TABLE `customer` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `customerno` varchar(36) NOT NULL,
  `customername` varchar(36) DEFAULT NULL,
  `telephone` varchar(36) DEFAULT NULL,
  `address` varchar(100) DEFAULT NULL,
  `customerclass` varchar(100) NOT NULL,
  PRIMARY KEY (`id`,`customerno`),
  UNIQUE KEY `customerno` (`customerno`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=119 DEFAULT CHARSET=utf8;


-- ----------------------------
-- Table structure for orderdetail
-- ----------------------------
DROP TABLE IF EXISTS `orderdetail`;
CREATE TABLE `orderdetail` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `order_no` varchar(36) NOT NULL,
  `product_no` varchar(36) NOT NULL,
  `productname` varchar(36) NOT NULL,
  `price` double(50,5) NOT NULL,
  `saleprice` double(50,5) NOT NULL,
  `discount` double(50,3) NOT NULL,
  `quantity` int(11) NOT NULL,
  `saletime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `orderdetail_product_fbk1` (`product_no`),
  KEY `orderdetail_order_fbk1` (`order_no`),
  CONSTRAINT `orderdetail_order_fbk1` FOREIGN KEY (`order_no`) REFERENCES `saleorder` (`orderno`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `orderdetail_product_fbk1` FOREIGN KEY (`product_no`) REFERENCES `product` (`productno`)
) ENGINE=InnoDB AUTO_INCREMENT=135 DEFAULT CHARSET=utf8;


-- ----------------------------
-- Table structure for payment
-- ----------------------------
DROP TABLE IF EXISTS `payment`;
CREATE TABLE `payment` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `paymentno` varchar(36) NOT NULL,
  `paymentmethod` varchar(36) NOT NULL,
  `amount` double(50,5) NOT NULL,
  `paytime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `order_no` varchar(36) NOT NULL,
  `payee_name` varchar(36) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `payment_user_fbk1` (`payee_name`),
  KEY `payment_saleorder_fbk1` (`order_no`),
  CONSTRAINT `payment_saleorder_fbk1` FOREIGN KEY (`order_no`) REFERENCES `saleorder` (`orderno`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `payment_user_fbk1` FOREIGN KEY (`payee_name`) REFERENCES `user` (`username`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8;


-- ----------------------------
-- Table structure for product
-- ----------------------------
DROP TABLE IF EXISTS `product`;
CREATE TABLE `product` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `productno` varchar(36) NOT NULL,
  `productname` varchar(36) NOT NULL,
  `description` varchar(100) DEFAULT NULL,
  `price` double(50,5) NOT NULL,
  `producttype_id` int(11) NOT NULL,
  `stockquantity` int(11) NOT NULL,
  PRIMARY KEY (`id`,`productno`,`productname`),
  UNIQUE KEY `productno` (`productno`) USING BTREE,
  KEY `producttype_id` (`producttype_id`) USING BTREE,
  KEY `productname` (`productname`),
  CONSTRAINT `product_ibfk_1` FOREIGN KEY (`producttype_id`) REFERENCES `producttype` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8;


-- ----------------------------
-- Table structure for producttype
-- ----------------------------
DROP TABLE IF EXISTS `producttype`;
CREATE TABLE `producttype` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `producttypename` varchar(36) NOT NULL,
  `description` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`id`,`producttypename`)
) ENGINE=InnoDB AUTO_INCREMENT=1127 DEFAULT CHARSET=utf8;


-- ----------------------------
-- Table structure for saleorder
-- ----------------------------
DROP TABLE IF EXISTS `saleorder`;
CREATE TABLE `saleorder` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `orderno` varchar(36) NOT NULL,
  `customer_no` varchar(36) NOT NULL,
  `state` int(11) NOT NULL,
  `ordertime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `seller_name` varchar(36) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `orderno` (`orderno`) USING BTREE,
  KEY `order_customer_fbk1` (`customer_no`) USING BTREE,
  KEY `saleorder_user_fbk1` (`seller_name`),
  CONSTRAINT `saleorder_customer_fbk1` FOREIGN KEY (`customer_no`) REFERENCES `customer` (`customerno`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `saleorder_user_fbk1` FOREIGN KEY (`seller_name`) REFERENCES `user` (`username`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=97 DEFAULT CHARSET=utf8;


-- ----------------------------
-- Table structure for salereturn
-- ----------------------------
DROP TABLE IF EXISTS `salereturn`;
CREATE TABLE `salereturn` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `salereturnno` varchar(36) NOT NULL,
  `returntime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `returnpeople_name` varchar(36) NOT NULL,
  `order_no` varchar(36) NOT NULL,
  `returnreason` varchar(200) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `salereturn_saleorder_fbk1` (`order_no`),
  KEY `salereturn_user_fbk1` (`returnpeople_name`),
  KEY `salereturnno` (`salereturnno`),
  CONSTRAINT `salereturn_saleorder_fbk1` FOREIGN KEY (`order_no`) REFERENCES `saleorder` (`orderno`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `salereturn_user_fbk1` FOREIGN KEY (`returnpeople_name`) REFERENCES `user` (`username`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;


-- ----------------------------
-- Table structure for salereturndetail
-- ----------------------------
DROP TABLE IF EXISTS `salereturndetail`;
CREATE TABLE `salereturndetail` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `salereturn_no` varchar(36) NOT NULL,
  `product_no` varchar(36) NOT NULL,
  `productname` varchar(36) NOT NULL,
  `price` double(50,5) NOT NULL,
  `returnmoney` double(50,5) NOT NULL,
  `returnquantity` int(11) NOT NULL,
  `returntime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `order_no` varchar(36) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `salereturndetail_salereturn_fbk1` (`salereturn_no`),
  KEY `salereturndetail_product_fbk1` (`product_no`),
  KEY `salereturndetail_saleorder_fbk1` (`order_no`),
  CONSTRAINT `salereturndetail_product_fbk1` FOREIGN KEY (`product_no`) REFERENCES `product` (`productno`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `salereturndetail_saleorder_fbk1` FOREIGN KEY (`order_no`) REFERENCES `saleorder` (`orderno`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `salereturndetail_salereturn_fbk1` FOREIGN KEY (`salereturn_no`) REFERENCES `salereturn` (`salereturnno`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;


-- ----------------------------
-- Table structure for serialnumber
-- ----------------------------
DROP TABLE IF EXISTS `serialnumber`;
CREATE TABLE `serialnumber` (
  `saleordernumber` int(36) NOT NULL,
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `customernumber` int(36) NOT NULL,
  `paymentnumber` int(36) NOT NULL,
  `salereturnnumber` int(36) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `UK_6kvsaeha3o16lipqunxwdlley` (`salereturnnumber`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;


-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(36) NOT NULL,
  `password` varchar(100) NOT NULL,
  `permission` varchar(36) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `username` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

 
  
  
  
  

你可能感兴趣的:(sql,数据库,pos)