You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to FINAL_GDD
Gente alguno hizo este ejercicio?
Dado el siguiente modelo.
T1
ID Primary Key
Detalle
T2
ID Primary Key
ID_T1
Detalle
3.a) Agregar el/los objetos de base de datos necesarios para
establecer la integridad referencial entre las tablas T1 y T2. La
integridad rige a partir del momento en que se crea el código.
(No puede alterar la estructura de las tablas ni utilizar FK
constraints)
Se que piden hacer un trigger pero alguien sabe como hacerlo?
Saludos
Rodrigo Fernandez
unread,
Feb 13, 2011, 3:28:12 PM2/13/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to fina...@googlegroups.com
Hola yo lo hice asi:
CREATE TRIGGER InsertInT2
ON T2
FOR INSERT
AS
IF
NOT EXISTS (SELECT ‘True’ FROM inserted I JOIN T1 AS t ON i.id_t1 = t.id)
BEGIN
RAISERROR(
‘ID de T1 inexistente’, 16, 1)
ROLLBACK
TRAN
END
GO
Fijate de acomodarlo para que lo puedas probar, la verdad no se si esta es la mejor forma pero asi me funciono.