def tokenise_table_name(table_name):
    """Given a feature class or feature dataset name, returns the schema (optional) and simple name"""

    dot_count = table_name.count(".")

    if dot_count == 2:
        dot_pos = [pos for pos, char in enumerate(table_name) if char == "."]

        return {
            "database": table_name[:dot_pos[0]],
            "schema": table_name[dot_pos[0] + 1:dot_pos[1]],
            "name": table_name[dot_pos[1] + 1:]
        }
    elif dot_count == 1:
        return {
            "database": None,
            "schema": table_name[:table_name.index(".")],
            "name": table_name[table_name.index(".") + 1:]
        }
    else:
        return {"database": None, "schema": None, "name": table_name}