AirNav Systems Forum

AirNav RadarBox and RadarBox24.com => AirNav RadarBox and RadarBox24.com Discussion => Topic started by: RodBearden on July 04, 2009, 02:06:32 PM

Title: NavData
Post by: RodBearden on July 04, 2009, 02:06:32 PM
Chris recently suggested that the IATA code be made the primary key in the Airlines table, and I think it would be a good idea, but does it actually matter? It does seem to tolerate duplicate ICAO codes anyway.

Also, will this change be possible without having to replace our current NavData files?

Another thing - nobody gave me an answer on the main forum about what the BY condition does. If nobody uses it, can't we get rid of it, or at least make IN the default, and avoid a couple of clicks for every database query that we do?

Rod
Title: Re: NavData
Post by: tarbat on July 04, 2009, 02:19:33 PM
If the only thing the Airlines table is used for is to do lookups to derive airline logos, then I'd recommend we change the primary key to C2 (the IATA code).

Change should be possible in the installer, or at first-run of the new v3 app.  Using SQL like this:

CREATE TEMPORARY TABLE airlines01(
  CN,
  C3,
  CM,
  C2
);

INSERT INTO airlines01
SELECT
  CN,
  C3,
  CM,
  C2
FROM airlines;

DROP TABLE airlines;

CREATE TABLE airlines (
  CN  varchar(80),
  C3  varchar(6),
  CM  varchar(6),
  C2  varchar(6) PRIMARY KEY NOT NULL UNIQUE
);

CREATE INDEX iC2
  ON airlines
  (C2);

CREATE INDEX iC3
  ON airlines
  (C3);

INSERT INTO airlines
SELECT
  CN,
  C3,
  CM,
  C2
FROM airlines01;

DROP TABLE airlines01;
Title: Re: NavData
Post by: AirNav Development on July 04, 2009, 02:19:50 PM
Copied. Pls post more suggestions.