/*
 * This file is generated by jOOQ.
 */
package org.jooq.meta.duckdb.system.information_schema.tables;


import java.util.Arrays;
import java.util.List;

import org.jooq.Condition;
import org.jooq.Field;
import org.jooq.ForeignKey;
import org.jooq.InverseForeignKey;
import org.jooq.Name;
import org.jooq.Record;
import org.jooq.Schema;
import org.jooq.Table;
import org.jooq.TableField;
import org.jooq.TableOptions;
import org.jooq.impl.DSL;
import org.jooq.impl.SQLDataType;
import org.jooq.impl.TableImpl;
import org.jooq.meta.duckdb.system.information_schema.InformationSchema;
import org.jooq.meta.duckdb.system.information_schema.Keys;


/**
 * This class is generated by jOOQ.
 */
@SuppressWarnings({ "all", "unchecked", "rawtypes", "this-escape" })
public class ReferentialConstraints extends TableImpl<Record> {

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>system.information_schema.referential_constraints</code>
     */
    public static final ReferentialConstraints REFERENTIAL_CONSTRAINTS = new ReferentialConstraints();

    /**
     * The class holding records for this type
     */
    @Override
    public Class<Record> getRecordType() {
        return Record.class;
    }

    /**
     * The column
     * <code>system.information_schema.referential_constraints.constraint_catalog</code>.
     */
    public final TableField<Record, String> CONSTRAINT_CATALOG = createField(DSL.name("constraint_catalog"), SQLDataType.VARCHAR, this, "");

    /**
     * The column
     * <code>system.information_schema.referential_constraints.constraint_schema</code>.
     */
    public final TableField<Record, String> CONSTRAINT_SCHEMA = createField(DSL.name("constraint_schema"), SQLDataType.VARCHAR, this, "");

    /**
     * The column
     * <code>system.information_schema.referential_constraints.constraint_name</code>.
     */
    public final TableField<Record, String> CONSTRAINT_NAME = createField(DSL.name("constraint_name"), SQLDataType.VARCHAR, this, "");

    /**
     * The column
     * <code>system.information_schema.referential_constraints.unique_constraint_catalog</code>.
     */
    public final TableField<Record, String> UNIQUE_CONSTRAINT_CATALOG = createField(DSL.name("unique_constraint_catalog"), SQLDataType.VARCHAR, this, "");

    /**
     * The column
     * <code>system.information_schema.referential_constraints.unique_constraint_schema</code>.
     */
    public final TableField<Record, String> UNIQUE_CONSTRAINT_SCHEMA = createField(DSL.name("unique_constraint_schema"), SQLDataType.VARCHAR, this, "");

    /**
     * The column
     * <code>system.information_schema.referential_constraints.unique_constraint_name</code>.
     */
    public final TableField<Record, String> UNIQUE_CONSTRAINT_NAME = createField(DSL.name("unique_constraint_name"), SQLDataType.VARCHAR, this, "");

    /**
     * The column
     * <code>system.information_schema.referential_constraints.match_option</code>.
     */
    public final TableField<Record, String> MATCH_OPTION = createField(DSL.name("match_option"), SQLDataType.VARCHAR, this, "");

    /**
     * The column
     * <code>system.information_schema.referential_constraints.update_rule</code>.
     */
    public final TableField<Record, String> UPDATE_RULE = createField(DSL.name("update_rule"), SQLDataType.VARCHAR, this, "");

    /**
     * The column
     * <code>system.information_schema.referential_constraints.delete_rule</code>.
     */
    public final TableField<Record, String> DELETE_RULE = createField(DSL.name("delete_rule"), SQLDataType.VARCHAR, this, "");

    private ReferentialConstraints(Name alias, Table<Record> aliased) {
        this(alias, aliased, (Field<?>[]) null, null);
    }

    private ReferentialConstraints(Name alias, Table<Record> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view(), where);
    }

    /**
     * Create an aliased
     * <code>system.information_schema.referential_constraints</code> table
     * reference
     */
    public ReferentialConstraints(String alias) {
        this(DSL.name(alias), REFERENTIAL_CONSTRAINTS);
    }

    /**
     * Create an aliased
     * <code>system.information_schema.referential_constraints</code> table
     * reference
     */
    public ReferentialConstraints(Name alias) {
        this(alias, REFERENTIAL_CONSTRAINTS);
    }

    /**
     * Create a <code>system.information_schema.referential_constraints</code>
     * table reference
     */
    public ReferentialConstraints() {
        this(DSL.name("referential_constraints"), null);
    }

    public <O extends Record> ReferentialConstraints(Table<O> path, ForeignKey<O, Record> childPath, InverseForeignKey<O, Record> parentPath) {
        super(path, childPath, parentPath, REFERENTIAL_CONSTRAINTS);
    }

    @Override
    public Schema getSchema() {
        return aliased() ? null : InformationSchema.INFORMATION_SCHEMA;
    }

    @Override
    public List<ForeignKey<Record, ?>> getReferences() {
        return Arrays.asList(Keys.REFERENCED_CONSTRAINT, Keys.REFERENCING_CONSTRAINT, Keys.SYNTHETIC_FK_REFERENTIAL_CONSTRAINTS__SYNTHETIC_PK_SCHEMATA);
    }

    private transient TableConstraints _referencedConstraint;

    /**
     * Get the implicit join path to the
     * <code>system.information_schema.table_constraints</code> table, via the
     * <code>REFERENCED_CONSTRAINT</code> key.
     */
    public TableConstraints referencedConstraint() {
        if (_referencedConstraint == null)
            _referencedConstraint = new TableConstraints(this, Keys.REFERENCED_CONSTRAINT, null);

        return _referencedConstraint;
    }

    private transient TableConstraints _referencingConstraint;

    /**
     * Get the implicit join path to the
     * <code>system.information_schema.table_constraints</code> table, via the
     * <code>REFERENCING_CONSTRAINT</code> key.
     */
    public TableConstraints referencingConstraint() {
        if (_referencingConstraint == null)
            _referencingConstraint = new TableConstraints(this, Keys.REFERENCING_CONSTRAINT, null);

        return _referencingConstraint;
    }

    private transient Schemata _schemata;

    /**
     * Get the implicit join path to the
     * <code>system.information_schema.schemata</code> table.
     */
    public Schemata schemata() {
        if (_schemata == null)
            _schemata = new Schemata(this, Keys.SYNTHETIC_FK_REFERENTIAL_CONSTRAINTS__SYNTHETIC_PK_SCHEMATA, null);

        return _schemata;
    }

    @Override
    public ReferentialConstraints as(String alias) {
        return new ReferentialConstraints(DSL.name(alias), this);
    }

    @Override
    public ReferentialConstraints as(Name alias) {
        return new ReferentialConstraints(alias, this);
    }

    @Override
    public ReferentialConstraints as(Table<?> alias) {
        return new ReferentialConstraints(alias.getQualifiedName(), this);
    }
}
