CREATE TABLE `sale` ( `code` bigint(20) unsigned zerofill NOT NULL AUTO_INCREMENT, `name` varchar(60) NOT NULL, `storeCode` bigint(20) unsigned zerofill NOT NULL, `type` enum('LowPrice','Percentage','Points','OnePlusOne','ProductAsGift','DiscountOnAmount','MoneyOnAmount','Other') NOT NULL DEFAULT 'Other', `status` enum('Deleted','Suspended','Active') DEFAULT 'Active', `allStoreSale` enum('Yes','No') NOT NULL DEFAULT 'No', `dupSale` enum('Yes','No') NOT NULL DEFAULT 'No', `instanceLimit` tinyint(3) unsigned DEFAULT '1', `fromDate` date DEFAULT NULL, `toDate` date DEFAULT NULL, `productCode_1` bigint(20) unsigned zerofill DEFAULT NULL, `productCode_2` bigint(20) unsigned zerofill DEFAULT NULL, `productGroupCode` bigint(20) unsigned zerofill DEFAULT NULL, `supplierCode` bigint(20) unsigned zerofill DEFAULT NULL, `price_1` decimal(8,2) unsigned DEFAULT NULL, `price_2` decimal(8,2) unsigned DEFAULT NULL, `point` decimal(6,2) unsigned DEFAULT NULL, `percentage` decimal(4,2) unsigned DEFAULT NULL, `quantity_1` decimal(6,2) unsigned DEFAULT NULL, `quantity_2` decimal(6,2) unsigned DEFAULT NULL, PRIMARY KEY (`code`), KEY `fk_sale_store1_idx` (`storeCode`), KEY `fk_sale_product1_idx` (`productCode_1`), KEY `fk_sale_product2_idx` (`productCode_2`), KEY `fk_sale_subgroup21_idx` (`productGroupCode`), KEY `fk_sale_supplier1_idx` (`supplierCode`), CONSTRAINT `fk_sale_product1` FOREIGN KEY (`productCode_1`) REFERENCES `product` (`code`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_sale_product2` FOREIGN KEY (`productCode_2`) REFERENCES `product` (`code`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_sale_store1` FOREIGN KEY (`storeCode`) REFERENCES `store` (`code`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_sale_subgroup21` FOREIGN KEY (`productGroupCode`) REFERENCES `subgroup2` (`code`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_sale_supplier1` FOREIGN KEY (`supplierCode`) REFERENCES `supplier` (`code`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8;