Mariadb-Developer-Examples/flights
..
data
media
src
README.md

README.md

Flights

Flights is a web application written in React.js and Node.js that, backed by the power of the MariaDB Node.js 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!

The following will walk you through the steps for getting this application up and running (locally) within minutes! This application is completely open source. Please feel free to use it and the source code as you see fit.

Table of Contents

  1. Environment and Compatibility
  2. Getting started with MariaDB
    1. The Basics
    2. Downloading and installing MariaDB ColumnStore
  3. Requirements
  4. Getting started with the app
    1. Get the data, create the schema, and load the data
    2. Grab the code
    3. Build the code
    4. Run the app
  5. Support and Contribution
  6. License

Environment and Compatibility

This sample was created using the following techologies:

This application was tested on macOS Mojave v.10.14.6.

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.

Downloading 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.

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

Get the data, create the schema, and load the data

Instructions on retrieving and importing the flights dataset into a MariaDB ColumnStore database can be here. Please note that he scripts provided within that repository only targets data for the year 2019 (~7.5 million records).

If you'd like to retrieve data spanning from 1990 to 2019 (~180 million records) please use the following scripts:

Grab the code

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

Configure the code

Configure the MariaDB connection by adding an .env file to the Node.js project.

Example implementation:

DB_HOST=<host_address>
DB_PORT=<port_number>
DB_USER=<username>
DB_PASS=<password>
DB_NAME=<database>

The environmental variables from .env are used within the db.js for the MariaDB Node.js Connector configuration pool settings:

var mariadb = require('mariadb');
require('dotenv').config();

const pool = mariadb.createPool({
    host: process.env.DB_HOST, 
    user: process.env.DB_USER, 
    password: process.env.DB_PASS,
    port: process.env.DB_PORT,
    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.

Executing the CLI command

npm install

within

  • src: the Node.js project
  • client: the React.js project

folders will target the the relative package.json file and 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.

License

License