--Crear Tabla pro-actividades

if not exists(select * FROM INFORMATION_SCHEMA.TABLES  where Table_Name='pro_actividad')
BEGIN
EXEC _ini_creartabla 'pro_actividad', 1
END


--Crear Tabla intermedia actividad con recurso fisico

if not exists(select * FROM INFORMATION_SCHEMA.TABLES  where Table_Name='pro_actividad_recursoFisico')
BEGIN
EXEC _ini_creartabla 'pro_actividad_recursoFisico', 1
END
--Crear Tabla intermedia actividad con ejecutores

if not exists(select * FROM INFORMATION_SCHEMA.TABLES  where Table_Name='pro_actividad_ejecutor')
BEGIN
EXEC _ini_creartabla 'pro_actividad_ejecutor', 1
END
--CREAR TABLA INTERMEDIA ACTIVIDADES CON ETAPA

if not exists(select * FROM INFORMATION_SCHEMA.TABLES  where Table_Name='pro_actividad_etapa')
BEGIN
EXEC _ini_creartabla 'pro_actividad_etapa', 1
END

--Crear Tabla intermedia actividades con hito

if not exists(select * FROM INFORMATION_SCHEMA.TABLES  where Table_Name='pro_actividad_hito')
BEGIN
EXEC _ini_creartabla 'pro_actividad_hito', 1
END        



-----------------------------------CREACION COLIUMNAS---------------

if exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='pro_actividad' and column_name = 'descripcionDetallada' )
begin
declare @constraint as varchar(3000)
declare @comando as varchar(3000)

SELECT @constraint =name FROM dbo.sysobjects WHERE  parent_obj = OBJECT_ID('pro_actividad') AND type = 'D' and name like 'DF__pro_activ__descr__%'
set @comando='ALTER TABLE [dbo].[pro_actividad] DROP CONSTRAINT ' +@constraint 
exec(@comando)
alter table [pro_actividad] drop column [descripcionDetallada] 
END



if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='pro_actividad' and column_name = 'descripcionDetallada' )
begin
alter table [pro_actividad] add [descripcionDetallada] varchar (8000)not NULL DEFAULT 0
end
if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='pro_actividad' and column_name = 'fechaInicioPlaneada' )
begin
alter table [pro_actividad] add [fechainicioPlaneada] smalldatetime not NULL DEFAULT 01/01/1900
end
if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='pro_actividad' and column_name = 'fechaInicioProyectada' )
begin
alter table [pro_actividad] add [fechainicioProyectada] smalldatetime not NULL DEFAULT 01/01/1900
end
if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='pro_actividad' and column_name = 'fechaInicioReal' )
begin
alter table [pro_actividad] add [fechaInicioReal] smalldatetime not NULL DEFAULT 01/01/1900
end
if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='pro_actividad' and column_name = 'duracion' )
begin
alter table [pro_actividad] add [duracion] varchar (100) not NULL DEFAULT 0
end


if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='pro_actividad' and column_name = 'fechaTerminacionPlaneada' )
begin
alter table [pro_actividad] add [fechaTerminacionPlaneada] smalldatetime not NULL DEFAULT 01/01/1900
end
if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='pro_actividad' and column_name = 'fechaTerminacionProyectada' )
begin
alter table [pro_actividad] add [fechaTerminacionProyectada] smalldatetime not NULL DEFAULT 01/01/1900
end
if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='pro_actividad' and column_name = 'fechaTerminacionReal' )
begin
alter table [pro_actividad] add [fechaTerminacionReal] smalldatetime not NULL DEFAULT 01/01/1900
end



-----------------------------------------------------------------------------------
if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='pro_actividad_recursoFisico' and column_name = 'duracion' )
begin
alter table [pro_actividad_recursoFisico] add [duracion] varchar (100)not NULL DEFAULT 0
end

