Good morning classmates I need to know how I can identify when the first record of a relationship is created, I have 2 related tables the main table has idclase primary key and the second table with its foreign key idclase and primary key id test I have a class called sciences that was created on 04/12/2017 and the first program of that class was created on 05/15/2017 that date has to be automatically put in the first column of the science class
create table clase(
idclase int identity primary key,
clase varchar(10),
fechaclase datetime ,
primerprograma datetime
)
create table programa(
idclase int ,
idprograma int identity primary key,
programa varchar(20),
fechaprograma datetime,
)
alter table programa add constraint idclase
foreign key(idclase) references clase(idclase)
go
IDCLASE IDPROGRAMA CLASE PROGRAMA FECHACLASE FECHAPROGRAMA PRIMERPROGRAMA
1 CIENCIAS 12/04/2017 ***15/05/2017***
2 TECNOLOGIA 22/04/17
3 ARTES 26/07/17 ***25/04/2017***
1 1 CIENCIAS QUMICA ***15/05/2017***
3 2 ARTES ARTESNIAS ***25/04/2017***
What I do is a trigger to save a type history so that at the end all that information is saved in another table called movements dates