Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
305 changes: 305 additions & 0 deletions DATABASE_SCHEMA.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,305 @@
# CIFP Database Schema Documentation

This document describes the SQLite database schema created by the CIFP parser for ARINC424 v18 format data.

## Overview

The database contains tables for all navigation elements defined in the ARINC424 specification. Table names follow the pattern:
```
{primary|continuation}_{SectionCode}_{SubSectionCode}_{application}_{Description}
```

All latitude/longitude fields are automatically converted to WGS84 decimal format with `_WGS84` suffix columns.

## Core Tables

### Airport Reference Points
**Table:** `primary_P_A_base_Airport - Reference Points`

Core airport information and location data.

| Column | Type | Description |
|--------|------|-------------|
| LandingFacilityIcaoIdentifier | TEXT | 4-letter ICAO airport code |
| LandingFacilityName | TEXT | Full airport name |
| LandingFacilityLatitude_WGS84 | REAL | Airport latitude in decimal degrees |
| LandingFacilityLongitude_WGS84 | REAL | Airport longitude in decimal degrees |
| LandingFacilityElevation | INTEGER | Airport elevation in feet MSL |
| MagneticVariation | REAL | Local magnetic variation |
| LongestRunway | INTEGER | Length of longest runway (hundreds of feet) |

### Runways
**Table:** `primary_P_G_base_Airport - Runways`

Runway physical characteristics and coordinates.

| Column | Type | Description |
|--------|------|-------------|
| LandingFacilityIcaoIdentifier | TEXT | Associated airport ICAO code |
| RunwayIdentifier | TEXT | Runway designator (e.g., "18L", "36R") |
| RunwayLatitude_WGS84 | REAL | Runway threshold latitude |
| RunwayLongitude_WGS84 | REAL | Runway threshold longitude |
| RunwayLength | INTEGER | Runway length in feet |
| RunwayWidth | INTEGER | Runway width in feet |
| RunwayMagneticBearing | INTEGER | Magnetic bearing of runway centerline |
| LandingThresholdElevation | INTEGER | Threshold elevation in feet MSL |

### Standard Instrument Departures (SIDs)
**Table:** `primary_P_D_base_Airport - SIDs`

SID procedure definitions with waypoint sequences.

| Column | Type | Description |
|--------|------|-------------|
| LandingFacilityIcaoIdentifier | TEXT | Departure airport ICAO code |
| SIDSTARApproachIdentifier | TEXT | SID procedure name |
| TransitionIdentifier | TEXT | Transition name (if applicable) |
| SequenceNumber | INTEGER | Step sequence in procedure |
| FixIdentifier | TEXT | Waypoint/fix identifier |
| PathAndTermination | TEXT | Path termination type (ARINC424) |
| MagneticCourse | INTEGER | Magnetic course (tenths of degrees) |
| Altitude_1 | INTEGER | Primary altitude constraint (feet) |
| Altitude_2 | INTEGER | Secondary altitude constraint (feet) |
| AltitudeDescription | TEXT | Altitude constraint type |
| RouteDistanceHoldingDistanceOrTime | INTEGER | Distance or time constraint |
| TurnDirection | TEXT | Turn direction (L/R) |

### Standard Terminal Arrival Routes (STARs)
**Table:** `primary_P_E_base_Airport - STARs`

STAR procedure definitions (same structure as SIDs).

### Approach Procedures
**Table:** `primary_P_F_base_Airport - Approach Procedures`

Instrument approach procedure definitions.

| Column | Type | Description |
|--------|------|-------------|
| LandingFacilityIcaoIdentifier | TEXT | Destination airport ICAO code |
| SIDSTARApproachIdentifier | TEXT | Approach procedure name |
| TransitionIdentifier | TEXT | Transition name (if applicable) |
| RouteType | TEXT | Approach type code |
| SequenceNumber | INTEGER | Step sequence in procedure |
| FixIdentifier | TEXT | Waypoint/fix identifier |
| PathAndTermination | TEXT | Path termination type |
| MagneticCourse | INTEGER | Magnetic course (tenths of degrees) |
| Altitude_1 | INTEGER | Primary altitude constraint |
| Altitude_2 | INTEGER | Secondary altitude constraint |
| AltitudeDescription | TEXT | Altitude constraint type |
| Rho | INTEGER | Distance from navaid (tenths of NM) |
| Theta | INTEGER | Bearing from navaid (tenths of degrees) |
| RNP | REAL | Required Navigation Performance |
| VerticalAngle | REAL | Vertical path angle |

