1, 2. УРОК
CREATE TABLE Company(
ID_comp int primary key auto_increment,
name char(10)
);
CREATE TABLE Trip (
trip_no int primary key auto_increment,
ID_comp int,
FOREIGN KEY (ID_comp) REFERENCES Company(ID_comp),
plane char(10),
town_from char(25),
town_to char(25),
time_out datetime,
time_in datetime
)
CREATE TABLE Passenger(
ID_psg int PRIMARY KEY AUTO_INCREMENT,
name char (20)
);
CREATE TABLE Pass_in_trip(
trip_no int,
FOREIGN key (trip_no) REFERENCES trip(trip_no),
date_ datetime,
Id_psg int,
FOREIGN KEY (ID_psg) REFERENCES passenger(ID_psg),
place char(10),
PRIMARY KEY (trip_no, date_, ID_psg)
)
Select * from company;
INSERT Into company(name) VALUES ('FlyingDilan');
INSERT Into company(name) VALUES ('Ryanair');
INSERT Into company(name) VALUES ('Nordica');
INSERT Into company(name) VALUES ('Airblatic');
INSERT Into company(name) VALUES ('FlyEmirates')
INSERT Into passenger(name) VALUES ('Dylan');
INSERT Into passenger(name) VALUES ('Artur');
INSERT Into passenger(name) VALUES ('Nikita');
INSERT Into passenger(name) VALUES ('Alfred');
INSERT Into passenger(name) VALUES ('Adolf');
Select * from passenger
INSERT INTO trip(ID_comp,plane,town_from,town_to,time_out,time_in)
VALUES(1,'Airbuss','Tallinn','Berlin','2023-10-12','2023-10-13');
INSERT INTO trip(ID_comp,plane,town_from,town_to,time_out,time_in)
VALUES(2,'Airbuss','Tokyo','Seul','2023-10-12','2023-10-13');
INSERT INTO trip(ID_comp,plane,town_from,town_to,time_out,time_in)
VALUES(3,'Airbuss','Toronto','Talinn','2023-10-12','2023-10-13');
INSERT INTO trip(ID_comp,plane,town_from,town_to,time_out,time_in)
VALUES(4,'Airbuss','Madrid','Jakarta','2023-10-12','2023-10-13');
INSERT INTO trip(ID_comp,plane,town_from,town_to,time_out,time_in)
VALUES(5,'Airbuss','Barcelona','Berlin','2023-10-12','2023-10-13');
select * from trip
INSERT INTO pass_in_trip(trip_no,date_,Id_psg,place)
VALUES(3,'2023-10-13',1,'Berlin');
INSERT INTO pass_in_trip(trip_no,date_,Id_psg,place)
VALUES(4,'2023-10-13',2,'Seul');
INSERT INTO pass_in_trip(trip_no,date_,Id_psg,place)
VALUES(5,'2023-10-13',3,'Tallinn');
INSERT INTO pass_in_trip(trip_no,date_,Id_psg,place)
VALUES(6,'2023-10-13',4,'Jakarta');
INSERT INTO pass_in_trip(trip_no,date_,Id_psg,place)
VALUES(7,'2023-10-13',5,'Berlin');
Select * from pass_in_trip



