MySQL Forums
Forum List  »  Portuguese

Carregar dados de chaves estrangeiras de uma tabela
Posted by: Pedro Cunha
Date: August 09, 2015 09:59AM

Tenho uma base de dados com o seguinte modelo:

Airport ( iata PK, airport, city, state, country, lat, long)


cancellation_cause ( cod_cancellation PK, description)


Manufaturer (id_manufacturer PK, manufacturer_name)


Model (id_model PK, model_name, id_manufacturer FK)


Airline( airline_code PK, description)


airplane_type (id_AirplaneType PK, airplane_type)


engine_type (id_engine PK, engine_tyoe)


Aircraft_type (id_aircraft PK, aircraft_type)


Airplane (TailNumber PK, id_model FK, id_aircraft FK, airline_code FK, id_AirplaneType FK, id_engine FK, Issue_date, status, year)


Flight (id_flight PK, cod_cancellation FK, TailNumber FK, iata_origin FK, iata_destin FK, Year, Month, DayofMonth, DayofWeek, DepTime, CRSTime, ArrTime, CRSArrTime, FlightNum, AtualElapsedTime, CRSElapsedTime, AirTime, ArrDelay, DepDelay, distane, TaxiIn, TaiOut, Cancelled, Diverted, CarrierDelay, WeatherDelay, NASDelay, SecurityDelay, LateAircraftDelay)


(PK - Primary Key; FK - Foreign Key)

A fonte dos dados são ficheiros csv, um principal com milhões de registos em que possuo informações detalhadas acerca de cada voo (código do aviao, a sua companhia aerea, etc) e outros csv suplementares de menor dimensão como companhia aerea e aviao. O csv avião dá mesmo origem a diversas tabelas (modelo avião, tipo de avião, motor).

A minha dúvida está em como carregar corretamente os dados das chaves estrangeiras. Devo criar uma tabela temporária e efetuar LEFT JOIN'S?

Alguém me pode explicar a maneira mais simples de preencher estas tabelas?

Options: ReplyQuote


Subject
Views
Written By
Posted
Carregar dados de chaves estrangeiras de uma tabela
2175
August 09, 2015 09:59AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.