The constraint
suitable to verify what you ask should be something like this:
CONSTRAINT check_Deuda CHECK ((Deudor = 1) or (Deudor = 0 and Deuda = 0))
For example:
create table Clientes (
Nombre varchar(50) not null,
Id_Cliente varchar(15) primary key,
Telefono varchar(15) not null unique,
Edad int not null,
Email varchar(50) not null unique,
Deudor bit not null default 0,
Deuda real not null default 0,
constraint CK_VALIDACION_EDAD check (Edad >= 18),
CONSTRAINT check_Deuda CHECK ((Deudor = 1) or (Deudor = 0 and Deuda = 0))
)
-- No deudor con Deuda -> Error
insert into Clientes (Nombre, Id_Cliente, Telefono, Edad, Email, Deudor, Deuda)
values ('cliente 1', 1, '', 19, '', 0, 100);
-- No deudor sin Deuda -> Ok
insert into Clientes (Nombre, Id_Cliente, Telefono, Edad, Email, Deudor, Deuda)
values ('cliente 2', 2, '', 19, '', 0, 0);
-- Deudor con Deuda -> Ok
insert into Clientes (Nombre, Id_Cliente, Telefono, Edad, Email, Deudor, Deuda)
values ('cliente 3', 3, '', 19, '', 1, 100);
-- Deudor sin Deuda -> Ok
insert into Clientes (Nombre, Id_Cliente, Telefono, Edad, Email, Deudor, Deuda)
values ('cliente 4', 4, '', 19, '', 0, 0);