def create_query_constraint(datasets: list, dir_file: str) -> str:
    """
    Write query to create constraints in Cypher and export as .cypher file.

    :param datasets: List of datasets/schema to create constraints from.
    :param dir_file: String of the directory to store Cypher query in.
    :return: String of the queries in the script exported.
    """
    aliases = [txt[0].lower() for txt in datasets]
    cypher = []
    for name, alias in zip(datasets, aliases):
        query_constraint = (
            f"CREATE CONSTRAINT table_name_Constraint{name} ON ({alias}:{name})\n"
            f"ASSERT {alias}.table_name IS UNIQUE;\n"
        )
        cypher.append(query_constraint)

    cypher = "".join(cypher)
    with open(file=f"{dir_file}/query_constraints.cypher", mode="w") as f:
        f.write(cypher)

    return cypher