SHARE
TWEET

Untitled

a guest Feb 27th, 2020 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE DATABASE `ASSIGNMENT` DEFAULT CHARACTER SET latin1 COLLATE latin1_turkish_ci;
  2. USE `ASSIGNMENT`;
  3.  
  4. CREATE TABLE `CUSTOMER` (
  5.   `Customer_ID` int(11) NOT NULL,
  6.   `Customer_Name` varchar(50) NOT NULL
  7. );
  8.  
  9. CREATE TABLE `PRODUCT` (
  10.   `Product_ID` int(11) NOT NULL,
  11.   `Product_Name` varchar(50) NOT NULL,
  12.   `Category` varchar(50) NOT NULL,
  13.   `Price` double DEFAULT '0'
  14. );
  15.  
  16. CREATE TABLE `SALE` (
  17.   `Sale_ID` int(11) NOT NULL,
  18.   `Product_ID` int(11) NOT NULL,
  19.   `Customer_ID` int(11) NOT NULL,
  20.   `Salesman_ID` int(11) NOT NULL,
  21.   `Sale_Date` date NOT NULL,
  22.   `Commission_Ratio` double DEFAULT '0'
  23. );
  24.  
  25.  
  26. CREATE TABLE `SALESMAN` (
  27.   `Salesman_ID` int(11) NOT NULL,
  28.   `Salesman_Name` varchar(50) NOT NULL,
  29.   `Hire_Date` date NOT NULL,
  30.   `Salary` double DEFAULT '0'
  31. );
  32.  
  33.  
  34. ALTER TABLE `CUSTOMER`
  35.   ADD PRIMARY KEY (`Customer_ID`);
  36.  
  37. ALTER TABLE `PRODUCT`
  38.   ADD PRIMARY KEY (`Product_ID`);
  39.  
  40. ALTER TABLE `SALE`
  41.   ADD PRIMARY KEY (`Sale_ID`),
  42.   ADD KEY `Product_ID` (`Product_ID`),
  43.   ADD KEY `Customer_ID` (`Customer_ID`),
  44.   ADD KEY `Salesman_ID` (`Salesman_ID`);
  45.  
  46. ALTER TABLE `SALESMAN`
  47.   ADD PRIMARY KEY (`Salesman_ID`);
  48.  
  49. ALTER TABLE `SALE`
  50.   ADD CONSTRAINT `sale_ibfk_1` FOREIGN KEY (`Product_ID`) REFERENCES `PRODUCT` (`Product_ID`),
  51.   ADD CONSTRAINT `sale_ibfk_2` FOREIGN KEY (`Customer_ID`) REFERENCES `CUSTOMER` (`Customer_ID`),
  52.   ADD CONSTRAINT `sale_ibfk_3` FOREIGN KEY (`Salesman_ID`) REFERENCES `SALESMAN` (`Salesman_ID`);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top