/*==============================================================*/ /* Table: APLICACIONES */ /*==============================================================*/ create table if not exists APLICACIONES ( ID_APLICACION integer not null primary key, APP varchar(100) null, VIGENTE boolean null ); /*==============================================================*/ /* Table: PERSONA */ /*==============================================================*/ create table if not exists PERSONA ( RUT numeric(12) not null primary key, ID_TIPO_TRATAMIENTO integer null, DV char(1) null, NOMBRES varchar(100) null, APELLIDO_A varchar(100) null, APELLIDO_B varchar(100) null, FONO varchar(100) null, EMAIL varchar(100) null, FECHA_NACIMIENTO date null ); /*==============================================================*/ /* Table: ROL */ /*==============================================================*/ create table if not exists ROL ( ID_ROL integer not null primary key, NOMBRE_ROL varchar(100) not null ); /*==============================================================*/ /* Table: ROL_APLICACION */ /*==============================================================*/ create table if not exists ROL_APLICACION ( ID_APLICACION integer not null, ID_ROL integer not null, SOLO_VISUALIZAR boolean null, constraint PK_ROL_APLICACION primary key (ID_APLICACION, ID_ROL) ); /*==============================================================*/ /* Table: TIPO_TRATAMIENTO_PERSONA */ /*==============================================================*/ create table if not exists TIPO_TRATAMIENTO_PERSONA ( ID_TIPO_TRATAMIENTO integer not null primary key, TRATAMIENTO varchar(50) null ); comment on table TIPO_TRATAMIENTO_PERSONA is 'Establece el tratamiento de como dirigirse hacia una persona: Ejemplo Se�or Se�ora Srta'; /*==============================================================*/ /* Table: USUARIO */ /*==============================================================*/ create table if not exists USUARIO ( LOGIN varchar(20) not null primary key, RUT numeric(12) null, CLAVE varchar(20) null, VIGENTE boolean null ); /*==============================================================*/ /* Table: USUARIO_ROL */ /*==============================================================*/ create table if not exists USUARIO_ROL ( LOGIN varchar(20) null, ID_ROL integer null, VIGENTE boolean null ); alter table PERSONA add constraint FK_PERSONA_REFERENCE_TIPO_TRA foreign key (ID_TIPO_TRATAMIENTO) references TIPO_TRATAMIENTO_PERSONA (ID_TIPO_TRATAMIENTO) on delete restrict on update restrict; alter table ROL_APLICACION add constraint FK_ROL_APLI_REFERENCE_APLICACI foreign key (ID_APLICACION) references APLICACIONES (ID_APLICACION) on delete restrict on update restrict; alter table ROL_APLICACION add constraint FK_ROL_APLI_REFERENCE_ROL foreign key (ID_ROL) references ROL (ID_ROL) on delete restrict on update restrict; alter table USUARIO add constraint FK_USUARIO_REFERENCE_PERSONA foreign key (RUT) references PERSONA (RUT) on delete restrict on update restrict; alter table USUARIO_ROL add constraint FK_USUARIO__REFERENCE_USUARIO foreign key (LOGIN) references USUARIO (LOGIN) on delete restrict on update restrict; alter table USUARIO_ROL add constraint FK_USUARIO__REFERENCE_ROL foreign key (ID_ROL) references ROL (ID_ROL) on delete restrict on update restrict;