/*==============================================================*/ /* Database name: FITBANK PHYSICAL DATA MODEL */ /* DBMS name: IBM DB2 UDB 5.x Common Server */ /* Created on: 16/04/2010 12:00:00 PM */ /*==============================================================*/ -- SQL script that update fitBank squema -- To run this script from the SQL Plus, perform the following steps: -- 1. connect to the database -- 2. set define character to ! -- "set define !" -- 3. issue the command "@ " -- where represents the name of this script -- fitbank201064006.log alter table TCOMPROBANTESCONTABLESDETALLE drop constraint FKCOMCONDECOD; alter table TCOMPROBANTESCONTABLESDETALLE drop constraint FKCOMCONDESUBCTA; alter table TCOMPROBANTESCONTABLESDETALLE drop constraint FKCOMPCONTDETAREA; alter table TCOMPROBANTESCONTABLESDETALLE drop constraint FKCOMPCONTDETCON; alter table TCOMPROBANTESCONTABLESDETALLE drop constraint FKCOMPCONTDETID; alter table TCOMPROBANTESCONTABLESDETALLE drop constraint FKCOMPCONTDETMON; alter table TCOMPROBANTESCONTABLESDETALLE drop constraint FKCOMPCONTDETSUCOFIDES; alter table TCOMPROBANTESCONTABLESDETALLE drop primary key; drop table TCOMPROBANTESCONTABLESDETALLE; /*==============================================================*/ /* Table: TCOMPROBANTESCONTABLESDETALLE */ /*==============================================================*/ create table TCOMPROBANTESCONTABLESDETALLE ( CPERSONA_COMPANIA INTEGER not null, NUMEROCOMPROBANTE BIGINT not null, SCOMPROBANTECONTABLE INTEGER not null, FHASTA TIMESTAMP not null, VERSIONCONTROL BIGINT default 0, FDESDE TIMESTAMP not null, DEBITOCREDITO VARCHAR(1) not null, CCONCEPTO VARCHAR(4), CMONEDA VARCHAR(3), COFICINA INTEGER, CSUCURSAL INTEGER, CCUENTA VARCHAR(19), SUBCUENTA INTEGER, TIPODECAMBIO DECIMAL(10,6), VALORMONEDAOFICIAL DECIMAL(19,6), VALORMONEDAEXTRANJERA DECIMAL(19,6), DESCRIPCIONADICIONAL VARCHAR(500), CODIGOCONTABLE VARCHAR(20), CAREA VARCHAR(4) ); comment on table TCOMPROBANTESCONTABLESDETALLE is 'Detalle de comprobantes contables provisionales que seran autorizados previo a su paso a la tabla de transacciones y saldos'; comment on column TCOMPROBANTESCONTABLESDETALLE.CPERSONA_COMPANIA is 'Codigo de persona de la compania'; comment on column TCOMPROBANTESCONTABLESDETALLE.NUMEROCOMPROBANTE is 'Numero del comprobante'; comment on column TCOMPROBANTESCONTABLESDETALLE.SCOMPROBANTECONTABLE is 'Secuencia del detalle del comprobante '; comment on column TCOMPROBANTESCONTABLESDETALLE.FHASTA is 'Fecha hasta la que esta vigente la informacion del movimiento del comprobante contable'; comment on column TCOMPROBANTESCONTABLESDETALLE.VERSIONCONTROL is 'Manejo de optimistic locking.'; comment on column TCOMPROBANTESCONTABLESDETALLE.FDESDE is 'Fecha desde la que esta vigente la informacion del movimiento del comprobante contable'; comment on column TCOMPROBANTESCONTABLESDETALLE.DEBITOCREDITO is 'Marca si aplica a D Debito, C Credito'; comment on column TCOMPROBANTESCONTABLESDETALLE.CCONCEPTO is 'Codigo del concepto de debito o credito'; comment on column TCOMPROBANTESCONTABLESDETALLE.CMONEDA is 'Codigo de moneda del movimiento contable'; comment on column TCOMPROBANTESCONTABLESDETALLE.COFICINA is 'Codigo de oficina'; comment on column TCOMPROBANTESCONTABLESDETALLE.CSUCURSAL is 'Codigo de la sucursal'; comment on column TCOMPROBANTESCONTABLESDETALLE.CCUENTA is 'Numero de cuenta de una subcuenta'; comment on column TCOMPROBANTESCONTABLESDETALLE.SUBCUENTA is 'Numero de subcuenta'; comment on column TCOMPROBANTESCONTABLESDETALLE.TIPODECAMBIO is 'Valor del tipo de cambio aplicado al movimiento contable'; comment on column TCOMPROBANTESCONTABLESDETALLE.VALORMONEDAOFICIAL is 'Valor del movimiento contable en la moneda oficial'; comment on column TCOMPROBANTESCONTABLESDETALLE.VALORMONEDAEXTRANJERA is 'Valor del movimiento contable en moneda extranjera'; comment on column TCOMPROBANTESCONTABLESDETALLE.DESCRIPCIONADICIONAL is 'Descripcion adicional del movimiento contable'; comment on column TCOMPROBANTESCONTABLESDETALLE.CODIGOCONTABLE is 'Codigo contable'; comment on column TCOMPROBANTESCONTABLESDETALLE.CAREA is 'Codigo de area: cre = credito, ope=operaciones, etc'; alter table TCOMPROBANTESCONTABLESDETALLE add constraint CKDEBITOCREDITOCCD check (DEBITOCREDITO = upper(DEBITOCREDITO) and DEBITOCREDITO in ('D','C')); alter table TCOMPROBANTESCONTABLESDETALLE add constraint IPKCOMPCONTDET primary key (CPERSONA_COMPANIA, NUMEROCOMPROBANTE, SCOMPROBANTECONTABLE, FHASTA); alter table TCOMPROBANTESCONTABLESDETALLE add constraint FKCOMCONDECOD foreign key (CODIGOCONTABLE, CPERSONA_COMPANIA) references TCUENTACONTABLEID (CODIGOCONTABLE, CPERSONA_COMPANIA); alter table TCOMPROBANTESCONTABLESDETALLE add constraint FKCOMCONDESUBCTA foreign key (CCUENTA, CPERSONA_COMPANIA, SUBCUENTA) references TSUBCUENTASID (CCUENTA, CPERSONA_COMPANIA, SUBCUENTA); alter table TCOMPROBANTESCONTABLESDETALLE add constraint FKCOMPCONTDETAREA foreign key (CPERSONA_COMPANIA, CAREA) references TAREASID (CPERSONA_COMPANIA, CAREA); alter table TCOMPROBANTESCONTABLESDETALLE add constraint FKCOMPCONTDETCON foreign key (CCONCEPTO) references TCONCEPTOSID (CCONCEPTO); alter table TCOMPROBANTESCONTABLESDETALLE add constraint FKCOMPCONTDETID foreign key (CPERSONA_COMPANIA, NUMEROCOMPROBANTE) references TCOMPROBANTESCONTABLESID (CPERSONA_COMPANIA, NUMEROCOMPROBANTE); alter table TCOMPROBANTESCONTABLESDETALLE add constraint FKCOMPCONTDETMON foreign key (CMONEDA) references TMONEDASID (CMONEDA); alter table TCOMPROBANTESCONTABLESDETALLE add constraint FKCOMPCONTDETSUCOFIDES foreign key (CPERSONA_COMPANIA, COFICINA, CSUCURSAL) references TOFICINASSUCURSAL (CPERSONA_COMPANIA, COFICINA, CSUCURSAL);