Error in creating foreign key fk_client in database

Asked

Viewed 22 times

0

Hello, when I was doing the client table relationship with sales table, at the time of finalizing, the system displayed an error message, so the relationship was not created the message is this: Error creating foreign key in fk_id_client(check data type), what I understand is that the error is in the types of data, I changed, but still the mistake not creating the relationship, the database tables are just below and then the primary key fields sales table and foreign key fk_client and also the primary key field client table What data should be changed in the tables? genteleza answer.

client table

NAME TYPE size/values Default grouping Attributes Null AI
pk_id_client int 11 none Name Type size values Default Grouping Attributes Null AI Name VARCHAR 300 no utf8_general_ci Name type size values Default Grouping Attributes Null AI address VARCHAR 300 no utf8_general_ci Attributes Null AI Name type size values Default Grouping Attributes Null AI district Varchar 300 no utf8_general_ci Name type size values Default Grouping Attributes Null AI city VARCHAR 200 no utf8_general_ci Name type size values Default Grouping Attributes Null AI Uf VARCHAR 2 utf8_general_ci Name type size values Default Grouping Attributes Null AI cep VARCHAR 9 no utf8_general_ci Name type size values Default Grouping Attributes Null AI telephone VARCHAR 15 no utf8_general_ci

SALES CHART

Name type tanho/values Default Grouping Attributes Null AI pk_id_sales int 11 none v Name type tanho/values Default Grouping Attributes Null AI fk_id_client int 11 no UNSIGNED Name type tanho/values Default Grouping Attributes Null AI VEN_DATA_VENDA DATE none Name type tanho/values Default Grouping Attributes Null AI ven_valor_liquido DOUBLE nenhum Name type tanho/values Default Grouping Attributes Null AI ven_valor_brute DOUBLE none Name type tanho/values Default Grouping Attributes Null AI DOUBLE DISCOUNT

PRIMARY KEY FIELD SALES TABLE

name type size/default values Grouping Null attributes AI
pk_id_sales int 11 none v

FOREIGN KEY FIELD FK_CLIENTE

name type size/default values Grouping Null attributes AI fk_id_client int 11 no UNSIGNED

PRIMARY KEY FIELD CLIENT TABLE

name Type size/default values Grouping Null attributes AI pk_id_client int 11 none v

  • hello welcome Antonio. Take a look at your question and try to format, see that it has a lot of information but is unreadable, difficult to help you :( click here to edit and try to get better

  • Your foreign key, apparently fk_id_cliente from the sales table, is with the attribute UNSIGNED. Everything indicates that it references the field pk_id_cliente of the client table that does not have such attribute.

  • thanks, brother, for correcting manage to make the relationship.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.