-
Notifications
You must be signed in to change notification settings - Fork 1
/
Airline.sql
117 lines (102 loc) · 3.76 KB
/
Airline.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
116
117
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';
CREATE SCHEMA IF NOT EXISTS `Airline` DEFAULT CHARACTER SET utf8 ;
USE `Airline` ;
-- -----------------------------------------------------
-- Table `Airline`.`Avion`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Airline`.`Avion` (
`codigo` VARCHAR(8) NOT NULL ,
`descripcion` VARCHAR(45) NOT NULL ,
`capacidad` INT NOT NULL ,
PRIMARY KEY (`codigo`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `Airline`.`Aerolinea`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Airline`.`Aerolinea` (
`codigo` VARCHAR(8) NOT NULL ,
`descripcion` VARCHAR(45) NOT NULL ,
PRIMARY KEY (`codigo`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `Airline`.`Aeropuerto`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Airline`.`Aeropuerto` (
`codigo` VARCHAR(8) NOT NULL ,
`descripcion` VARCHAR(45) NOT NULL ,
`ciudad` VARCHAR(45) NOT NULL ,
`pais` VARCHAR(45) NOT NULL ,
`direccion` VARCHAR(45) NOT NULL ,
PRIMARY KEY (`codigo`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `Airline`.`Vuelo`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Airline`.`Vuelo` (
`codigo` VARCHAR(8) NOT NULL ,
`aerolinea` VARCHAR(8) NOT NULL ,
`origen` VARCHAR(8) NOT NULL ,
`destino` VARCHAR(8) NOT NULL ,
`avion` VARCHAR(8) NOT NULL ,
`salida` DATETIME NOT NULL ,
`llegada` DATETIME NOT NULL ,
`estado` TINYINT NULL DEFAULT 0 ,
PRIMARY KEY (`codigo`) ,
INDEX `FK_Vuelo_Avion` (`avion` ASC) ,
INDEX `FK_Vuelo_Aerolinea` (`aerolinea` ASC) ,
INDEX `FK_Vuelo_AeropuertoOrigen` (`destino` ASC) ,
INDEX `FK_Vuelo_AeropuertoDestino` (`origen` ASC) ,
CONSTRAINT `FK_Vuelo_Avion`
FOREIGN KEY (`avion` )
REFERENCES `Airline`.`Avion` (`codigo` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `FK_Vuelo_Aerolinea`
FOREIGN KEY (`aerolinea` )
REFERENCES `Airline`.`Aerolinea` (`codigo` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `FK_Vuelo_AeropuertoOrigen`
FOREIGN KEY (`destino` )
REFERENCES `Airline`.`Aeropuerto` (`codigo` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `FK_Vuelo_AeropuertoDestino`
FOREIGN KEY (`origen` )
REFERENCES `Airline`.`Aeropuerto` (`codigo` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `Airline`.`Clases`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Airline`.`Clases` (
`codigo` VARCHAR(8) NOT NULL ,
`descripcion` VARCHAR(45) NULL ,
PRIMARY KEY (`codigo`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `Airline`.`Configuracion`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Airline`.`Configuracion` (
`avion` VARCHAR(8) NOT NULL ,
`clase` VARCHAR(45) NOT NULL ,
PRIMARY KEY (`avion`, `clase`) ,
INDEX `FK_Configuracion_Avion` (`avion` ASC) ,
INDEX `FK_Configuracion_Clase` (`clase` ASC) ,
CONSTRAINT `FK_Configuracion_Avion`
FOREIGN KEY (`avion` )
REFERENCES `Airline`.`Avion` (`codigo` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `FK_Configuracion_Clase`
FOREIGN KEY (`clase` )
REFERENCES `Airline`.`Clases` (`codigo` )
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;