When loading data into the database, messages will be sorted into SQL tables determined by the message type and month. The names of these tables follow the following format, which {YYYYMM}
indicates the table year and month in the format YYYYMM.
Some additional tables containing computed data may be created depending on the indexes used. For example, an aggregate of vessel static data by month or a virtual table is used as a covering index.
Additional tables are also included for storing data not directly derived from AIS message reports.
For quick reference to data types and detailed explanations of these table entries, please see the Detailed Table Description.
In addition to querying the database using DBQuery
module, there is an option to customize the query with your own SQL code.
Example of listing all the tables in your database:
As messages are separated into tables by message type and month, queries spanning multiple message types or months should use UNIONs and JOINs to combine results as appropriate.
Example of querying tables with `JOIN`:
More information about SQL queries can be looked up from online tutorials.
The R* tree virtual tables should be queried for AIS position reports instead of the default tables. Query performance can be significantly improved using the R* tree index when restricting output to a narrow range of MMSIs, timestamps, longitudes, and latitudes. However, querying a wide range will not yield much benefit. If custom indexes are required for specific manual queries, these should be defined on message tables 1_2_3, 5, 18, and 24 directly instead of upon the virtual tables.
Timestamps are stored as epoch minutes in the database. To facilitate querying the database manually, use the dt_2_epoch()
function to convert datetime values to epoch minutes and the epoch_2_dt()
function to convert epoch minutes back to datetime values. Here is how you can use dt_2_epoch()
with the example above:
For more examples, please see the SQL code in aisdb_sql/
that is used to create database tables and associated queries.
ais_{YYYYMM}_dynamic
tablesais_{YYYYMM}_static
tablesstatic_{YYYYMM}_aggregate
tablesColumn | Data Type | Description |
---|---|---|
Column | Data Type | Description |
---|---|---|
Column | Data Type | Description |
---|---|---|
mmsi
INTEGER
Maritime Mobile Service Identity, a unique identifier for vessels.
time
INTEGER
Timestamp of the AIS message, in epoch seconds.
longitude
REAL
Longitude of the vessel in decimal degrees.
latitude
REAL
Latitude of the vessel in decimal degrees.
rot
REAL
Rate of turn, indicating how fast the vessel is turning.
sog
REAL
Speed over ground, in knots.
cog
REAL
Course over ground, in degrees.
heading
REAL
Heading of the vessel, in degrees.
maneuver
BOOLEAN
Indicator for whether the vessel is performing a special maneuver.
utc_second
INTEGER
Second of the UTC timestamp when the message was generated.
source
TEXT
Source of the AIS data.
mmsi
INTEGER
Maritime Mobile Service Identity, a unique identifier for vessels.
time
INTEGER
Timestamp of the AIS message, in epoch seconds.
vessel_name
TEXT
Name of the vessel.
ship_type
INTEGER
Numeric code representing the type of ship.
call_sign
TEXT
International radio call sign of the vessel.
imo
INTEGER
International Maritime Organization number, another unique vessel identifier.
dim_bow
INTEGER
Distance from the AIS transmitter to the bow (front) of the vessel.
dim_stern
INTEGER
Distance from the AIS transmitter to the stern (back) of the vessel.
dim_port
INTEGER
Distance from the AIS transmitter to the port (left) side of the vessel.
dim_star
INTEGER
Distance from the AIS transmitter to the starboard (right) side of the vessel.
draught
REAL
Maximum depth of the vessel's hull below the waterline, in meters.
destination
TEXT
Destination port or location where the vessel is heading.
ais_version
INTEGER
AIS protocol version used by the vessel.
fixing_device
TEXT
Type of device used for fixing the vessel's position (e.g., GPS).
eta_month
INTEGER
Estimated time of arrival month.
eta_day
INTEGER
Estimated time of arrival day.
eta_hour
INTEGER
Estimated time of arrival hour.
eta_minute
INTEGER
Estimated time of arrival minute.
source
TEXT
Source of the AIS data (e.g., specific AIS receiver or data provider).
mmsi
INTEGER
Maritime Mobile Service Identity, a unique identifier for vessels.
imo
INTEGER
International Maritime Organization number, another unique vessel identifier.
vessel_name
TEXT
Name of the vessel.
ship_type
INTEGER
Numeric code representing the type of ship.
call_sign
TEXT
International radio call sign of the vessel.
dim_bow
INTEGER
Distance from the AIS transmitter to the bow (front) of the vessel.
dim_stern
INTEGER
Distance from the AIS transmitter to the stern (back) of the vessel.
dim_port
INTEGER
Distance from the AIS transmitter to the port (left) side of the vessel.
dim_star
INTEGER
Distance from the AIS transmitter to the starboard (right) side of the vessel.
draught
REAL
Maximum depth of the vessel's hull below the waterline, in meters.
destination
TEXT
Destination port or location where the vessel is heading.
eta_month
INTEGER
Estimated time of arrival month.
eta_day
INTEGER
Estimated time of arrival day.
eta_hour
INTEGER
Estimated time of arrival hour.
eta_minute
INTEGER
Estimated time of arrival minute.