-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFirstScript.sql
115 lines (99 loc) · 3.74 KB
/
FirstScript.sql
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
-- MySQL Script generated by MySQL Workbench
-- Thu Nov 5 20:54:49 2020
-- 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='TRADITIONAL,ALLOW_INVALID_DATES';
-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 ;
USE `mydb` ;
-- -----------------------------------------------------
-- Table `mydb`.`Race`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Race` (
`raceName` VARCHAR(10) NOT NULL,
`raceId` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`speed` INT UNSIGNED NOT NULL,
`size` VARCHAR(10) NOT NULL,
`darkvision` TINYINT NULL,
PRIMARY KEY (`raceId`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Language`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Language` (
`languagesId` INT NOT NULL,
`languagesName` VARCHAR(45) NOT NULL,
PRIMARY KEY (`languagesId`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`RaceLanguage`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`RaceLanguage` (
`raceId` INT UNSIGNED NOT NULL,
`language` INT NOT NULL,
PRIMARY KEY (`raceId`, `language`),
INDEX `race_idx` (`raceId` ASC),
INDEX `language1_idx` (`language` ASC),
CONSTRAINT `race`
FOREIGN KEY (`raceId`)
REFERENCES `mydb`.`Race` (`raceId`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `language`
FOREIGN KEY (`language`)
REFERENCES `mydb`.`Language` (`languagesId`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`RaceAbilityScore`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`RaceAbilityScore` (
`raceId` INT UNSIGNED NOT NULL,
`abilityScore` VARCHAR(15) NOT NULL,
`scoreIncrease` INT UNSIGNED NOT NULL,
PRIMARY KEY (`raceId`, `abilityScore`),
CONSTRAINT `raceId`
FOREIGN KEY (`raceId`)
REFERENCES `mydb`.`Race` (`raceId`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Proficiency`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Proficiency` (
`proficiencyId` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`proficiencyName` VARCHAR(45) NOT NULL,
`proficiencyType` VARCHAR(45) NOT NULL COMMENT 'Skill, tool, instrument etc',
PRIMARY KEY (`proficiencyId`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`RaceProficiency`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`RaceProficiency` (
`raceId` INT UNSIGNED NOT NULL,
`proficiencyId` INT UNSIGNED NOT NULL,
PRIMARY KEY (`raceId`, `proficiencyId`),
INDEX `proficiencyId_idx` (`proficiencyId` ASC),
CONSTRAINT `raceId`
FOREIGN KEY (`raceId`)
REFERENCES `mydb`.`Race` (`raceId`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `proficiencyId`
FOREIGN KEY (`proficiencyId`)
REFERENCES `mydb`.`Proficiency` (`proficiencyId`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;