2
I have a database with the following tables:
Airport ( Iata PK, airport, city, state, country, lat, long)
Causa_cancellation ( code PK, description)
Manufacturer (Idfabricante PK, manufacturer name)
Model (Idmodelo PK, model name, manufacturer name FK)
Airline(code PK, description)
Tipoaviao (Idtipoaviao PK, plane type)
Engine type (Idtipo_motor PK, engine type)
Tipolicenca (Idtipo_licenca PK, typo_licenca)
Aviao (codAviao PK, Idmodelo FK, Idtipo_licenca FK, Code-keeping FK, Idtipoaviao FK, Idtipo_motor FK, date registration, state, year)
Flight (Idvoo PK, code FK, CodaviaoFK, iata_origin FK, iata_destination FK, Datavoo, Hora_partida_real, Hora_partida_prevista, Hora_chegada_real, Hora_chegada_prevista, FlightNum, AtualElapsedTime, TempoVoo, distancia, cancelado)
Note: PK - Primary Key; FK - Foreign Key
The data source is files csv. The csv main has millions of records and all flight information. The rest are files csv with information about the plane, airline and airport.
My question is: what is the simplest/most effective way to correctly load foreign key data from the Airplane and Flight tables?
Everything, therefore, is in CSV and you need to give an initial load in your database? Or this load will have to be done periodically?
– cantoni
Some tables I can load directly as is the case of Airport, type of engine and etc. In relation to the tables Plane and flight this is not possible because some data matches are necessary so that everything is correct, maybe using INNER JOIN’s. For example in one of the csv files each log corresponds to a flight and has the fields "Airplane code", "airline", "flight number" and etc. The csv that has the data of the aircraft does not have the airline to which each aircraft belongs, hence having to make a match between the plane code in the two tables
– Pedro Cunha