index.js
function ( config, tables, context, callback )
    {
        var self    = this,
            db      = Array(),
            counter = 0;

        db[ 0 ] = Array();
        db[ 1 ] = Array();
        var len = ( tables.tables[ 0 ].length > tables.tables[ 1 ].length ) ?
            tables.tables[ 0 ].length : tables.tables[ 1 ].length;

        var query = [
                'SELECT const.CONSTRAINT_NAME, const.CONSTRAINT_SCHEMA,const.TABLE_NAME,',
                'const.REFERENCED_TABLE_NAME,const.UPDATE_RULE,const.DELETE_RULE,',
                'const_keys.COLUMN_NAME,const_keys.POSITION_IN_UNIQUE_CONSTRAINT,',
                'const_keys.REFERENCED_COLUMN_NAME,const_keys.REFERENCED_TABLE_SCHEMA',
                'FROM information_schema.REFERENTIAL_CONSTRAINTS const',
                'INNER JOIN information_schema.KEY_COLUMN_USAGE const_keys ON ( ',
                'const_keys.CONSTRAINT_SCHEMA = const.CONSTRAINT_SCHEMA',
                'AND const_keys.CONSTRAINT_NAME = const.CONSTRAINT_NAME )',
                'WHERE const.CONSTRAINT_SCHEMA = ?',
                'AND const.TABLE_NAME = ?;'
            ]
            .join( ' ' );

        for ( var i = 0; i < len; ++i )
        {
            var q = '',
                params = Array(),
                stmt = 0;


            if ( tables.tables[ 0 ][ i ] )
            {
                q = query;
                params.push( config.database );
                params.push( tables.tables[ 0 ][ i ] );
            }
            else ++stmt;

            if ( tables.tables[ 1 ][ i ] )
            {
                q += query;
                params.push( config.database_diff );
                params.push( tables.tables[ 1 ][ i ] );
            }

            //scoping stmt and interator to event
            ( function ( stmt, i )
            {
                self.runSql( q, params, { useArray: true } )
                    .on( 'result', function ( res )
                    {
                        var local = stmt++;
                        res.on( 'data', function ( row )
                        {
                            constraint = Array();

                            if ( !db[ local ][ tables.tables[ local ][ i ] ] )
                                db[ local ][ tables.tables[ local ][ i ] ] = Array();

                            constraint[ 0 ] = row[ 0 ]; //constraint_name
                            constraint[ 1 ] = row[ 6 ]; //column_name
                            constraint[ 2 ] = row[ 9 ]; //referenced_table_schema
                            constraint[ 3 ] = row[ 3 ]; //referenced_table_name
                            constraint[ 4 ] = row[ 8 ]; //referenced_column_name
                            constraint[ 5 ] = row[ 7 ]; //position_in_unique_constraint
                            constraint[ 6 ] = row[ 4 ]; //on_update
                            constraint[ 7 ] = row[ 5 ]; //on_delete

                            db[ local ][ tables.tables[ local ][ i ] ].push( constraint );
                        } );
                    } )
                    .on( 'end', function ()
                    {
                        if ( ++counter >= len )
                            callback( context, db );
                    } );
            } )( stmt, i );
        }
    }
function ( config, tables, context, callback )
    {
        var self    = this,
            db      = Array(),
            counter = 0;

        db[ 0 ] = Array();
        db[ 1 ] = Array();
        var len = ( tables.tables[ 0 ].length > tables.tables[ 1 ].length ) ?
            tables.tables[ 0 ].length : tables.tables[ 1 ].length;

        var query = [
                'SELECT const.CONSTRAINT_NAME, const.CONSTRAINT_SCHEMA,const.TABLE_NAME,',
                'const.REFERENCED_TABLE_NAME,const.UPDATE_RULE,const.DELETE_RULE,',
                'const_keys.COLUMN_NAME,const_keys.POSITION_IN_UNIQUE_CONSTRAINT,',
                'const_keys.REFERENCED_COLUMN_NAME,const_keys.REFERENCED_TABLE_SCHEMA',
                'FROM information_schema.REFERENTIAL_CONSTRAINTS const',
                'INNER JOIN information_schema.KEY_COLUMN_USAGE const_keys ON ( ',
                'const_keys.CONSTRAINT_SCHEMA = const.CONSTRAINT_SCHEMA',
                'AND const_keys.CONSTRAINT_NAME = const.CONSTRAINT_NAME )',
                'WHERE const.CONSTRAINT_SCHEMA = ?',
                'AND const.TABLE_NAME = ?;'
            ]
            .join( ' ' );

        for ( var i = 0; i < len; ++i )
        {
            var q = '',
                params = Array(),
                stmt = 0;


            if ( tables.tables[ 0 ][ i ] )
            {
                q = query;
                params.push( config.database );
                params.push( tables.tables[ 0 ][ i ] );
            }
            else ++stmt;

            if ( tables.tables[ 1 ][ i ] )
            {
                q += query;
                params.push( config.database_diff );
                params.push( tables.tables[ 1 ][ i ] );
            }

            //scoping stmt and interator to event
            ( function ( stmt, i )
            {
                self.runSql( q, params, { useArray: true } )
                    .on( 'result', function ( res )
                    {
                        var local = stmt++;
                        res.on( 'data', function ( row )
                        {
                            constraint = Array();

                            if ( !db[ local ][ tables.tables[ local ][ i ] ] )
                                db[ local ][ tables.tables[ local ][ i ] ] = Array();

                            constraint[ 0 ] = row[ 0 ]; //constraint_name
                            constraint[ 1 ] = row[ 6 ]; //column_name
                            constraint[ 2 ] = row[ 9 ]; //referenced_table_schema
                            constraint[ 3 ] = row[ 3 ]; //referenced_table_name
                            constraint[ 4 ] = row[ 8 ]; //referenced_column_name
                            constraint[ 5 ] = row[ 7 ]; //position_in_unique_constraint
                            constraint[ 6 ] = row[ 4 ]; //on_update
                            constraint[ 7 ] = row[ 5 ]; //on_delete

                            db[ local ][ tables.tables[ local ][ i ] ].push( constraint );
                        } );
                    } )
                    .on( 'end', function ()
                    {
                        if ( ++counter >= len )
                            callback( context, db );
                    } );
            } )( stmt, i );
        }
    }
function ( config , tables , context , callback ) { var self = this , db = Array ( ) , counter = 0 ; db [ 0 ] = Array ( ) ; db [ 1 ] = Array ( ) ; var len = ( tables . tables [ 0 ] . length > tables . tables [ 1 ] . length ) ? tables . tables [ 0 ] . length : tables . tables [ 1 ] . length ; var query = [ 'SELECT const.CONSTRAINT_NAME, const.CONSTRAINT_SCHEMA,const.TABLE_NAME,' , 'const.REFERENCED_TABLE_NAME,const.UPDATE_RULE,const.DELETE_RULE,' , 'const_keys.COLUMN_NAME,const_keys.POSITION_IN_UNIQUE_CONSTRAINT,' , 'const_keys.REFERENCED_COLUMN_NAME,const_keys.REFERENCED_TABLE_SCHEMA' , 'FROM information_schema.REFERENTIAL_CONSTRAINTS const' , 'INNER JOIN information_schema.KEY_COLUMN_USAGE const_keys ON ( ' , 'const_keys.CONSTRAINT_SCHEMA = const.CONSTRAINT_SCHEMA' , 'AND const_keys.CONSTRAINT_NAME = const.CONSTRAINT_NAME )' , 'WHERE const.CONSTRAINT_SCHEMA = ?' , 'AND const.TABLE_NAME = ?;' ] . join ( ' ' ) ; for ( var i = 0 ; i < len ; ++ i ) { var q = '' , params = Array ( ) , stmt = 0 ; if ( tables . tables [ 0 ] [ i ] ) { q = query ; params . push ( config . database ) ; params . push ( tables . tables [ 0 ] [ i ] ) ; } else ++ stmt ; if ( tables . tables [ 1 ] [ i ] ) { q += query ; params . push ( config . database_diff ) ; params . push ( tables . tables [ 1 ] [ i ] ) ; } //scoping stmt and interator to event ( function ( stmt , i ) { self . runSql ( q , params , { useArray : true } ) . on ( 'result' , function ( res ) { var local = stmt ++ ; res . on ( 'data' , function ( row ) { constraint = Array ( ) ; if ( ! db [ local ] [ tables . tables [ local ] [ i ] ] ) db [ local ] [ tables . tables [ local ] [ i ] ] = Array ( ) ; constraint [ 0 ] = row [ 0 ] ; //constraint_name constraint [ 1 ] = row [ 6 ] ; //column_name constraint [ 2 ] = row [ 9 ] ; //referenced_table_schema constraint [ 3 ] = row [ 3 ] ; //referenced_table_name constraint [ 4 ] = row [ 8 ] ; //referenced_column_name constraint [ 5 ] = row [ 7 ] ; //position_in_unique_constraint constraint [ 6 ] = row [ 4 ] ; //on_update constraint [ 7 ] = row [ 5 ] ; //on_delete db [ local ] [ tables . tables [ local ] [ i ] ] . push ( constraint ) ; } ) ; } ) . on ( 'end' , function ( ) { if ( ++ counter >= len ) callback ( context , db ) ; } ) ; } ) ( stmt , i ) ; } }
Returns an array containing the foreign keys.

General return information:

This array has 3 layers, the final information layer has
8 elements.

Array Format:
Layer 1:
[0] = real table, [1] = diff table

Layer 2:
['tablename'] = Array for final table indizies information

Layer 3 (Result formatting):
[0] = foreign_key_name, [1] = column_name, [2] = referenced_table_schema,
[3] = referenced_table_name, [4] = referenced_column_name,
[5] = position_in_unique_constraint, [6] = on_update,
[7] = on_delete

@return array
Returns an array containing the foreign keys .