I try to create a couple of tables in MySQL, this is the sentence to create the first one:
----- Creamos la Tabla de Usuarios del Sistema
Create table if not exists USUARIO
(
ID_USUARIO BIGINT UNSIGNED not null auto_increment comment 'Id de la Tabla de Usuarios',
FICHA_LARGA varchar(10) not null comment 'Representa el numero del usuario',
FICHA_CORTA varchar(10) not null comment 'Representa el numero del usuario',
NOMBRE varchar(50) not null comment 'Nombre Completo del Usuario',
CORREO varchar(50) not null comment 'Correo de notificacion del usuario',
USUARIO_ACTIVO char(1) not null default 'Y' comment 'Bandera que indica si el usuario esta activo',
Primary Key(ID_USUARIO)
);
However, when trying to create the following table, I get the error:
(Error Code: 1215. Can not add foreign key constraint).
----- Creamos la Tabla con la Cabecera de Venta del Sistema
Create table if not exists CABECERA_VENTA
(
ID_CABECERA_VENTA Bigint UNSIGNED not null auto_increment comment 'Id de la Tabla de Cabecera de Ventas',
ID_USUARIO Bigint not null comment 'Id del Usuario que realiza la compra',
FECHA_CREADO Datetime not null default CURRENT_TIMESTAMP comment 'Fecha y Hora de Venta',
MONTO_TOTAL Decimal not null comment 'Monto Total de la Venta Realizada',
PROCESADA Char(1) not null default 'N' comment 'Bandera para indicar si la Venta ya fue procesada en un Corte',
FECHA_CORTE Date default null comment 'Fecha Corte en la que fue incorporada la Venta',
Primary Key(ID_CABECERA_VENTA),
Constraint ID_USUARIO
Foreign Key(ID_USUARIO)
References USUARIO(ID_USUARIO)
);
Thank you in advance for the help provided.