can anyone help me with this error? When I try to do an insert in the "attendances" table I get that my foreign key does not have a default value, but shouldn't it be automatic? I leave my code, thanks!
USE dbfinal3;
CREATE TABLE alumnos (
dni int(20) NOT NULL UNIQUE primary key,
apellido varchar(15) NOT NULL,
nombre varchar(20) NOT NULL,
direccion varchar(25) NOT NULL,
curso int(2) NOT NULL,
division varchar(5) NOT NULL,
estado varchar(35) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE asistencias (
idAsistencia int NOT NULL auto_increment primary key,
dniAlumnos int NOT NULL,
fecha date NOT NULL,
constraint fk_dniAlumnos foreign key (dniAlumnos) references alumnos(dni)
ON UPDATE CASCADE
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
I also leave the inserts that I have been testing!
insert into `alumnos` (dni,apellido,nombre,direccion,curso,division,estado) values
(40441958,'Perez','Javier','Martelli 234','3','A','Regular');
insert into `alumnos` (dni,apellido,nombre,direccion,curso,division,estado) values
(50987187,'Martinez','Juan','Belgrano 534','2','B','Irregular');
insert into `asistencias` (fecha) values
('1998-10-19')