Commit 29be1da2 by karade

Update Andmebaasi deklaratsioon.sql

parent 737a31d3
Showing with 14 additions and 9 deletions
......@@ -6,12 +6,6 @@ CREATE TABLE `Flights`(
primary key(id)
);
CREATE TABLE `Bookings`(
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`flightNum` CHAR(255) NOT NULL,
`bookingNumber` CHAR(255) NOT NULL,
primary key(id)
);
CREATE TABLE `Users`(
`id` INT NOT NULL AUTO_INCREMENT,
......@@ -25,9 +19,19 @@ CREATE TABLE `Users`(
`seat` CHAR(255) NOT NULL,
`luggageClass` INT NOT NULL,
`flight_id` INT NOT NULL,
primary key(id)
primary key(id),
FOREIGN KEY(flight_id) REFERENCES Flights(id)
);
CREATE TABLE `Bookings`(
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`flightNum` CHAR(255) NOT NULL,
`bookingNumber` CHAR(255) NOT NULL,
`flight_id` INT NOT NULL,
`user_id` INT NOT NULL,
primary key(id),
FOREIGN KEY (user_id) REFERENCES Users(id),
FOREIGN KEY (flight_id) REFERENCES Flights(id)
);
INSERT INTO flights(destination, time, seats)
......@@ -36,4 +40,4 @@ VALUES
("Kuressaare", "021440JUN23", 72),
("Kardla", "081700JUN23", 72),
("Stockholm", "071230JUN23", 72),
("Riga", "122200JUN23", 72);
("Riga", "122200JUN23", 72);
\ No newline at end of file
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