Professional Documents
Culture Documents
DB - Sales Script
DB - Sales Script
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- Database: `db_sales`
--
-- --------------------------------------------------------
--
-- Table structure for table `barcode`
--
--
-- Dumping data for table `barcode`
--
-- --------------------------------------------------------
--
-- Table structure for table `categories`
--
--
-- Dumping data for table `categories`
--
-- --------------------------------------------------------
--
-- Table structure for table `customer`
--
--
-- Dumping data for table `customer`
--
-- --------------------------------------------------------
--
-- Table structure for table `item`
--
--
-- Dumping data for table `item`
--
-- --------------------------------------------------------
--
-- Table structure for table `orderinfo`
--
--
-- Dumping data for table `orderinfo`
--
-- --------------------------------------------------------
--
-- Table structure for table `orderline`
--
--
-- Dumping data for table `orderline`
--
-- --------------------------------------------------------
--
-- Table structure for table `shippers`
--
--
-- Dumping data for table `shippers`
--
-- --------------------------------------------------------
--
-- Table structure for table `stock`
--
--
-- Dumping data for table `stock`
--
--
-- Constraints for table `barcode`
--
ALTER TABLE `barcode`
ADD CONSTRAINT `barcode_item_id_fk` FOREIGN KEY (`item_id`) REFERENCES `item`
(`item_id`);
--
-- Constraints for table `item`
--
ALTER TABLE `item`
ADD CONSTRAINT `category_fk` FOREIGN KEY (`category_id`) REFERENCES `categories`
(`Category_id`) ON DELETE CASCADE ON UPDATE NO ACTION;
--
-- Constraints for table `orderinfo`
--
ALTER TABLE `orderinfo`
ADD CONSTRAINT `orderinfo_ibfk_1` FOREIGN KEY (`customer_id`) REFERENCES `customer`
(`customer_id`) ON DELETE CASCADE,
ADD CONSTRAINT `orderinfo_shipper_id_fk` FOREIGN KEY (`shipvia`) REFERENCES
`shippers` (`Shipper_id`);
--
-- Constraints for table `orderline`
--
ALTER TABLE `orderline`
ADD CONSTRAINT `orderline_ibfk_2` FOREIGN KEY (`orderinfo_id`) REFERENCES
`orderinfo` (`orderinfo_id`) ON DELETE CASCADE,
ADD CONSTRAINT `orderline_ibfk_3` FOREIGN KEY (`item_id`) REFERENCES `item`
(`item_id`) ON DELETE NO ACTION;
--
-- Constraints for table `stock`
--
ALTER TABLE `stock`
ADD CONSTRAINT `stock_item_id_fk` FOREIGN KEY (`item_id`) REFERENCES `item`
(`item_id`);