if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='pro_actividad_recursoFisico' and column_name = 'cantidad' )
begin
alter table [pro_actividad_recursoFisico] add [cantidad] int not NULL DEFAULT 0
end
if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='pro_actividad_recursoFisico' and column_name = 'id_recursoFisico' )
begin
alter table [pro_actividad_recursoFisico] add [id_recursoFisico] int not NULL DEFAULT 0
end
if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='pro_actividad_recursoFisico' and column_name = 'id_actividad' )
begin
alter table [pro_actividad_recursoFisico] add [id_actividad] int not NULL DEFAULT 0
end

--------------------------------------------------------------------------------------------
if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='pro_actividad_ejecutor' and column_name = 'id_ejecutores' )
begin
alter table [pro_actividad_ejecutor] add [id_ejecutores] int not NULL DEFAULT 0
end
if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='pro_actividad_ejecutor' and column_name = 'id_actividad' )
begin
alter table [pro_actividad_ejecutor] add [id_actividad] int not NULL DEFAULT 0
end
-------------------------------------------------------------------------------------------------------

if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='pro_actividad_hito' and column_name = 'id_hito' )
begin
alter table [pro_actividad_hito] add [id_hito] int not NULL DEFAULT 0
end
if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='pro_actividad_hito' and column_name = 'id_actividad' )
begin
alter table [pro_actividad_hito] add [id_actividad] int not NULL DEFAULT 0
end
-----------------------------------------------------------------------------------------------------------------------------------
if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='pro_actividad_etapa' and column_name = 'id_etapa' )
begin
alter table [pro_actividad_etapa] add [id_etapa] int not NULL DEFAULT 0
end
if not exists(select * FROM INFORMATION_SCHEMA.COLUMNS  where Table_Name='pro_actividad_etapa' and column_name = 'id_actividad' )
begin
alter table [pro_actividad_etapa] add [id_actividad] int not NULL DEFAULT 0
end
----------------------------------------INSERCION COLUMNAS------------------------------------------

IF NOT EXISTS(SELECT *FROM [_columnas] WHERE[tabla]='pro_actividad'
      AND [columna]='descripcionDetallada' AND[mostrarEnGrilla]=1 AND[ordenGrilla]=5AND[requerido]=1 AND [tipo]='varchar' AND[defecto]=0 AND [tamano] =100)
BEGIN
INSERT INTO [_columnas]
([tabla] ,[columna] ,[mostrarEnGrilla],[ordenGrilla],[requerido] ,[tipo],[defecto],[tamano])
 VALUES
 ('pro_actividad' ,'descripcionDetallada',1 ,5 ,1 ,'varchar' ,0 ,100)
END

IF NOT EXISTS(SELECT *FROM [_columnas] WHERE[tabla]='pro_actividad'
      AND [columna]='fechaInicioPlaneada' AND[mostrarEnGrilla]=1 AND[ordenGrilla]=5AND[requerido]=1 AND [tipo]='smalldatetime' AND[defecto]=0 AND [tamano] =100)
BEGIN
INSERT INTO [_columnas]
([tabla] ,[columna] ,[mostrarEnGrilla],[ordenGrilla],[requerido] ,[tipo],[defecto],[tamano])
 VALUES
 ('pro_actividad' ,'fechaInicioPlaneada',1 ,5 ,1 ,'smalldatetime' ,0 ,100)
END
IF NOT EXISTS(SELECT *FROM [_columnas] WHERE[tabla]='pro_actividad'
      AND [columna]='fechaInicioProyectada' AND[mostrarEnGrilla]=1 AND[ordenGrilla]=5AND[requerido]=1 AND [tipo]='smalldatetime' AND[defecto]=0 AND [tamano] =100)
BEGIN
INSERT INTO [_columnas]
([tabla] ,[columna] ,[mostrarEnGrilla],[ordenGrilla],[requerido] ,[tipo],[defecto],[tamano])
 VALUES
 ('pro_actividad' ,'fechaInicioProyectada',1 ,5 ,1 ,'smalldatetime' ,0 ,100)
END
IF NOT EXISTS(SELECT *FROM [_columnas] WHERE[tabla]='pro_actividad'
      AND [columna]='fechaInicioReal' AND[mostrarEnGrilla]=1 AND[ordenGrilla]=5AND[requerido]=1 AND [tipo]='smalldatetime' AND[defecto]=0 AND [tamano] =100)
