Spring boot application - SQLException: Cannot add foreign key constraint
up vote
0
down vote
favorite
After some research on this problem, I found out that something is probably not right in my database structure, so I have tried the "SHOW ENGINE INNODB STATUS" command to find out what is causing the foreign key SQLException.
Here is the result on "lastest foreign key error"
If I'm right, the table that causes the problem is a temporary table, that's why I don't know what to do.
The other questions here are usually like having an unsigned int in one table, and signed int at foreign key, so that causes error, but I can't see anything like that in my script and the script itself works fine in mysql workbench, but the spring application throws exception when using this database.
The strange thing is that I don't have origin_id anywhere in my code, be it the java code or the sql.
Here is the database script:
-- MySQL Script generated by MySQL Workbench
-- Tue Oct 9 20:16:01 2018
-- 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';
-- -----------------------------------------------------
-- DATABASE flights
-- -----------------------------------------------------
DROP DATABASE IF EXISTS `flights` ;
-- -----------------------------------------------------
-- DATABASE flights
-- -----------------------------------------------------
CREATE DATABASE `flights` ;
-- -----------------------------------------------------
-- Schema flights
-- -----------------------------------------------------
DROP SCHEMA IF EXISTS `flights` ;
-- -----------------------------------------------------
-- Schema flights
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `flights` DEFAULT CHARACTER SET utf8 ;
USE `flights` ;
-- -----------------------------------------------------
-- Table `flights`.`user`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`user` (
`id` REAL NOT NULL,
`username` VARCHAR(50) NULL,
`password` VARCHAR(50) NULL,
`email` TEXT NULL,
`role` VARCHAR(10) NULL DEFAULT "USER",
`created_at` TIMESTAMP NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `flights`.`airline`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`airline` (
`id` REAL NOT NULL auto_increment,
`name` VARCHAR(100) NULL,
`created_at` TIMESTAMP NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `flights`.`plane`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`plane` (
`id` REAL NOT NULL auto_increment,
`seats` INT NULL,
`airline_id` REAL NULL,
`created_at` TIMESTAMP NULL,
PRIMARY KEY (`id`),
CONSTRAINT `airline_id`
FOREIGN KEY (`airline_id`)
REFERENCES `flights`.`airline` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
CREATE INDEX `airline_id_idx` ON `flights`.`plane` (`airline_id` ASC) VISIBLE;
-- -----------------------------------------------------
-- Table `flights`.`airport`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`airport` (
`id` REAL NOT NULL auto_increment,
`name` VARCHAR(100) NULL,
`city` VARCHAR(50) NULL,
`country` VARCHAR(50) NULL,
`created_at` TIMESTAMP NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `flights`.`flight`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`flight` (
`id` REAL NOT NULL auto_increment,
`departure_time` TIMESTAMP NULL,
`arrival_time` TIMESTAMP NULL,
`adult_prise` REAL NULL,
`reduced_prise` REAL NULL,
`plane_id` REAL NULL,
`departure_airport_id` REAL NULL,
`arrival_airport_id` REAL NULL,
`created_at` TIMESTAMP NULL,
`airline_id` REAL NOT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `airline_id_2`
FOREIGN KEY (`airline_id`)
REFERENCES `flights`.`airline` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `plane_id`
FOREIGN KEY (`plane_id`)
REFERENCES `flights`.`plane` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `departure_airport_id`
FOREIGN KEY (`departure_airport_id`)
REFERENCES `flights`.`airport` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `arrival_airport_id`
FOREIGN KEY (`arrival_airport_id`)
REFERENCES `flights`.`airport` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
CREATE INDEX `plane_id_idx` ON `flights`.`flight` (`plane_id` ASC) VISIBLE;
CREATE INDEX `departure_airport_id_idx` ON `flights`.`flight` (`departure_airport_id` ASC) VISIBLE;
CREATE INDEX `arrival_airport_id_idx` ON `flights`.`flight` (`arrival_airport_id` ASC) VISIBLE;
-- -----------------------------------------------------
-- Table `flights`.`reservation`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`reservation` (
`id` REAL NOT NULL,
`reservation_time` TIMESTAMP NULL,
`adult_ticket` SMALLINT NULL,
`reduced_ticket` SMALLINT NULL,
`user_id` REAL NOT NULL,
`flight_id` REAL NOT NULL,
`created_at` TIMESTAMP NULL,
PRIMARY KEY (`id`),
CONSTRAINT `user_id`
FOREIGN KEY (`user_id`)
REFERENCES `flights`.`user` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `flight_id`
FOREIGN KEY (`flight_id`)
REFERENCES `flights`.`flight` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
CREATE INDEX `user_id_idx` ON `flights`.`reservation` (`user_id` ASC) VISIBLE;
CREATE INDEX `flight_id_idx` ON `flights`.`reservation` (`flight_id` ASC) VISIBLE;
USE `flights` ;
-- -----------------------------------------------------
-- Placeholder table for view `flights`.`v_airline`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`v_airline` (`id` REAL, `name` VARCHAR(30), `created_at` TIMESTAMP);
-- -----------------------------------------------------
-- Placeholder table for view `flights`.`v_airport`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`v_airport` (`id` REAL, `name` VARCHAR(100), `city` VARCHAR(50), `country` VARCHAR(50), `created_at` TIMESTAMP);
-- -----------------------------------------------------
-- Placeholder table for view `flights`.`v_flight`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`v_flight` (`id` REAL, `departure_time` TIMESTAMP, `arrival_time` TIMESTAMP, `adult_prise` REAL, `reduced_prise` REAL, `plane_id` REAL, `departure_airport_id` REAL, `arrival_airport_id` REAL, `created_at` TIMESTAMP);
-- -----------------------------------------------------
-- Placeholder table for view `flights`.`v_plane`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`v_plane` (`id` REAL, `seats` INT, `airline_id` REAL, `created_at` TIMESTAMP);
-- -----------------------------------------------------
-- Placeholder table for view `flights`.`v_reservation`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`v_reservation` (`id` REAL, `reservation_time` TIMESTAMP, `adult_ticket` SMALLINT, `reduced_ticket` SMALLINT, `user_id` REAL, `flight_id` REAL, `created_at` TIMESTAMP);
-- -----------------------------------------------------
-- Placeholder table for view `flights`.`v_user`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`v_user` (`id` REAL, `username` VARCHAR(50), `password` VARCHAR(50), `email` TEXT, `role` VARCHAR(50), `created_at` TIMESTAMP);
-- -----------------------------------------------------
-- View `flights`.`v_airline`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flights`.`v_airline`;
USE `flights`;
CREATE OR REPLACE VIEW `v_airline` AS select * from airline;
-- -----------------------------------------------------
-- View `flights`.`v_airport`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flights`.`v_airport`;
USE `flights`;
CREATE OR REPLACE VIEW `v_airport` AS select * from airport;
-- -----------------------------------------------------
-- View `flights`.`v_flight`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flights`.`v_flight`;
USE `flights`;
CREATE OR REPLACE VIEW `v_flight` AS select * from flight;
-- -----------------------------------------------------
-- View `flights`.`v_plane`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flights`.`v_plane`;
USE `flights`;
CREATE OR REPLACE VIEW `v_plane` AS select * from plane;
-- -----------------------------------------------------
-- View `flights`.`v_reservation`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flights`.`v_reservation`;
USE `flights`;
CREATE OR REPLACE VIEW `v_reservation` AS select * from reservation;
-- -----------------------------------------------------
-- View `flights`.`v_user`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flights`.`v_user`;
USE `flights`;
CREATE OR REPLACE VIEW `v_user` AS select * from user;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
mysql spring spring-boot foreign-keys
add a comment |
up vote
0
down vote
favorite
After some research on this problem, I found out that something is probably not right in my database structure, so I have tried the "SHOW ENGINE INNODB STATUS" command to find out what is causing the foreign key SQLException.
Here is the result on "lastest foreign key error"
If I'm right, the table that causes the problem is a temporary table, that's why I don't know what to do.
The other questions here are usually like having an unsigned int in one table, and signed int at foreign key, so that causes error, but I can't see anything like that in my script and the script itself works fine in mysql workbench, but the spring application throws exception when using this database.
The strange thing is that I don't have origin_id anywhere in my code, be it the java code or the sql.
Here is the database script:
-- MySQL Script generated by MySQL Workbench
-- Tue Oct 9 20:16:01 2018
-- 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';
-- -----------------------------------------------------
-- DATABASE flights
-- -----------------------------------------------------
DROP DATABASE IF EXISTS `flights` ;
-- -----------------------------------------------------
-- DATABASE flights
-- -----------------------------------------------------
CREATE DATABASE `flights` ;
-- -----------------------------------------------------
-- Schema flights
-- -----------------------------------------------------
DROP SCHEMA IF EXISTS `flights` ;
-- -----------------------------------------------------
-- Schema flights
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `flights` DEFAULT CHARACTER SET utf8 ;
USE `flights` ;
-- -----------------------------------------------------
-- Table `flights`.`user`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`user` (
`id` REAL NOT NULL,
`username` VARCHAR(50) NULL,
`password` VARCHAR(50) NULL,
`email` TEXT NULL,
`role` VARCHAR(10) NULL DEFAULT "USER",
`created_at` TIMESTAMP NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `flights`.`airline`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`airline` (
`id` REAL NOT NULL auto_increment,
`name` VARCHAR(100) NULL,
`created_at` TIMESTAMP NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `flights`.`plane`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`plane` (
`id` REAL NOT NULL auto_increment,
`seats` INT NULL,
`airline_id` REAL NULL,
`created_at` TIMESTAMP NULL,
PRIMARY KEY (`id`),
CONSTRAINT `airline_id`
FOREIGN KEY (`airline_id`)
REFERENCES `flights`.`airline` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
CREATE INDEX `airline_id_idx` ON `flights`.`plane` (`airline_id` ASC) VISIBLE;
-- -----------------------------------------------------
-- Table `flights`.`airport`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`airport` (
`id` REAL NOT NULL auto_increment,
`name` VARCHAR(100) NULL,
`city` VARCHAR(50) NULL,
`country` VARCHAR(50) NULL,
`created_at` TIMESTAMP NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `flights`.`flight`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`flight` (
`id` REAL NOT NULL auto_increment,
`departure_time` TIMESTAMP NULL,
`arrival_time` TIMESTAMP NULL,
`adult_prise` REAL NULL,
`reduced_prise` REAL NULL,
`plane_id` REAL NULL,
`departure_airport_id` REAL NULL,
`arrival_airport_id` REAL NULL,
`created_at` TIMESTAMP NULL,
`airline_id` REAL NOT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `airline_id_2`
FOREIGN KEY (`airline_id`)
REFERENCES `flights`.`airline` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `plane_id`
FOREIGN KEY (`plane_id`)
REFERENCES `flights`.`plane` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `departure_airport_id`
FOREIGN KEY (`departure_airport_id`)
REFERENCES `flights`.`airport` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `arrival_airport_id`
FOREIGN KEY (`arrival_airport_id`)
REFERENCES `flights`.`airport` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
CREATE INDEX `plane_id_idx` ON `flights`.`flight` (`plane_id` ASC) VISIBLE;
CREATE INDEX `departure_airport_id_idx` ON `flights`.`flight` (`departure_airport_id` ASC) VISIBLE;
CREATE INDEX `arrival_airport_id_idx` ON `flights`.`flight` (`arrival_airport_id` ASC) VISIBLE;
-- -----------------------------------------------------
-- Table `flights`.`reservation`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`reservation` (
`id` REAL NOT NULL,
`reservation_time` TIMESTAMP NULL,
`adult_ticket` SMALLINT NULL,
`reduced_ticket` SMALLINT NULL,
`user_id` REAL NOT NULL,
`flight_id` REAL NOT NULL,
`created_at` TIMESTAMP NULL,
PRIMARY KEY (`id`),
CONSTRAINT `user_id`
FOREIGN KEY (`user_id`)
REFERENCES `flights`.`user` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `flight_id`
FOREIGN KEY (`flight_id`)
REFERENCES `flights`.`flight` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
CREATE INDEX `user_id_idx` ON `flights`.`reservation` (`user_id` ASC) VISIBLE;
CREATE INDEX `flight_id_idx` ON `flights`.`reservation` (`flight_id` ASC) VISIBLE;
USE `flights` ;
-- -----------------------------------------------------
-- Placeholder table for view `flights`.`v_airline`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`v_airline` (`id` REAL, `name` VARCHAR(30), `created_at` TIMESTAMP);
-- -----------------------------------------------------
-- Placeholder table for view `flights`.`v_airport`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`v_airport` (`id` REAL, `name` VARCHAR(100), `city` VARCHAR(50), `country` VARCHAR(50), `created_at` TIMESTAMP);
-- -----------------------------------------------------
-- Placeholder table for view `flights`.`v_flight`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`v_flight` (`id` REAL, `departure_time` TIMESTAMP, `arrival_time` TIMESTAMP, `adult_prise` REAL, `reduced_prise` REAL, `plane_id` REAL, `departure_airport_id` REAL, `arrival_airport_id` REAL, `created_at` TIMESTAMP);
-- -----------------------------------------------------
-- Placeholder table for view `flights`.`v_plane`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`v_plane` (`id` REAL, `seats` INT, `airline_id` REAL, `created_at` TIMESTAMP);
-- -----------------------------------------------------
-- Placeholder table for view `flights`.`v_reservation`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`v_reservation` (`id` REAL, `reservation_time` TIMESTAMP, `adult_ticket` SMALLINT, `reduced_ticket` SMALLINT, `user_id` REAL, `flight_id` REAL, `created_at` TIMESTAMP);
-- -----------------------------------------------------
-- Placeholder table for view `flights`.`v_user`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`v_user` (`id` REAL, `username` VARCHAR(50), `password` VARCHAR(50), `email` TEXT, `role` VARCHAR(50), `created_at` TIMESTAMP);
-- -----------------------------------------------------
-- View `flights`.`v_airline`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flights`.`v_airline`;
USE `flights`;
CREATE OR REPLACE VIEW `v_airline` AS select * from airline;
-- -----------------------------------------------------
-- View `flights`.`v_airport`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flights`.`v_airport`;
USE `flights`;
CREATE OR REPLACE VIEW `v_airport` AS select * from airport;
-- -----------------------------------------------------
-- View `flights`.`v_flight`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flights`.`v_flight`;
USE `flights`;
CREATE OR REPLACE VIEW `v_flight` AS select * from flight;
-- -----------------------------------------------------
-- View `flights`.`v_plane`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flights`.`v_plane`;
USE `flights`;
CREATE OR REPLACE VIEW `v_plane` AS select * from plane;
-- -----------------------------------------------------
-- View `flights`.`v_reservation`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flights`.`v_reservation`;
USE `flights`;
CREATE OR REPLACE VIEW `v_reservation` AS select * from reservation;
-- -----------------------------------------------------
-- View `flights`.`v_user`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flights`.`v_user`;
USE `flights`;
CREATE OR REPLACE VIEW `v_user` AS select * from user;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
mysql spring spring-boot foreign-keys
Hi. Please use text, not images/links, for text (including code, tables & ERDs). Use a link/image only for convenience to supplement text and/or for what cannot be given in text. And never give a diagram without a legend/key. Use edit functions to inline, not links, if you have the rep--make your post self-contained.
– philipxy
Nov 11 at 20:44
1
You didn't used to have origin, like for departure_airport, maybe in a different database? Please show the query that caused that error. Please give a Minimal, Complete, and Verifiable example.
– philipxy
Nov 11 at 21:20
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
After some research on this problem, I found out that something is probably not right in my database structure, so I have tried the "SHOW ENGINE INNODB STATUS" command to find out what is causing the foreign key SQLException.
Here is the result on "lastest foreign key error"
If I'm right, the table that causes the problem is a temporary table, that's why I don't know what to do.
The other questions here are usually like having an unsigned int in one table, and signed int at foreign key, so that causes error, but I can't see anything like that in my script and the script itself works fine in mysql workbench, but the spring application throws exception when using this database.
The strange thing is that I don't have origin_id anywhere in my code, be it the java code or the sql.
Here is the database script:
-- MySQL Script generated by MySQL Workbench
-- Tue Oct 9 20:16:01 2018
-- 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';
-- -----------------------------------------------------
-- DATABASE flights
-- -----------------------------------------------------
DROP DATABASE IF EXISTS `flights` ;
-- -----------------------------------------------------
-- DATABASE flights
-- -----------------------------------------------------
CREATE DATABASE `flights` ;
-- -----------------------------------------------------
-- Schema flights
-- -----------------------------------------------------
DROP SCHEMA IF EXISTS `flights` ;
-- -----------------------------------------------------
-- Schema flights
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `flights` DEFAULT CHARACTER SET utf8 ;
USE `flights` ;
-- -----------------------------------------------------
-- Table `flights`.`user`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`user` (
`id` REAL NOT NULL,
`username` VARCHAR(50) NULL,
`password` VARCHAR(50) NULL,
`email` TEXT NULL,
`role` VARCHAR(10) NULL DEFAULT "USER",
`created_at` TIMESTAMP NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `flights`.`airline`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`airline` (
`id` REAL NOT NULL auto_increment,
`name` VARCHAR(100) NULL,
`created_at` TIMESTAMP NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `flights`.`plane`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`plane` (
`id` REAL NOT NULL auto_increment,
`seats` INT NULL,
`airline_id` REAL NULL,
`created_at` TIMESTAMP NULL,
PRIMARY KEY (`id`),
CONSTRAINT `airline_id`
FOREIGN KEY (`airline_id`)
REFERENCES `flights`.`airline` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
CREATE INDEX `airline_id_idx` ON `flights`.`plane` (`airline_id` ASC) VISIBLE;
-- -----------------------------------------------------
-- Table `flights`.`airport`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`airport` (
`id` REAL NOT NULL auto_increment,
`name` VARCHAR(100) NULL,
`city` VARCHAR(50) NULL,
`country` VARCHAR(50) NULL,
`created_at` TIMESTAMP NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `flights`.`flight`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`flight` (
`id` REAL NOT NULL auto_increment,
`departure_time` TIMESTAMP NULL,
`arrival_time` TIMESTAMP NULL,
`adult_prise` REAL NULL,
`reduced_prise` REAL NULL,
`plane_id` REAL NULL,
`departure_airport_id` REAL NULL,
`arrival_airport_id` REAL NULL,
`created_at` TIMESTAMP NULL,
`airline_id` REAL NOT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `airline_id_2`
FOREIGN KEY (`airline_id`)
REFERENCES `flights`.`airline` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `plane_id`
FOREIGN KEY (`plane_id`)
REFERENCES `flights`.`plane` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `departure_airport_id`
FOREIGN KEY (`departure_airport_id`)
REFERENCES `flights`.`airport` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `arrival_airport_id`
FOREIGN KEY (`arrival_airport_id`)
REFERENCES `flights`.`airport` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
CREATE INDEX `plane_id_idx` ON `flights`.`flight` (`plane_id` ASC) VISIBLE;
CREATE INDEX `departure_airport_id_idx` ON `flights`.`flight` (`departure_airport_id` ASC) VISIBLE;
CREATE INDEX `arrival_airport_id_idx` ON `flights`.`flight` (`arrival_airport_id` ASC) VISIBLE;
-- -----------------------------------------------------
-- Table `flights`.`reservation`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`reservation` (
`id` REAL NOT NULL,
`reservation_time` TIMESTAMP NULL,
`adult_ticket` SMALLINT NULL,
`reduced_ticket` SMALLINT NULL,
`user_id` REAL NOT NULL,
`flight_id` REAL NOT NULL,
`created_at` TIMESTAMP NULL,
PRIMARY KEY (`id`),
CONSTRAINT `user_id`
FOREIGN KEY (`user_id`)
REFERENCES `flights`.`user` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `flight_id`
FOREIGN KEY (`flight_id`)
REFERENCES `flights`.`flight` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
CREATE INDEX `user_id_idx` ON `flights`.`reservation` (`user_id` ASC) VISIBLE;
CREATE INDEX `flight_id_idx` ON `flights`.`reservation` (`flight_id` ASC) VISIBLE;
USE `flights` ;
-- -----------------------------------------------------
-- Placeholder table for view `flights`.`v_airline`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`v_airline` (`id` REAL, `name` VARCHAR(30), `created_at` TIMESTAMP);
-- -----------------------------------------------------
-- Placeholder table for view `flights`.`v_airport`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`v_airport` (`id` REAL, `name` VARCHAR(100), `city` VARCHAR(50), `country` VARCHAR(50), `created_at` TIMESTAMP);
-- -----------------------------------------------------
-- Placeholder table for view `flights`.`v_flight`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`v_flight` (`id` REAL, `departure_time` TIMESTAMP, `arrival_time` TIMESTAMP, `adult_prise` REAL, `reduced_prise` REAL, `plane_id` REAL, `departure_airport_id` REAL, `arrival_airport_id` REAL, `created_at` TIMESTAMP);
-- -----------------------------------------------------
-- Placeholder table for view `flights`.`v_plane`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`v_plane` (`id` REAL, `seats` INT, `airline_id` REAL, `created_at` TIMESTAMP);
-- -----------------------------------------------------
-- Placeholder table for view `flights`.`v_reservation`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`v_reservation` (`id` REAL, `reservation_time` TIMESTAMP, `adult_ticket` SMALLINT, `reduced_ticket` SMALLINT, `user_id` REAL, `flight_id` REAL, `created_at` TIMESTAMP);
-- -----------------------------------------------------
-- Placeholder table for view `flights`.`v_user`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`v_user` (`id` REAL, `username` VARCHAR(50), `password` VARCHAR(50), `email` TEXT, `role` VARCHAR(50), `created_at` TIMESTAMP);
-- -----------------------------------------------------
-- View `flights`.`v_airline`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flights`.`v_airline`;
USE `flights`;
CREATE OR REPLACE VIEW `v_airline` AS select * from airline;
-- -----------------------------------------------------
-- View `flights`.`v_airport`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flights`.`v_airport`;
USE `flights`;
CREATE OR REPLACE VIEW `v_airport` AS select * from airport;
-- -----------------------------------------------------
-- View `flights`.`v_flight`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flights`.`v_flight`;
USE `flights`;
CREATE OR REPLACE VIEW `v_flight` AS select * from flight;
-- -----------------------------------------------------
-- View `flights`.`v_plane`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flights`.`v_plane`;
USE `flights`;
CREATE OR REPLACE VIEW `v_plane` AS select * from plane;
-- -----------------------------------------------------
-- View `flights`.`v_reservation`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flights`.`v_reservation`;
USE `flights`;
CREATE OR REPLACE VIEW `v_reservation` AS select * from reservation;
-- -----------------------------------------------------
-- View `flights`.`v_user`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flights`.`v_user`;
USE `flights`;
CREATE OR REPLACE VIEW `v_user` AS select * from user;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
mysql spring spring-boot foreign-keys
After some research on this problem, I found out that something is probably not right in my database structure, so I have tried the "SHOW ENGINE INNODB STATUS" command to find out what is causing the foreign key SQLException.
Here is the result on "lastest foreign key error"
If I'm right, the table that causes the problem is a temporary table, that's why I don't know what to do.
The other questions here are usually like having an unsigned int in one table, and signed int at foreign key, so that causes error, but I can't see anything like that in my script and the script itself works fine in mysql workbench, but the spring application throws exception when using this database.
The strange thing is that I don't have origin_id anywhere in my code, be it the java code or the sql.
Here is the database script:
-- MySQL Script generated by MySQL Workbench
-- Tue Oct 9 20:16:01 2018
-- 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';
-- -----------------------------------------------------
-- DATABASE flights
-- -----------------------------------------------------
DROP DATABASE IF EXISTS `flights` ;
-- -----------------------------------------------------
-- DATABASE flights
-- -----------------------------------------------------
CREATE DATABASE `flights` ;
-- -----------------------------------------------------
-- Schema flights
-- -----------------------------------------------------
DROP SCHEMA IF EXISTS `flights` ;
-- -----------------------------------------------------
-- Schema flights
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `flights` DEFAULT CHARACTER SET utf8 ;
USE `flights` ;
-- -----------------------------------------------------
-- Table `flights`.`user`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`user` (
`id` REAL NOT NULL,
`username` VARCHAR(50) NULL,
`password` VARCHAR(50) NULL,
`email` TEXT NULL,
`role` VARCHAR(10) NULL DEFAULT "USER",
`created_at` TIMESTAMP NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `flights`.`airline`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`airline` (
`id` REAL NOT NULL auto_increment,
`name` VARCHAR(100) NULL,
`created_at` TIMESTAMP NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `flights`.`plane`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`plane` (
`id` REAL NOT NULL auto_increment,
`seats` INT NULL,
`airline_id` REAL NULL,
`created_at` TIMESTAMP NULL,
PRIMARY KEY (`id`),
CONSTRAINT `airline_id`
FOREIGN KEY (`airline_id`)
REFERENCES `flights`.`airline` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
CREATE INDEX `airline_id_idx` ON `flights`.`plane` (`airline_id` ASC) VISIBLE;
-- -----------------------------------------------------
-- Table `flights`.`airport`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`airport` (
`id` REAL NOT NULL auto_increment,
`name` VARCHAR(100) NULL,
`city` VARCHAR(50) NULL,
`country` VARCHAR(50) NULL,
`created_at` TIMESTAMP NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `flights`.`flight`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`flight` (
`id` REAL NOT NULL auto_increment,
`departure_time` TIMESTAMP NULL,
`arrival_time` TIMESTAMP NULL,
`adult_prise` REAL NULL,
`reduced_prise` REAL NULL,
`plane_id` REAL NULL,
`departure_airport_id` REAL NULL,
`arrival_airport_id` REAL NULL,
`created_at` TIMESTAMP NULL,
`airline_id` REAL NOT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `airline_id_2`
FOREIGN KEY (`airline_id`)
REFERENCES `flights`.`airline` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `plane_id`
FOREIGN KEY (`plane_id`)
REFERENCES `flights`.`plane` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `departure_airport_id`
FOREIGN KEY (`departure_airport_id`)
REFERENCES `flights`.`airport` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `arrival_airport_id`
FOREIGN KEY (`arrival_airport_id`)
REFERENCES `flights`.`airport` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
CREATE INDEX `plane_id_idx` ON `flights`.`flight` (`plane_id` ASC) VISIBLE;
CREATE INDEX `departure_airport_id_idx` ON `flights`.`flight` (`departure_airport_id` ASC) VISIBLE;
CREATE INDEX `arrival_airport_id_idx` ON `flights`.`flight` (`arrival_airport_id` ASC) VISIBLE;
-- -----------------------------------------------------
-- Table `flights`.`reservation`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`reservation` (
`id` REAL NOT NULL,
`reservation_time` TIMESTAMP NULL,
`adult_ticket` SMALLINT NULL,
`reduced_ticket` SMALLINT NULL,
`user_id` REAL NOT NULL,
`flight_id` REAL NOT NULL,
`created_at` TIMESTAMP NULL,
PRIMARY KEY (`id`),
CONSTRAINT `user_id`
FOREIGN KEY (`user_id`)
REFERENCES `flights`.`user` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `flight_id`
FOREIGN KEY (`flight_id`)
REFERENCES `flights`.`flight` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
CREATE INDEX `user_id_idx` ON `flights`.`reservation` (`user_id` ASC) VISIBLE;
CREATE INDEX `flight_id_idx` ON `flights`.`reservation` (`flight_id` ASC) VISIBLE;
USE `flights` ;
-- -----------------------------------------------------
-- Placeholder table for view `flights`.`v_airline`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`v_airline` (`id` REAL, `name` VARCHAR(30), `created_at` TIMESTAMP);
-- -----------------------------------------------------
-- Placeholder table for view `flights`.`v_airport`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`v_airport` (`id` REAL, `name` VARCHAR(100), `city` VARCHAR(50), `country` VARCHAR(50), `created_at` TIMESTAMP);
-- -----------------------------------------------------
-- Placeholder table for view `flights`.`v_flight`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`v_flight` (`id` REAL, `departure_time` TIMESTAMP, `arrival_time` TIMESTAMP, `adult_prise` REAL, `reduced_prise` REAL, `plane_id` REAL, `departure_airport_id` REAL, `arrival_airport_id` REAL, `created_at` TIMESTAMP);
-- -----------------------------------------------------
-- Placeholder table for view `flights`.`v_plane`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`v_plane` (`id` REAL, `seats` INT, `airline_id` REAL, `created_at` TIMESTAMP);
-- -----------------------------------------------------
-- Placeholder table for view `flights`.`v_reservation`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`v_reservation` (`id` REAL, `reservation_time` TIMESTAMP, `adult_ticket` SMALLINT, `reduced_ticket` SMALLINT, `user_id` REAL, `flight_id` REAL, `created_at` TIMESTAMP);
-- -----------------------------------------------------
-- Placeholder table for view `flights`.`v_user`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `flights`.`v_user` (`id` REAL, `username` VARCHAR(50), `password` VARCHAR(50), `email` TEXT, `role` VARCHAR(50), `created_at` TIMESTAMP);
-- -----------------------------------------------------
-- View `flights`.`v_airline`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flights`.`v_airline`;
USE `flights`;
CREATE OR REPLACE VIEW `v_airline` AS select * from airline;
-- -----------------------------------------------------
-- View `flights`.`v_airport`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flights`.`v_airport`;
USE `flights`;
CREATE OR REPLACE VIEW `v_airport` AS select * from airport;
-- -----------------------------------------------------
-- View `flights`.`v_flight`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flights`.`v_flight`;
USE `flights`;
CREATE OR REPLACE VIEW `v_flight` AS select * from flight;
-- -----------------------------------------------------
-- View `flights`.`v_plane`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flights`.`v_plane`;
USE `flights`;
CREATE OR REPLACE VIEW `v_plane` AS select * from plane;
-- -----------------------------------------------------
-- View `flights`.`v_reservation`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flights`.`v_reservation`;
USE `flights`;
CREATE OR REPLACE VIEW `v_reservation` AS select * from reservation;
-- -----------------------------------------------------
-- View `flights`.`v_user`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `flights`.`v_user`;
USE `flights`;
CREATE OR REPLACE VIEW `v_user` AS select * from user;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
mysql spring spring-boot foreign-keys
mysql spring spring-boot foreign-keys
asked Nov 11 at 20:38
Ereghard
22
22
Hi. Please use text, not images/links, for text (including code, tables & ERDs). Use a link/image only for convenience to supplement text and/or for what cannot be given in text. And never give a diagram without a legend/key. Use edit functions to inline, not links, if you have the rep--make your post self-contained.
– philipxy
Nov 11 at 20:44
1
You didn't used to have origin, like for departure_airport, maybe in a different database? Please show the query that caused that error. Please give a Minimal, Complete, and Verifiable example.
– philipxy
Nov 11 at 21:20
add a comment |
Hi. Please use text, not images/links, for text (including code, tables & ERDs). Use a link/image only for convenience to supplement text and/or for what cannot be given in text. And never give a diagram without a legend/key. Use edit functions to inline, not links, if you have the rep--make your post self-contained.
– philipxy
Nov 11 at 20:44
1
You didn't used to have origin, like for departure_airport, maybe in a different database? Please show the query that caused that error. Please give a Minimal, Complete, and Verifiable example.
– philipxy
Nov 11 at 21:20
Hi. Please use text, not images/links, for text (including code, tables & ERDs). Use a link/image only for convenience to supplement text and/or for what cannot be given in text. And never give a diagram without a legend/key. Use edit functions to inline, not links, if you have the rep--make your post self-contained.
– philipxy
Nov 11 at 20:44
Hi. Please use text, not images/links, for text (including code, tables & ERDs). Use a link/image only for convenience to supplement text and/or for what cannot be given in text. And never give a diagram without a legend/key. Use edit functions to inline, not links, if you have the rep--make your post self-contained.
– philipxy
Nov 11 at 20:44
1
1
You didn't used to have origin, like for departure_airport, maybe in a different database? Please show the query that caused that error. Please give a Minimal, Complete, and Verifiable example.
– philipxy
Nov 11 at 21:20
You didn't used to have origin, like for departure_airport, maybe in a different database? Please show the query that caused that error. Please give a Minimal, Complete, and Verifiable example.
– philipxy
Nov 11 at 21:20
add a comment |
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53253002%2fspring-boot-application-sqlexception-cannot-add-foreign-key-constraint%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53253002%2fspring-boot-application-sqlexception-cannot-add-foreign-key-constraint%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Hi. Please use text, not images/links, for text (including code, tables & ERDs). Use a link/image only for convenience to supplement text and/or for what cannot be given in text. And never give a diagram without a legend/key. Use edit functions to inline, not links, if you have the rep--make your post self-contained.
– philipxy
Nov 11 at 20:44
1
You didn't used to have origin, like for departure_airport, maybe in a different database? Please show the query that caused that error. Please give a Minimal, Complete, and Verifiable example.
– philipxy
Nov 11 at 21:20