title: Can't create table "Foreign Key constraint is incorrectly formed" SQL
body: <p>I'm new into SQL and I'm having a little problem with my SQL code. I have been searching a lot about this kind of error but I couldn't find any answer that suits for my problem. Here's the code example.</p>
  
  <pre><code>CREATE DATABASE IF NOT EXISTS `PracticaER`;
  USE `PracticaER`;
  
  DROP TABLE IF EXISTS Banco;
  DROP TABLE IF EXISTS Cuenta;
  DROP TABLE IF EXISTS Usuario;
  
  CREATE TABLE Usuario (
  id_usuario INT NOT NULL AUTO_INCREMENT,
  nombre VARCHAR(10) NOT NULL,
  DNI VARCHAR(9) NOT NULL UNIQUE,
  usuario VARCHAR(10) NOT NULL,
  Contrasena VARCHAR(15) NOT NULL,
  PRIMARY KEY (id_usuario)
  );
  
  CREATE TABLE Cuenta (
  CIF_Banco VARCHAR(20) NOT NULL,
  num_cuenta INT NOT NULL,
  balance FLOAT NOT NULL DEFAULT 0.0,
  fecha_apertura VARCHAR(20) NOT NULL,
  DNI VARCHAR(9) NOT NULL,
  PRIMARY KEY (num_cuenta),
  FOREIGN KEY (DNI) REFERENCES Usuario(DNI)
  );
  
  CREATE TABLE Banco (
  CIF VARCHAR(20) NOT NULL,
  nombre VARCHAR(9) NOT NULL,
  cod_oficial INT NOT NULL,
  pais VARCHAR(15) NOT NULL,
  PRIMARY KEY (CIF),
  FOREIGN KEY (CIF) REFERENCES Cuenta(CIF_Banco)
  );
  </code></pre>
  
  <p>When I execute MySQL, this is the error. Basically it can't create the table "Banco".</p>
  
  <blockquote>
    <p>Error Code: 1005. Can't create table <code>practicaer</code>.<code>banco</code> (errno: 150
    "Foreign key constraint is incorrectly formed")</p>
  </blockquote>