Commit db683276 by karade

Update Andmebaasi deklaratsioon.sql

parent 9eea3935
Showing with 12 additions and 10 deletions
CREATE TABLE `Flights`(
`id` INT NOT NULL AUTO_INCREMENT,
`passenger_id` INT NOT NULL,
`destination` CHAR(255) NOT NULL,
`time` CHAR(255) NOT NULL,
`seats` INT NOT NULL,
primary key(destination)
primary key(id)
);
CREATE TABLE `Bookings`(
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`flightNum` CHAR(255) NOT NULL,
`bookingNumber` BIGINT NOT NULL,
`bookingNumber` CHAR(255) NOT NULL,
primary key(id)
);
CREATE TABLE `Users`(
`documentNum` BIGINT NOT NULL,
`id` INT NOT NULL AUTO_INCREMENT,
`documentNum` CHAR(255) NOT NULL,
`firstName` CHAR(255) NULL,
`lastName` CHAR(255) NULL,
`dateOfBirth` CHAR(255) NULL,
......@@ -20,18 +25,15 @@ CREATE TABLE `Users`(
`checkedIn` TINYINT(1) NOT NULL,
`seat` CHAR(255) NOT NULL,
`luggageClass` INT NOT NULL,
primary key(documentNum)
primary key(id)
);
ALTER TABLE
`Bookings` ADD CONSTRAINT `bookings_flightnum_foreign` FOREIGN KEY(`flightNum`) REFERENCES `Flights`(`destination`);
ALTER TABLE
`Bookings` ADD CONSTRAINT `bookings_bookingnumber_foreign` FOREIGN KEY(`bookingNumber`) REFERENCES `Users`(`documentNum`);
INSERT INTO flights(destination, time, seats)
VALUES
("Helsinki", "050950JUN23", 72),
("Kuressaare", "021440JUN23", 72),
("Kärdla", "081700JUN23", 72),
("Kardla", "081700JUN23", 72),
("Stockholm", "071230JUN23", 72),
("Riga", "122200JUN23", 72);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment