def foreign_key_constraint_sql(table):
    """Return the SQL to add foreign key constraints to a given table"""
    sql = ''
    fk_names = list(table.foreign_keys.keys())
    for fk_name in sorted(fk_names):
        foreign_key = table.foreign_keys[fk_name]
        sql += "FOREIGN KEY({fn}) REFERENCES {tn}({kc}), ".format(
            fn=foreign_key.from_col,
            tn=foreign_key.to_table.name,
            kc=foreign_key.to_col
        )
    return sql