Mariadb-Developer-Examples/Flights
Rob Hedgpeth cd2a6547fd
Update README.md
2019-12-16 15:44:46 -08:00
..
media Initial additions 2019-12-16 15:02:28 -08:00
src updates 2019-12-16 15:31:59 -08:00
README.md Update README.md 2019-12-16 15:44:46 -08:00

README.md

Flights

Flights is a web application written in ReactJS and NodeJS that, backed by the power of the MariaDB Node Connector and MariaDB ColumnStore database, allows you to analyze over 180 million flight records from the United States Department of Transportation in real time without needing to add any indexes

This README will walk you through the steps for getting this app up and running (locally) within minutes!

Table of Contents

  1. Getting started with MariaDB
    1. The Basics
    2. Downloadng and installing MariaDB ColumnStore
    3. Using the MariaDB columnar database
  2. Requirements
  3. Getting started with the app
    1. Grab the code
    2. Build the code
    3. Run the app
  4. Support and Contribution

Overview

Introduction to MariaDB

MariaDB platform unifies MariaDB TX (transactions) and MariaDB AX (analytics) so transactional applications can retain unlimited historical data and leverage powerful, real-time analytics in order to provide data-driven customers with more information, actionable insight and greater value – and businesses with endless ways to monetize data. It is the enterprise open source database for hybrid transactional/analytical processing at scale.

Downloadng and installing MariaDB ColumnStore

MariaDB ColumnStore extends MariaDB Server with distributed storage and massively parallel processing to support scalable, high-performance analytics. It can be deployed as the analytics component of MariaDB Platform using MariaDB MaxScale for change-data-capture and hybrid transactional/analytical query routing, or as a standalone columnar database for interactive, ad hoc analytics at scale. You can find more information on how to download and install ColumnStore here.

Using the MariaDB columnar database

MariaDB ColumnStore provides distributed, columnar storage for scalable analytical processing. MariaDB ColumnStore is a component of MariaDB Platform. The primary documentation is located in the MariaDB Public Knowledge Base.

This application uses three a tables (airlines, airports, flights) within a single MariaDB ColumnStore database.

CREATE TABLE `airlines` (
  `iata_code` char(2) DEFAULT NULL,
  `airline` varchar(30) DEFAULT NULL
) ENGINE=Columnstore DEFAULT CHARSET=utf8;
CREATE TABLE `airports` (
  `iata_code` char(3) DEFAULT NULL,
  `airport` varchar(80) DEFAULT NULL,
  `city` varchar(30) DEFAULT NULL,
  `state` char(2) DEFAULT NULL,
  `country` varchar(30) DEFAULT NULL,
  `latitude` float DEFAULT NULL,
  `longitude` float DEFAULT NULL
) ENGINE=Columnstore DEFAULT CHARSET=utf8;
CREATE TABLE `flights` (
  `year` smallint(6) DEFAULT NULL,
  `month` tinyint(4) DEFAULT NULL,
  `day` tinyint(4) DEFAULT NULL,
  `day_of_week` tinyint(4) DEFAULT NULL,
  `fl_date` date DEFAULT NULL,
  `carrier` char(2) DEFAULT NULL,
  `tail_num` char(6) DEFAULT NULL,
  `fl_num` smallint(6) DEFAULT NULL,
  `origin` varchar(5) DEFAULT NULL,
  `dest` varchar(5) DEFAULT NULL,
  `crs_dep_time` char(4) DEFAULT NULL,
  `dep_time` char(4) DEFAULT NULL,
  `dep_delay` smallint(6) DEFAULT NULL,
  `taxi_out` smallint(6) DEFAULT NULL,
  `wheels_off` char(4) DEFAULT NULL,
  `wheels_on` char(4) DEFAULT NULL,
  `taxi_in` smallint(6) DEFAULT NULL,
  `crs_arr_time` char(4) DEFAULT NULL,
  `arr_time` char(4) DEFAULT NULL,
  `arr_delay` smallint(6) DEFAULT NULL,
  `cancelled` smallint(6) DEFAULT NULL,
  `cancellation_code` smallint(6) DEFAULT NULL,
  `diverted` smallint(6) DEFAULT NULL,
  `crs_elapsed_time` smallint(6) DEFAULT NULL,
  `actual_elapsed_time` smallint(6) DEFAULT NULL,
  `air_time` smallint(6) DEFAULT NULL,
  `distance` smallint(6) DEFAULT NULL,
  `carrier_delay` smallint(6) DEFAULT NULL,
  `weather_delay` smallint(6) DEFAULT NULL,
  `nas_delay` smallint(6) DEFAULT NULL,
  `security_delay` smallint(6) DEFAULT NULL,
  `late_aircraft_delay` smallint(6) DEFAULT NULL
) ENGINE=Columnstore DEFAULT CHARSET=utf8;

For more information about MariaDB ColumnStore databases please check out the MariaDB blog!

Requirements

This project assumes you have familiarity with building web applications using ReactJS and NodeJS technologies.

  • Download and install MariaDB ColumnStore database.
  • Download and install NodeJS.
  • git (Optional) - this is required if you would prefer to pull the source code from GitHub repo.
    • Create a free github account if you dont already have one
    • git can be downloaded from git-scm.org

Getting started

In order to build and run the application you will need to have NodeJS installed. You can find more information here.

Create the schema and load the dataset

This application uses data from the United States Department of Transportation that is imported into a MariaDB ColumnStore database. For instructions on how to retrieve the dataset and import it into a MariaDB ColumnStore database please see the instructions here provided by Todd Stoffel.

Grab the code

Download this code directly or use git (through CLI or a client) to retrieve the code.

Configure the code

Update the MariaDB connection configuration here.

const pool = mariadb.createPool({
    host: '<host_address_here>', 
    user:'<username_here>', 
    password: '<password_here>',
    database: 'flights',
    multipleStatements: true,
    connectionLimit: 5
});

Build the code

Once you have retrieved a copy of the code you're ready to build and run the project! However, before running the code it's important to point out that the application uses several Node Packages.

For the client-side:

For the server-side:

Quick tip: You can also execute the CLI command npm install within the src and client folders. Doing so will target the the relative package.json files to install all dependencies.

Run the app

Once you've pulled down the code and have verified that all of the required Node packages are installed you're ready to run the application! It's as easy as 1,2,3.

  1. Using a command line interface (CLI) navigate to the src directory.

  1. Run the command:
npm start

  1. Open a browser window and navigate to http://localhost:3000.

Support and Contribution

Thanks so much for taking a look at the Flights app! As this is a very simple example, there's a lot of potential for customization!

If you have any questions, comments, or would like to contribute to this or future projects like this please reach out to us directly at developers@mariadb.com or on Twitter.