1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 ;
CREATE TABLE IF NOT EXISTS `mydb`.`User` ( `u-number` INT(11) NOT NULL COMMENT ' \n', `id` VARCHAR(45) NOT NULL COMMENT ' ', `pwd` VARCHAR(45) NOT NULL, `name` VARCHAR(45) NOT NULL, `call` INT(11) NOT NULL, `gender` VARCHAR(45) NULL DEFAULT NULL, `birth` INT(11) NOT NULL, `join-date` DATETIME NOT NULL, `session-date` DATETIME NULL DEFAULT NULL, `address` VARCHAR(45) NOT NULL, `ages` VARCHAR(45) NULL DEFAULT NULL, PRIMARY KEY (`u-number`)) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8;
CREATE TABLE IF NOT EXISTS `mydb`.`Login` ( `login-date` DATETIME NOT NULL, `IP` VARCHAR(45) NULL DEFAULT NULL, `User_u-number` INT(11) NOT NULL, PRIMARY KEY (`login-date`, `User_u-number`), INDEX `fk_Login_User1_idx` (`User_u-number` ASC), CONSTRAINT `fk_Login_User1` FOREIGN KEY (`User_u-number`) REFERENCES `mydb`.`User` (`u-number`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8;
CREATE TABLE IF NOT EXISTS `mydb`.`Basket` ( `basket-number` INT(11) NOT NULL, `select-date` DATETIME NULL DEFAULT NULL, `User_u-number` INT(11) NOT NULL, `Product_product-number` INT(11) NOT NULL, PRIMARY KEY (`basket-number`, `User_u-number`, `Product_product-number`), INDEX `fk_Basket_User1_idx` (`User_u-number` ASC), INDEX `fk_Basket_Product1_idx` (`Product_product-number` ASC), CONSTRAINT `fk_Basket_User1` FOREIGN KEY (`User_u-number`) REFERENCES `mydb`.`User` (`u-number`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_Basket_Product1` FOREIGN KEY (`Product_product-number`) REFERENCES `mydb`.`Product` (`product-number`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8;
CREATE TABLE IF NOT EXISTS `mydb`.`Product` ( `product-number` INT(11) NOT NULL, `product-name` VARCHAR(45) NULL DEFAULT NULL, `price` VARCHAR(45) NULL DEFAULT NULL, `size` VARCHAR(45) NULL DEFAULT NULL, PRIMARY KEY (`product-number`)) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8;
CREATE TABLE IF NOT EXISTS `mydb`.`Buy` ( `buy-date` DATETIME NOT NULL, `Product_product-number` INT(11) NOT NULL, `User_u-number` INT(11) NOT NULL, PRIMARY KEY (`buy-date`, `Product_product-number`, `User_u-number`), INDEX `fk_Buy_Product1_idx` (`Product_product-number` ASC), INDEX `fk_Buy_User1_idx` (`User_u-number` ASC), CONSTRAINT `fk_Buy_Product1` FOREIGN KEY (`Product_product-number`) REFERENCES `mydb`.`Product` (`product-number`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_Buy_User1` FOREIGN KEY (`User_u-number`) REFERENCES `mydb`.`User` (`u-number`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8;
CREATE TABLE IF NOT EXISTS `mydb`.`Coupon` ( `coupon-number` INT(11) NOT NULL, `User_u-number` INT(11) NOT NULL, PRIMARY KEY (`coupon-number`, `User_u-number`), INDEX `fk_생일쿠폰_User_idx` (`User_u-number` ASC), CONSTRAINT `fk_생일쿠폰_User` FOREIGN KEY (`User_u-number`) REFERENCES `mydb`.`User` (`u-number`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8;
SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
use mydb;
SELECT * FROM user;
INSERT INTO user VALUES (1,'sejune','kim','kimsejune','01045401088','men','930907','170913', null, '경기도 시흥시 정왕동', '25');
SELECT*FROM login;
INSERT INTO login VALUES(now(), '192.168.0.1', 1);
SELECT*FROM coupon;
INSERT INTO coupon VALUES(1, 1);
SELECT * FROM Product;
INSERT INTO product VALUES(1, '슬렉스(검정)', '200000', '29');
SELECT * FROM buy;
INSERT INTO buy VALUES (now(), 1, 1);
SELECT * FROM Basket;
INSERT INTO basket VALUES(1, now(), 1, 1);
|