-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_script.sql
More file actions
88 lines (75 loc) · 3 KB
/
build_script.sql
File metadata and controls
88 lines (75 loc) · 3 KB
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
-- MySQL Script generated by MySQL Workbench
-- Wed Mar 6 18:20:36 2019
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering
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='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
-- -----------------------------------------------------
-- Schema atm
-- -----------------------------------------------------
DROP SCHEMA IF EXISTS `atm` ;
-- -----------------------------------------------------
-- Schema atm
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `atm` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci ;
USE `atm` ;
-- -----------------------------------------------------
-- Table `atm`.`users`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `atm`.`users` ;
CREATE TABLE IF NOT EXISTS `atm`.`users` (
`userid` INT(11) NOT NULL AUTO_INCREMENT,
`firstname` VARCHAR(30) CHARACTER SET 'utf8' NOT NULL,
`lastname` VARCHAR(30) CHARACTER SET 'utf8' NOT NULL,
`birthdate` DATE NOT NULL,
PRIMARY KEY (`userid`))
ENGINE = InnoDB
AUTO_INCREMENT = 4
DEFAULT CHARACTER SET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;
-- -----------------------------------------------------
-- Table `atm`.`accounts`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `atm`.`accounts` ;
CREATE TABLE IF NOT EXISTS `atm`.`accounts` (
`accountid` VARCHAR(6) CHARACTER SET 'utf8' NOT NULL,
`userid` INT(11) NOT NULL,
`accounttype` VARCHAR(15) CHARACTER SET 'utf8' NOT NULL,
`accountnumber` VARCHAR(12) CHARACTER SET 'utf8' NOT NULL,
`balance` FLOAT NOT NULL,
PRIMARY KEY (`accountid`),
UNIQUE INDEX `accountid_UNIQUE` (`accountid` ASC) VISIBLE,
UNIQUE INDEX `accountnumber_UNIQUE` (`accountnumber` ASC) VISIBLE,
INDEX `userid_idx` (`userid` ASC) VISIBLE,
CONSTRAINT `userid`
FOREIGN KEY (`userid`)
REFERENCES `atm`.`users` (`userid`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;
-- -----------------------------------------------------
-- Table `atm`.`auth`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `atm`.`auth` ;
CREATE TABLE IF NOT EXISTS `atm`.`auth` (
`authid` INT(11) NOT NULL AUTO_INCREMENT,
`accountid` VARCHAR(6) CHARACTER SET 'utf8' NOT NULL,
`pin` INT(4) NOT NULL,
PRIMARY KEY (`authid`),
UNIQUE INDEX `accountid_UNIQUE` (`accountid` ASC) VISIBLE,
INDEX `accountid_idx` (`accountid` ASC) VISIBLE,
CONSTRAINT `accountid`
FOREIGN KEY (`accountid`)
REFERENCES `atm`.`accounts` (`accountid`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB
AUTO_INCREMENT = 5
DEFAULT CHARACTER SET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;