def get_tables_name_and_role(cursor):
    """
    Return all the table names and table role

    Args:
        cursor: the DB cursor

    Returns:
        a list of (table name, table role)
    """
    sql_command = f"SELECT name FROM sqlite_master WHERE type='table';"
    names = cursor.execute(sql_command).fetchall()

    name_roles = []
    for name in names:
        assert len(name) == 1, f'got={name}'
        name = name[0]
        if '_metadata' in name:
            continue

        name_metadata = name + '_metadata'
        sql_command = f"SELECT table_role FROM '{name_metadata}';"
        v = cursor.execute(sql_command).fetchall()
        assert len(v) == 1, f'got={v}, name={name}'
        name_roles.append((name, v[0][0]))

    return name_roles