0
I have three tables: Usuario
, Lembrete
and Lembrete_Usuario
on the Oracle. I am trying to create a Rigger that when I insert in the User table and Reminder, take the ids, User and Reminder, and put in the table User.
Tables:
create table Usuario(
idUsuario number(5),
nome varchar2(20) not null,
login varchar2(20) not null,
senha varchar2(10) not null,
email varchar2(50) not null,
constraint idUsuario_pk primary key(idUsuario)
);
create table Lembrete(
idLembrete number(5),
titulo varchar2(255),
hora number(5,2),
dataLemb date,
repetir number(5),
descricao varchar2(50),
constraint idLembrete_pk primary key(idLembrete)
);
create table Lembrete_Usuario(
idUsuario number(5),
idLembrete number(5),
log_usuario date,
constraint idUsuarioLembrete_fk foreign key(idUsuario) references Usuario(idUsuario),
constraint idLembreteUsuario_fk foreign key(idLembrete) references Lembrete(idLembrete)
);
Can someone help me?
Do you really need the 3 tables? The way you described, using a
trigger
, i don’t see a way to do this because how will you know which user id is related to the reminder id?– mateusalxd
Then this table "Lembrete_usuario" was created due to the fact of being many for many, between User and Reminder.
– Christian Gomes da Silva
I may be wrong, but I don’t think it’s possible to do it for
trigger
, you will need to control by the application.– mateusalxd
Okay, thanks for your attention!
– Christian Gomes da Silva