/*==============================================================*/ /* DBMS name: PostgreSQL 8 */ /* Created on: 24/11/2011 15:56:00 */ /*==============================================================*/ /*==============================================================*/ /* Table: caja */ /*==============================================================*/ create table caja ( codcaja INT2 not null, ubicacion VARCHAR(100) null, constraint PK_CAJA primary key (codcaja) ); -- set table ownership alter table caja owner to postgres ; /*==============================================================*/ /* Table: cmpcontable */ /*==============================================================*/ create table cmpcontable ( comprobante INT4 not null, descripcion VARCHAR(255) null, monto DECIMAL(6,2) null, constraint PK_CMPCONTABLE primary key (comprobante) ); -- set table ownership ; /*==============================================================*/ /* Table: deposito */ /*==============================================================*/ create table deposito ( codeposito VARCHAR(10) not null, descripcion VARCHAR(45) null, constraint PK_DEPOSITO primary key (codeposito) ); -- set table ownership alter table deposito owner to postgres ; /*==============================================================*/ /* Table: detcontable */ /*==============================================================*/ -- set table ownership ; /*==============================================================*/ /* Index: fk_detcontable_deposito */ /*==============================================================*/ /*==============================================================*/ /* Index: fk_detcontable_cmpcontable */ /*==============================================================*/ /*==============================================================*/ /* Table: detventa */ /*==============================================================*/ create table detventa ( codetventa INT4 not null, precio DECIMAL(6,2) null, estatus VARCHAR(2) null, cargo DECIMAL(6,2) null, venta_codventa INT4 null, servicio_codservicio VARCHAR(10) null, usuario_codusuario VARCHAR(15) null, constraint PK_DETVENTA primary key (codetventa) ); -- set table ownership alter table detventa owner to postgres ; /*==============================================================*/ /* Table: servicio */ /*==============================================================*/ create table servicio ( codservicio VARCHAR(10) not null, nombre VARCHAR(60) null, costo DECIMAL(6,2) null, constraint PK_SERVICIO primary key (codservicio) ); -- set table ownership alter table servicio owner to postgres ; /*==============================================================*/ /* Table: turno */ /*==============================================================*/ create table turno ( codturno INT4 not null, fecha DATE null, horaini TIME null, horafin TIME null, saldoini DECIMAL(6,2) null, saldofin DECIMAL(6,2) null, saldoactual DECIMAL(6,2) null, cerrado INT2 null, caja_codcaja INT2 null, deposito_codeposito VARCHAR(10) null, constraint PK_TURNO primary key (codturno) ); -- set table ownership alter table turno owner to postgres ; /*==============================================================*/ /* Index: fk_turno_caja */ /*==============================================================*/ /*==============================================================*/ /* Index: fk_turno_deposito */ /*==============================================================*/ /*==============================================================*/ /* Table: usuario */ /*==============================================================*/ create table usuario ( codusuario VARCHAR(15) not null, cedula VARCHAR(15) null, nombre VARCHAR(100) null, apellido VARCHAR(100) null, constraint PK_USUARIO primary key (codusuario) ); -- set table ownership alter table usuario owner to postgres ; /*==============================================================*/ /* Table: venta */ /*==============================================================*/ create table venta ( codventa INT4 not null, fecha DATE null, hora INT4 null, total DECIMAL(6,2) null, estatus VARCHAR(1) null, turno_codturno INT4 null, constraint PK_VENTA primary key (codventa) ); -- set table ownership alter table venta owner to postgres ; /*==============================================================*/ /* Index: fk_venta_turno */ /*==============================================================*/ alter table detventa add constraint fk_detventa_servicio foreign key (servicio_codservicio) references servicio (codservicio); alter table detventa add constraint fk_detventa_usuario foreign key (usuario_codusuario) references usuario (codusuario); alter table detventa add constraint fk_detventa_venta foreign key (venta_codventa) references venta (codventa); alter table turno add constraint fk_turno_caja foreign key (caja_codcaja) references caja (codcaja); alter table turno add constraint fk_turno_deposito foreign key (deposito_codeposito) references deposito (codeposito); alter table venta add constraint fk_venta_turno foreign key (turno_codturno) references turno (codturno);