### Terminal Waypoints
**Table:** `primary_P_C_base_Airport - Terminal Waypoints`

Airport terminal area waypoints and fixes.

| Column | Type | Description |
|--------|------|-------------|
| RegionCode | TEXT | Associated airport ICAO code |
| waypointIdentifier | TEXT | Waypoint identifier |
| waypointLatitude_WGS84 | REAL | Waypoint latitude |
| waypointLongitude_WGS84 | REAL | Waypoint longitude |
| WaypointType | TEXT | Type of waypoint |
| WaypointUsage | TEXT | Usage classification |

### VHF Navigation Aids
**Table:** `primary_D__base_Navaid - VHF Navaid`

VOR, DME, and TACAN navigation aids.

| Column | Type | Description |
|--------|------|-------------|
| vorIdentifier | TEXT | Navaid identifier |
| vorName | TEXT | Navaid name |
| vorFrequency | REAL | Operating frequency |
| vorLatitude_WGS84 | REAL | Navaid latitude |
| vorLongitude_WGS84 | REAL | Navaid longitude |
| vorElevation | INTEGER | Navaid elevation (feet MSL) |
| MagneticVariation | REAL | Local magnetic variation |
| dmeLatitude_WGS84 | REAL | Collocated DME latitude |
| dmeLongitude_WGS84 | REAL | Collocated DME longitude |

### NDB Navigation Aids
**Table:** `primary_D_B_base_Navaid - NDB Navaid`

Non-directional beacon navigation aids.

| Column | Type | Description |
|--------|------|-------------|
| ndbIdentifier | TEXT | NDB identifier |
| ndbName | TEXT | NDB name |
| ndbFrequency | REAL | Operating frequency |
| ndbLatitude_WGS84 | REAL | NDB latitude |
| ndbLongitude_WGS84 | REAL | NDB longitude |
| ndbElevation | INTEGER | NDB elevation (feet MSL) |
| MagneticVariation | REAL | Local magnetic variation |

### Enroute Waypoints
**Table:** `primary_E_A_base_Enroute - Grid Waypoints`

Enroute navigation fixes and waypoints.

| Column | Type | Description |
|--------|------|-------------|
| waypointIdentifier | TEXT | Waypoint identifier |
| waypointLatitude_WGS84 | REAL | Waypoint latitude |
| waypointLongitude_WGS84 | REAL | Waypoint longitude |
| WaypointType | TEXT | Type of waypoint |
| WaypointUsage | TEXT | Usage classification |
| WaypointIcaoRegionCode | TEXT | ICAO region |

### Airways and Routes
**Table:** `primary_E_R_base_Enroute - Airways and Routes`

Airway definitions and routing information.

| Column | Type | Description |
|--------|------|-------------|
| RouteIdentifier | TEXT | Airway identifier (e.g., "V123", "J45") |
| SequenceNumber | INTEGER | Sequence along airway |
| FixIdentifier | TEXT | Waypoint along airway |
| InboundMagneticCourse | INTEGER | Inbound magnetic course |
| OutboundMagneticCourse | INTEGER | Outbound magnetic course |
| RouteDistanceFrom | INTEGER | Distance from previous fix |
| MinimumEnrouteAltitude | INTEGER | MEA for this segment |
| MaximumAuthorizedAltitude | INTEGER | MAA for this segment |
| DirectionRestriction | TEXT | Direction restriction (F/B) |

### Holding Patterns
**Table:** `primary_E_P_base_Enroute - Holding Patterns`

Published holding pattern definitions.

| Column | Type | Description |
|--------|------|-------------|
| HoldingFixIdentifier | TEXT | Holding fix identifier |
| InboundHoldingCourse | INTEGER | Inbound course (magnetic) |
| TurnDirection | TEXT | Turn direction (L/R) |
| LegLength | REAL | Holding pattern leg length |
| LegTime | INTEGER | Holding pattern leg time |
| MinimumAltitude | INTEGER | Minimum holding altitude |
| MaximumAltitude | INTEGER | Maximum holding altitude |

### Controlled Airspace
**Table:** `primary_U_C_base_Airspace - Controlled Airspace`

Controlled airspace boundary definitions.

