Do not create port[], primary_port[] and secondary_port[] tables: find them from the database.
Work out whether a tide is a high- or low-tide before creating the event, rather than afterwards.
Exported functions to erase and re-create the ports database.
Re-created the ports database, so it is now nice and small.