I am creating a relation between tables which is necessary to auto increment two columns id_quotation
and seq_quotation
. The column id_quotation
, I am referencing into another table (tb_core_process_id_quotation) where I already increment it.
This table below (tb_core_process_customer_data) will be used by other tables to catch commons and main customers data. To make it is necessary this three validation keys: cpf_cnpj
, id_quotation
and seq_quotation
that are common to entire tables in this database.
tb_core_process_customer_data query:
CREATE TABLE tb_core_process_customer_data(
cpf_cnpj VARCHAR(255) NOT NULL,
id_quotation INT NOT NULL,
seq_quotation INT NOT NULL AUTO_INCREMENT,
name VARCHAR(255),
dt_birth DATE,
cd_insurance_type INT,
PRIMARY KEY (cpf_cnpj, seq_quotation, id_quotation),
FOREIGN KEY (cd_insurance_type) REFERENCES tb_nm_insurance_type(cd_insurance_type),
FOREIGN KEY (id_quotation) REFERENCES tb_core_process_id_quotation(id_quotation)
);
tb_core_process_id_quotation query:
CREATE TABLE tb_core_process_id_quotation(
id_quotation INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id_quotation)
);
So, I am having difficult to relation this three keys and to make this validation. When I try to create tb_core_process_customer_data the follow message shows me off:
ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key