/* Create Tables */ Create table sbc_ponderaciones_ejecutadas ( ponderacion_ejecutada Serial NOT NULL, fecha_ejecucion Date NOT NULL, desc_ejecucion_ponderacion Varchar(50) NOT NULL, nombre_usuario Varchar(20) NOT NULL, ejecucion_definitiva Char(1) NOT NULL Default 'N', convocatoria Integer NOT NULL, doc_entregada Char(1), primary key (ponderacion_ejecutada) ) With Oids; Create table sbc_reglas_ponderacion ( nro_regla_ponderacion Serial NOT NULL, sql_variable Text NOT NULL, desc_variable_ponderacion Text, nom_regla_ponderacion Varchar(30) NOT NULL, primary key (nro_regla_ponderacion) ) With Oids; Create table sbc_reglas_x_ejecucion ( ponderacion_ejecutada Integer NOT NULL, nro_regla_ponderacion Integer NOT NULL, orden Integer NOT NULL, primary key (ponderacion_ejecutada,nro_regla_ponderacion) ) With Oids; Create table sbc_ejecuciones_x_solicitud ( solicitud Integer NOT NULL, ponderacion_ejecutada Integer NOT NULL, valor_ponderacion Double precision NOT NULL Default 0, valor_segundo_ordenamiento Double precision NOT NULL, primary key (solicitud,ponderacion_ejecutada) ) With Oids; Create table sbc_reglas_x_ejecuciones_x_solicitud ( solicitud Integer NOT NULL, ponderacion_ejecutada Integer NOT NULL, nro_regla_ponderacion Integer NOT NULL, valor_ponderacion_regla Double precision NOT NULL, valor_resultante_regla Double precision, primary key (solicitud,ponderacion_ejecutada,nro_regla_ponderacion) ) With Oids; Create table sbc_evaluaciones_x_ponderacion ( ponderacion_ejecutada Integer NOT NULL, tipo_evaluacion Integer NOT NULL, primary key (ponderacion_ejecutada,tipo_evaluacion) ) With Oids; Create table sbc_tipo_beca_x_ponderacion ( ponderacion_ejecutada Integer NOT NULL, tipo_beca Integer NOT NULL, primary key (ponderacion_ejecutada,tipo_beca) ) With Oids; /* Create Foreign Keys */ Create index IX_Relationship232 on sbc_ponderaciones_ejecutadas (convocatoria); Alter table sbc_ponderaciones_ejecutadas add foreign key (convocatoria) references sbc_convocatorias (convocatoria) on update restrict on delete restrict; Create index IX_Relationship243 on sbc_tipo_beca_x_ponderacion (tipo_beca); Alter table sbc_tipo_beca_x_ponderacion add foreign key (tipo_beca) references sbc_tipos_beca (tipo_beca) on update restrict on delete restrict; Create index IX_Relationship235 on sbc_ejecuciones_x_solicitud (solicitud); Alter table sbc_ejecuciones_x_solicitud add foreign key (solicitud) references sbc_solicitud (solicitud) on update restrict on delete restrict; Create index IX_Relationship241 on sbc_evaluaciones_x_ponderacion (tipo_evaluacion); Alter table sbc_evaluaciones_x_ponderacion add foreign key (tipo_evaluacion) references sbc_tipos_evaluaciones (tipo_evaluacion) on update restrict on delete restrict; Create index IX_Relationship233 on sbc_reglas_x_ejecucion (ponderacion_ejecutada); Alter table sbc_reglas_x_ejecucion add foreign key (ponderacion_ejecutada) references sbc_ponderaciones_ejecutadas (ponderacion_ejecutada) on update restrict on delete restrict; Create index IX_Relationship236 on sbc_ejecuciones_x_solicitud (ponderacion_ejecutada); Alter table sbc_ejecuciones_x_solicitud add foreign key (ponderacion_ejecutada) references sbc_ponderaciones_ejecutadas (ponderacion_ejecutada) on update restrict on delete restrict; Create index IX_Relationship239 on sbc_evaluaciones_x_ponderacion (ponderacion_ejecutada); Alter table sbc_evaluaciones_x_ponderacion add foreign key (ponderacion_ejecutada) references sbc_ponderaciones_ejecutadas (ponderacion_ejecutada) on update restrict on delete restrict; Create index IX_Relationship242 on sbc_tipo_beca_x_ponderacion (ponderacion_ejecutada); Alter table sbc_tipo_beca_x_ponderacion add foreign key (ponderacion_ejecutada) references sbc_ponderaciones_ejecutadas (ponderacion_ejecutada) on update restrict on delete restrict; Create index IX_Relationship234 on sbc_reglas_x_ejecucion (nro_regla_ponderacion); Alter table sbc_reglas_x_ejecucion add foreign key (nro_regla_ponderacion) references sbc_reglas_ponderacion (nro_regla_ponderacion) on update restrict on delete restrict; Create index IX_Relationship238 on sbc_reglas_x_ejecuciones_x_solicitud (nro_regla_ponderacion); Alter table sbc_reglas_x_ejecuciones_x_solicitud add foreign key (nro_regla_ponderacion) references sbc_reglas_ponderacion (nro_regla_ponderacion) on update restrict on delete restrict; Create index IX_Relationship237 on sbc_reglas_x_ejecuciones_x_solicitud (solicitud,ponderacion_ejecutada); Alter table sbc_reglas_x_ejecuciones_x_solicitud add foreign key (solicitud,ponderacion_ejecutada) references sbc_ejecuciones_x_solicitud (solicitud,ponderacion_ejecutada) on update restrict on delete restrict; /* Create Comment on Columns */ Comment on column sbc_ponderaciones_ejecutadas.ponderacion_ejecutada is 'Identificador de ponderación ejecutada'; Comment on column sbc_ponderaciones_ejecutadas.fecha_ejecucion is 'Fecha de ejecución de la ponderación'; Comment on column sbc_ponderaciones_ejecutadas.desc_ejecucion_ponderacion is 'Descripción para la ejecución'; Comment on column sbc_ponderaciones_ejecutadas.nombre_usuario is 'Usuario responsable de la ejecución'; Comment on column sbc_ponderaciones_ejecutadas.ejecucion_definitiva is 'Es la ejecución que se publica'; Comment on column sbc_reglas_ponderacion.sql_variable is 'Sql que hará el cálculo para la variable'; Comment on column sbc_reglas_ponderacion.desc_variable_ponderacion is 'Descripción de la variable sobre la cual se hace la regla'; Comment on column sbc_reglas_x_ejecucion.orden is 'Orden en que se ejecuta la regla dentro de la ponderación';