· 7 years ago · Oct 28, 2018, 03:08 PM
1/*TABLA JUEGOS*/
2DROP TABLE IF EXISTS `juegos`;
3CREATE TABLE IF NOT EXISTS `juegos` (
4 `id` int(11) PRIMARY KEY AUTO_INCREMENT,
5 `id_subcategoria` int(11) NOT NULL,
6 `nombre` varchar(50) COLLATE utf8mb4_spanish_ci NOT NULL,
7 `imagen` varchar(100) COLLATE utf8mb4_spanish_ci NOT NULL,
8 FOREIGN KEY (id_subcategoria)
9 REFERENCES subcategoria(id)
10 ON UPDATE CASCADE ON DELETE CASCADE
11) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
12
13/*TABLA USUARIOS*/
14DROP TABLE IF EXISTS `usuarios`;
15CREATE TABLE IF NOT EXISTS `usuarios` (
16 `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
17 `nombre` varchar(50) COLLATE utf8_spanish_ci NOT NULL,
18 `email` varchar(120) COLLATE utf8_spanish_ci NOT NULL,
19 `password` varchar(50) COLLATE utf8_spanish_ci NOT NULL,
20 `fecha_ingreso` date DEFAULT NULL,
21 `acumulado` int(11) DEFAULT 0
22) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci;
23
24/*LA TABLA PIVOTE = APUESTAS*/
25DROP TABLE IF EXISTS `apuestas`;
26CREATE TABLE IF NOT EXISTS `apuestas` (
27 `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
28 `id_juego` int(11) NOT NULL,
29 `id_usuario` int(11) NOT NULL,
30 `apostado` int(11) NOT NULL,
31 `fecha_apuesta` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
32 FOREIGN KEY (id_juego) references juegos (id),
33 FOREIGN KEY (id_usuario) references usuarios (id)
34
35) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
36
37DROP TABLE IF EXISTS `apuestas`;
38CREATE TABLE IF NOT EXISTS `apuestas` (
39 `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
40 `id_juego` int(11) NOT NULL,
41 `id_usuario` int(11) NOT NULL,
42 `apostado` int(11) NOT NULL,
43 `fecha_apuesta` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
44 FOREIGN KEY (id_juego) references juegos (id)
45) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;