BEGIN
INSERT INTO [_columnas]
([tabla] ,[columna] ,[mostrarEnGrilla],[ordenGrilla],[requerido] ,[tipo],[defecto],[tamano])
 VALUES
 ('pro_actividad' ,'fechaInicioReal',1 ,5 ,1 ,'smalldatetime' ,0 ,100)
END

IF NOT EXISTS(SELECT *FROM [_columnas] WHERE[tabla]='pro_actividad'
      AND [columna]='duracion' AND[mostrarEnGrilla]=1 AND[ordenGrilla]=5AND[requerido]=1 AND [tipo]='varchar' AND[defecto]=0 AND [tamano] =100)
BEGIN
INSERT INTO [_columnas]
([tabla] ,[columna] ,[mostrarEnGrilla],[ordenGrilla],[requerido] ,[tipo],[defecto],[tamano])
 VALUES
 ('pro_actividad' ,'duracion',1 ,5 ,1 ,'varchar' ,0 ,100)
END

IF NOT EXISTS(SELECT *FROM [_columnas] WHERE[tabla]='pro_actividad'
      AND [columna]='fechaTerminacionPlaneada' AND[mostrarEnGrilla]=1 AND[ordenGrilla]=5AND[requerido]=1 AND [tipo]='smalldatetime' AND[defecto]=0 AND [tamano] =100)
BEGIN
INSERT INTO [_columnas]
([tabla] ,[columna] ,[mostrarEnGrilla],[ordenGrilla],[requerido] ,[tipo],[defecto],[tamano])
 VALUES
 ('pro_actividad' ,'fechaTerminacionPlaneada',1 ,5 ,1 ,'smalldatetime' ,0 ,100)
END

IF NOT EXISTS(SELECT *FROM [_columnas] WHERE[tabla]='pro_actividad'
      AND [columna]='fechaTerminacionProyectada' AND[mostrarEnGrilla]=1 AND[ordenGrilla]=5AND[requerido]=1 AND [tipo]='smalldatetime' AND[defecto]=0 AND [tamano] =100)
BEGIN
INSERT INTO [_columnas]
([tabla] ,[columna] ,[mostrarEnGrilla],[ordenGrilla],[requerido] ,[tipo],[defecto],[tamano])
 VALUES
 ('pro_actividad' ,'fechaTerminacionProyectada',1 ,5 ,1 ,'smalldatetime' ,0 ,100)
END

IF NOT EXISTS(SELECT *FROM [_columnas] WHERE[tabla]='pro_actividad'
      AND [columna]='fechaTerminacionReal' AND[mostrarEnGrilla]=1 AND[ordenGrilla]=5AND[requerido]=1 AND [tipo]='smalldatetime' AND[defecto]=0 AND [tamano] =100)
BEGIN
INSERT INTO [_columnas]
([tabla] ,[columna] ,[mostrarEnGrilla],[ordenGrilla],[requerido] ,[tipo],[defecto],[tamano])
 VALUES
 ('pro_actividad' ,'fechaTerminacionReal',1 ,5 ,1 ,'smalldatetime' ,0 ,100)
END

--------------------------------------------------------------------------------------

IF NOT EXISTS(SELECT *FROM [_columnas] WHERE[tabla]='pro_actividad_recursoFisico'
      AND [columna]='duracion' AND[mostrarEnGrilla]=1 AND[ordenGrilla]=5AND[requerido]=1 AND [tipo]='varchar' AND[defecto]=0 AND [tamano] =100)
BEGIN
INSERT INTO [_columnas]
([tabla] ,[columna] ,[mostrarEnGrilla],[ordenGrilla],[requerido] ,[tipo],[defecto],[tamano])
 VALUES
 ('pro_actividad_recursoFisico' ,'duracion',1 ,5 ,1 ,'varchar' ,0 ,100)
END

IF NOT EXISTS(SELECT *FROM [_columnas] WHERE[tabla]='pro_actividad_recursoFisico'
      AND [columna]='cantidad' AND[mostrarEnGrilla]=1 AND[ordenGrilla]=5AND[requerido]=1 AND [tipo]='int' AND[defecto]=0 AND [tamano] =100)