| Column | Type | Description |
|--------|------|-------------|
| AirspaceCenter | TEXT | Airspace center identifier |
| AirspaceClassification | TEXT | Airspace class (A, B, C, D, E) |
| AirspaceType | TEXT | Type of airspace |
| SequenceNumber | INTEGER | Boundary point sequence |
| Latitude_WGS84 | REAL | Boundary point latitude |
| Longitude_WGS84 | REAL | Boundary point longitude |
| ArcOriginLatitude_WGS84 | REAL | Arc center latitude |
| ArcOriginLongitude_WGS84 | REAL | Arc center longitude |
| ArcDistance | INTEGER | Arc radius (tenths of NM) |
| LowerLimit | TEXT | Lower altitude limit |
| UpperLimit | TEXT | Upper altitude limit |

### Restrictive Airspace
**Table:** `primary_U_R_base_Airspace - Restrictive Airspace`

Restricted, prohibited, and warning area definitions.

| Column | Type | Description |
|--------|------|-------------|
| RestrictiveAirspaceDesignation | TEXT | Area designation |
| RestrictiveType | TEXT | Type (R/P/W for Restricted/Prohibited/Warning) |
| RestrictiveAirspaceName | TEXT | Area name |
| SequenceNumber | INTEGER | Boundary point sequence |
| Latitude_WGS84 | REAL | Boundary point latitude |
| Longitude_WGS84 | REAL | Boundary point longitude |
| LowerLimit | TEXT | Lower altitude limit |
| UpperLimit | TEXT | Upper altitude limit |
| TimeCode | TEXT | Time of use code |

## Database Indexes

The following indexes are automatically created for optimal query performance:

### Primary Indexes
- VOR/DME identifier lookups
- NDB identifier lookups
- Airport identifier lookups
- Procedure identifier and airport associations
- Waypoint identifier lookups
- Geographic coordinate lookups (lat/lon pairs)

### Composite Indexes
- Airport + procedure combinations
- Fix + procedure associations
- Geographic bounding box queries

## Data Types and Encoding

### Coordinates
- All coordinates stored as REAL in decimal degrees (WGS84)
- Original ARINC424 coordinates preserved in separate columns
- Precision maintained to 0.0005 arc seconds where specified

### Altitudes
- Stored as INTEGER in feet MSL
- Flight levels stored as hundreds of feet (FL180 = 18000)

### Frequencies
- VHF stored as REAL in MHz (e.g., 118.1)
- NDB stored as REAL in kHz (e.g., 385.0)

### Courses and Bearings
- Stored as INTEGER in tenths of degrees (magnetic)
- True bearings indicated by separate field

### Identifiers
- All identifiers stored as TEXT
- ICAO codes stored uppercase
- Preserve original spacing and formatting

## Usage Notes

### Joining Tables
When joining procedure tables with fix/navaid tables, use:
1. Identifier matching
2. ICAO region code matching (where applicable)
3. Section/subsection code matching for disambiguation

### Coordinate Queries
Use WGS84 coordinate columns for:
- GIS integration
- Distance calculations
- Bounding box searches
- Mapping applications

### Performance Tips
1. Always use indexed columns in WHERE clauses
2. Use CAST for numeric comparisons on text fields
3. Consider using prepared statements for repeated queries
4. Use EXPLAIN QUERY PLAN to optimize complex queries

## Example Joins

### Get approach with waypoint coordinates:
```sql
SELECT p.*, w.waypointLatitude_WGS84, w.waypointLongitude_WGS84
FROM "primary_P_F_base_Airport - Approach Procedures" p
LEFT JOIN "primary_P_C_base_Airport - Terminal Waypoints" w
ON p.FixIdentifier = w.waypointIdentifier
AND p.LandingFacilityIcaoIdentifier = w.RegionCode
WHERE p.LandingFacilityIcaoIdentifier = 'KRIC';
```

### Get airway with enroute fixes:
```sql
SELECT a.*, w.waypointLatitude_WGS84, w.waypointLongitude_WGS84
FROM "primary_E_R_base_Enroute - Airways and Routes" a
LEFT JOIN "primary_E_A_base_Enroute - Grid Waypoints" w
ON a.FixIdentifier = w.waypointIdentifier
WHERE a.RouteIdentifier = 'V123'
ORDER BY CAST(a.SequenceNumber AS INTEGER);
```
Loading