title: ERROR 3780: Referencing column and referenced column in foreign key constraint are incompatible
body: <p>I created a schema in MySQL 8.0 named hr. I'm creating two tables: one is <strong>locations</strong> and the other one <strong>departments</strong>, which has a foreign key referencing the table <strong>locations</strong>.</p>
  <pre><code>create table hr.locations(
  location_id varchar(4) not null unique,
  street_address varchar(25) not null,
  country_id char(2) not null unique,
  primary key(location_id),
  foreign key(country_id) references countries(country_id)
  );
  
  create table hr.departments(
  department_id varchar(4) not null unique,
  department_name varchar(30) not null,
  manager_id varchar(9) not null unique,
  location_id varchar(4) not null unique,
  primary key(department_id),
  foreign key(location_id) references locations(location_id)
   );
  </code></pre>
  <p>When processing it this error appears:</p>
  <blockquote>
  <p>Error Code: 3780. Referencing column 'location_id' and referenced
  column 'location_id' in foreign key constraint 'departments_ibfk_1'
  are incompatible.</p>
  </blockquote>
  <p>Data type is the same for location_id in both tables. I can't find the mistake.</p>