BEGIN
INSERT INTO [_columnas]
([tabla] ,[columna] ,[mostrarEnGrilla],[ordenGrilla],[requerido] ,[tipo],[defecto],[tamano])
 VALUES
 ('pro_actividad_recursoFisico' ,'cantidad',1 ,5 ,1 ,'int' ,0 ,100)
END
IF NOT EXISTS(SELECT *FROM [_columnas] WHERE[tabla]='pro_actividad_recursoFisico'
      AND [columna]='id_recursoFisico' AND[mostrarEnGrilla]=1 AND[ordenGrilla]=5AND[requerido]=1 AND [tipo]='int' AND[defecto]=0 AND [tamano] =100)
BEGIN
INSERT INTO [_columnas]
([tabla] ,[columna] ,[mostrarEnGrilla],[ordenGrilla],[requerido] ,[tipo],[defecto],[tamano])
 VALUES
 ('pro_actividad_recursoFisico' ,'id_recursoFisico',1 ,5 ,1 ,'int' ,0 ,100)
END

IF NOT EXISTS(SELECT *FROM [_columnas] WHERE[tabla]='pro_actividad_recursoFisico'
      AND [columna]='id_actividad' AND[mostrarEnGrilla]=1 AND[ordenGrilla]=5AND[requerido]=1 AND [tipo]='int' AND[defecto]=0 AND [tamano] =100)
BEGIN
INSERT INTO [_columnas]
([tabla] ,[columna] ,[mostrarEnGrilla],[ordenGrilla],[requerido] ,[tipo],[defecto],[tamano])
 VALUES
 ('pro_actividad_recursoFisico' ,'id_actividad',1 ,5 ,1 ,'int' ,0 ,100)
END
------------------------------------------------------------------------------------------------------------------

IF NOT EXISTS(SELECT *FROM [_columnas] WHERE[tabla]='pro_actividad_ejecutor'
      AND [columna]='id_ejecutores' AND[mostrarEnGrilla]=1 AND[ordenGrilla]=5AND[requerido]=1 AND [tipo]='int' AND[defecto]=0 AND [tamano] =100)
BEGIN
INSERT INTO [_columnas]
([tabla] ,[columna] ,[mostrarEnGrilla],[ordenGrilla],[requerido] ,[tipo],[defecto],[tamano])
 VALUES
 ('pro_actividad_ejecutor' ,'id_ejecutores',1 ,5 ,1 ,'int' ,0 ,100)
END
IF NOT EXISTS(SELECT *FROM [_columnas] WHERE[tabla]='pro_actividad_ejecutor'
      AND [columna]='id_actividad' AND[mostrarEnGrilla]=1 AND[ordenGrilla]=5AND[requerido]=1 AND [tipo]='int' AND[defecto]=0 AND [tamano] =100)
BEGIN
INSERT INTO [_columnas]
([tabla] ,[columna] ,[mostrarEnGrilla],[ordenGrilla],[requerido] ,[tipo],[defecto],[tamano])
 VALUES
 ('pro_actividad_ejecutor' ,'id_actividad',1 ,5 ,1 ,'int' ,0 ,100)
END
--------------------------------------------------------------------------------------------------
IF NOT EXISTS(SELECT *FROM [_columnas] WHERE[tabla]='pro_actividad_hito'
      AND [columna]='id_actividad' AND[mostrarEnGrilla]=1 AND[ordenGrilla]=5AND[requerido]=1 AND [tipo]='int' AND[defecto]=0 AND [tamano] =100)
BEGIN
INSERT INTO [_columnas]
([tabla] ,[columna] ,[mostrarEnGrilla],[ordenGrilla],[requerido] ,[tipo],[defecto],[tamano])
 VALUES
 ('pro_actividad_hito' ,'id_actividad',1 ,5 ,1 ,'int' ,0 ,100)
END
IF NOT EXISTS(SELECT *FROM [_columnas] WHERE[tabla]='pro_actividad_hito'
      AND [columna]='id_hito' AND[mostrarEnGrilla]=1 AND[ordenGrilla]=5AND[requerido]=1 AND [tipo]='int' AND[defecto]=0 AND [tamano] =100)
BEGIN
INSERT INTO [_columnas]
([tabla] ,[columna] ,[mostrarEnGrilla],[ordenGrilla],[requerido] ,[tipo],[defecto],[tamano])
 VALUES
 ('pro_actividad_hito' ,'id_hito',1 ,5 ,1 ,'int' ,0 ,100)
END
--------------------------------------------------------------------------------------------------------
IF NOT EXISTS(SELECT *FROM [_columnas] WHERE[tabla]='pro_actividad_etapa'
      AND [columna]='id_etapa' AND[mostrarEnGrilla]=1 AND[ordenGrilla]=5AND[requerido]=1 AND [tipo]='int' AND[defecto]=0 AND [tamano] =100)
BEGIN
INSERT INTO [_columnas]
([tabla] ,[columna] ,[mostrarEnGrilla],[ordenGrilla],[requerido] ,[tipo],[defecto],[tamano])
 VALUES
 ('pro_actividad_etapa' ,'id_etapa',1 ,5 ,1 ,'int' ,0 ,100)
END
IF NOT EXISTS(SELECT *FROM [_columnas] WHERE[tabla]='pro_actividad_etapa'
      AND [columna]='id_actividad' AND[mostrarEnGrilla]=1 AND[ordenGrilla]=5AND[requerido]=1 AND [tipo]='int' AND[defecto]=0 AND [tamano] =100)
BEGIN
INSERT INTO [_columnas]
([tabla] ,[columna] ,[mostrarEnGrilla],[ordenGrilla],[requerido] ,[tipo],[defecto],[tamano])
 VALUES
 ('pro_actividad_etapa' ,'id_actividad',1 ,5 ,1 ,'int' ,0 ,100)
END
-----------------------------------------------CREACION DE RELACIONES-----------------------------------------------------------------


IF NOT  EXISTS (SELECT * FROM sys.foreign_keys WHERE parent_object_id = OBJECT_ID(N'[dbo].[pro_actividad_recursoFisico]') AND object_id = OBJECT_ID(N'[dbo].[fk_actividad_recursoFisico_id_recursoFisico]')  )
begin
ALTER TABLE [pro_actividad_recursoFisico] ADD CONSTRAINT
	[fk_actividad_recursoFisico_id_recursoFisico] FOREIGN KEY
	--nombre llave foranea--------tabla relacionada---------llave primaria------------
	([id_recursoFisico]) REFERENCES [pro_recursoFisico]	(id)
 
ALTER TABLE [dbo].[pro_actividad_recursoFisico] CHECK CONSTRAINT [fk_actividad_recursoFisico_id_recursoFisico]
end

IF NOT  EXISTS (SELECT * FROM sys.foreign_keys WHERE parent_object_id = OBJECT_ID(N'[dbo].[pro_actividad_recursoFisico]') AND object_id = OBJECT_ID(N'[dbo].[fk_actividad_recursoFisico_id_actividad]')  )
begin
ALTER TABLE [pro_actividad_recursoFisico] ADD CONSTRAINT
	[fk_actividad_recursoFisico_id_actividad] FOREIGN KEY
	--nombre llave foranea--------tabla relacionada---------llave primaria------------
	([id_actividad]) REFERENCES [pro_actividad]	(id)
 
ALTER TABLE [dbo].[pro_actividad_recursoFisico] CHECK CONSTRAINT [fk_actividad_recursoFisico_id_actividad]
end
----------------------------------------------------------------------------------------------------------
IF NOT  EXISTS (SELECT * FROM sys.foreign_keys WHERE parent_object_id = OBJECT_ID(N'[dbo].[pro_actividad_ejecutor]') AND object_id = OBJECT_ID(N'[dbo].[fk_actividad_ejecutor_id_ejecutores]')  )
begin
ALTER TABLE [pro_actividad_ejecutor] ADD CONSTRAINT
	[fk_actividad_ejecutor_id_ejecutores] FOREIGN KEY
	--nombre llave foranea--------tabla relacionada---------llave primaria------------
	([id_ejecutores]) REFERENCES [pro_ejecutores]	(id)
 
ALTER TABLE [dbo].[pro_actividad_ejecutor] CHECK CONSTRAINT [fk_actividad_ejecutor_id_ejecutores]
end
IF NOT  EXISTS (SELECT * FROM sys.foreign_keys WHERE parent_object_id = OBJECT_ID(N'[dbo].[pro_actividad_ejecutor]') AND object_id = OBJECT_ID(N'[dbo].[fk_actividad_ejecutor_id_actividad]')  )
begin
ALTER TABLE [pro_actividad_ejecutor] ADD CONSTRAINT
	[fk_actividad_ejecutor_id_actividad] FOREIGN KEY
	--nombre llave foranea--------tabla relacionada---------llave primaria------------
	([id_actividad]) REFERENCES [pro_actividad]	(id)
 
ALTER TABLE [dbo].[pro_actividad_ejecutor] CHECK CONSTRAINT [fk_actividad_ejecutor_id_actividad]
end

------------------------------------------------------------------------------------------------------------------------

IF NOT  EXISTS (SELECT * FROM sys.foreign_keys WHERE parent_object_id = OBJECT_ID(N'[dbo].[pro_actividad_hito]') AND object_id = OBJECT_ID(N'[dbo].[fk_actividad_hito_id_hito]')  )
begin
ALTER TABLE [pro_actividad_hito] ADD CONSTRAINT
	[fk_actividad_hito_id_hito] FOREIGN KEY
	--nombre llave foranea--------tabla relacionada---------llave primaria------------
	([id_hito]) REFERENCES [pro_hito]	(id)
 
ALTER TABLE [dbo].[pro_actividad_hito] CHECK CONSTRAINT [fk_actividad_hito_id_hito]
end

IF NOT  EXISTS (SELECT * FROM sys.foreign_keys WHERE parent_object_id = OBJECT_ID(N'[dbo].[pro_actividad_hito]') AND object_id = OBJECT_ID(N'[dbo].[fk_actividad_hito_id_actividad]')  )
begin
ALTER TABLE [pro_actividad_hito] ADD CONSTRAINT
	[fk_actividad_hito_id_actividad] FOREIGN KEY
	--nombre llave foranea--------tabla relacionada---------llave primaria------------
	([id_actividad]) REFERENCES [pro_actividad]	(id)
 
ALTER TABLE [dbo].[pro_actividad_hito] CHECK CONSTRAINT [fk_actividad_hito_id_actividad]
end
---------------------------------------------------------------------------------------------------------------------------------
IF NOT  EXISTS (SELECT * FROM sys.foreign_keys WHERE parent_object_id = OBJECT_ID(N'[dbo].[pro_actividad_etapa]') AND object_id = OBJECT_ID(N'[dbo].[fk_actividad_etapa_id_etapa]')  )
begin
ALTER TABLE [pro_actividad_etapa] ADD CONSTRAINT
	[fk_actividad_etapa_id_etapa] FOREIGN KEY
	--nombre llave foranea--------tabla relacionada---------llave primaria------------
	([id_etapa]) REFERENCES [pro_etapa]	(id)
 
ALTER TABLE [dbo].[pro_actividad_etapa] CHECK CONSTRAINT [fk_actividad_etapa_id_etapa]
end

IF NOT  EXISTS (SELECT * FROM sys.foreign_keys WHERE parent_object_id = OBJECT_ID(N'[dbo].[pro_actividad_etapa]') AND object_id = OBJECT_ID(N'[dbo].[fk_actividad_etapa_id_actividad]')  )
begin
ALTER TABLE [pro_actividad_etapa] ADD CONSTRAINT
	[fk_actividad_etapa_id_actividad] FOREIGN KEY
	--nombre llave foranea--------tabla relacionada---------llave primaria------------
	([id_actividad]) REFERENCES [pro_actividad]	(id)
 
ALTER TABLE [dbo].[pro_actividad_etapa] CHECK CONSTRAINT [fk_actividad_etapa_id_actividad]
end