RESTRICCIONES DE DOMINIOS



Documentos relacionados
El Lenguaje SQL TEMA V. Grupo de Bas ses de Datos Avanzadas Univ. Carlo os III de Madrid. V.1 SQL como Lenguaje de Definición de Datos

CONTROL DE ACCESO. curso 2008

Aplicaciones de las vistas Concepto de vista Vistas en SQL Vistas en SQL.

Diseño de bases de datos

SQL. (...la guía básica de supervivencia de dmi) Universidad de los Andes Demián Gutierrez Enero

Otros objetos de Base de Datos

ÍNDICE PRIMERA PARTE... 17

SINTAXIS DE SQL-92. <definición de esquema >::= CREATE SCHEMA <cláusula de nombre de esquema> [ <elemento de esquema>... ]

Haga clic para PostgreS cambiar el estilo

Integridad y Seguridad. Integridad y Seguridad. Restricción de Dominio. Protección. Índice. create domain. Dominios

Permite definir cada relación que pertenece a la base de datos relacional, incluyendo:

UNIVERSIDAD DEL ISTMO CAMPUS IXTEPEC LIC. INFORMATICA GRUPO 508 PROCEDIMIENTOS ALMACENADOS EN SQL SERVER 2000

Motores de Base de Datos Libres: Postgresql y MySql. Ing. Ricardo Naranjo Faccini, M.Sc

Integridad en sistemas de bases de datos relacionales

Seguridad en SQL Server 2005

AUTENTICACIÓN: DETERMINAR SI EL USUARIOS ES QUIÉN DICE SER AUTORIZACIÓN: DETERMINA A CUÁLES OBJETOS TIENE ACCESO EL USUARIO

GUIA DE LABORATORIO N 9 B. (000Webhost Php- Para desarrollar en casa)

DISPARADORES EN SQL DISPARADORES EN SQL:1999 SINTAXIS GENERAL DE UN DISPARADOR EN SQL:1999 SINTAXIS GENERAL DE UN DISPARADOR EN SQL:1999

LABORATORIO 2. POSTGRE SQL - BASE DE DATOS SECRETARIA DE HACIENDA

EXAMEN TEMAS 3, 4 y 5. CREACIÓN Y EXPLOTACIÓN DE UNA BASE DE DATOS

LENGUAJE ESTRUCTURADO DE CONSULTAS SQL (2)

SQL PROCEDURAL Triggers y Stored Procedures. Ing. Gustavo A. Correa Reina UNCPBA 2008

Triggers 24/12/2016. Escuela Técnica Superior de Ingeniería Informática Departamento de Lenguajes y Sistemas Informáticos. Triggers en Oracle

Práctica 3: Lenguaje SQL 2ª Parte: Definición de datos. Objetivos

Restricciones de Integridad

LENGUAJE SQL. Bárbula, Febrero de Historia y Definición

- Bases de Datos - - Diseño Físico - Luis D. García

Bases de Datos SQL - Ejemplos

Oracle Básico PL/SQL

Disparadores en Oracle (Ejemplos Prácticos)

Tema 33. El lenguaje SQL

Tema 1. Bases de datos activas

Diseño de bases de datos

El usuario puede utilizar esta tabla derivada como una tabla más, en sus consultas.

Programación SQL. Lucio Salgado Diciembre 2008

BASE DE DATOS - CURSO 02/03 PRÁCTICA 2: SQL: Lenguaje de definición de datos (DDL)

Tema 1. Bases de datos activas

[ EDICION ESPECIAL] En el siguiente ejemplo se agrega un archivo de datos de 5 MB a la base de datos BD_Ejemplo01.

Bases de Datos / Elementos de Bases de Datos Que es un Stored Procedure? Stored Procedures: Ventajas

Disparadores en ORACLE

Repaso. Laboratorio Informix. Stored Procedures. Ejemplo. Creación de stored procedures. Sql en un Procedimiento

PRÁCTICA III. DISPARADORES EN SQL (II)

Integridad y Seguridad en los sistemas de Bases de Datos. Javier Escobar Luis Ramirez Omar Asprino

Laboratorio Informix. Stored Procedures Triggers

Triggers. BASES DE DATOS Mercedes García Merayo

Formato para prácticas de laboratorio

Sistemas de Datos Curso: Ernesto Chinkes. Sistemas de Datos. Niveles de Control de acceso. Criptografía. Aspectos legales y éticos.

Bases de Datos / Elementos de Bases de Datos 2015

Formato para prácticas de laboratorio

EXAMEN DE BASES DE DATOS 11/06/04 Esquema de trabajo

Formatos para prácticas de laboratorio

Tipos de datos en SQL. SQL. DDL (Data Definition Language) CREATE DOMAIN CREATE TABLE CREATE TABLE. CREATE TABLE con restricciones de atributo

Procedimientos, Funciones, Trigger y Cursores en ORACLE

A. Introducción. B. Los DATABASES TRIGGERS. PL/SQL en objetos de la base de datos. Oracle 11g - SQL, PL/SQL, SQL*Plus 271

Concepto de vista. (con ciertas limitaciones). nivel físico) Una vista es una tabla virtual (no tiene una correspondencia a

Escuela Técnica Superior de Ingeniería Informática Departamento de Lenguajes y Sistemas Informáticos. Triggers

Seguridad de la Información Permisos. Sistemas de Bases de Datos II - ITS EMT - CETP

CURSO DE SQL SERVER 2005

Bases de Datos I. Cursada Clase 3: Restricciones de Integridad (de tablas y generales)

10 - Desencadenadores.

Lenguaje para descripción de datos

Bases de Datos: Structured Query Language (SQL)

PROGRAMANDO BASES DE DATOS PostgreSQL INTRODUCCIÓN INTRODUCCIÓN A LAS BASES DE DATOS (L1)

8 SQL SERVER 2008 RA-MA

CREATE USER ADMINISTRADOR IDENTIFIED BY ADMIN DEFAULT TABLESPACE USERS TEMPORARY TABLESPACE TEMP QUOTA 500K ON USERS;

Unidad III. Bases de Datos

Solución Ejercicio Prac. 3b (Esquema).

6. Integridad en Sistemas de Bases de Datos Relacionales

Un ejemplo teórico de trigger podría ser éste:

Tutorial Oracle SQL Developer 1.2.1

TRANSACT-SQL, DISEÑO Y PROGRAMACIÓN DE BASES DE DATOS EN SQL SERVER 2008

Gestión de Usuarios en MySQL

Microsoft SQL Server Usuarios, Roles, Encriptación y Back Up de la base de datos.

PL/SQL avanzado: Secuencias, triggers, cursores y subprogramas

INTRODUCCIÓN INTRODUCCIÓN INTRODUCCIÓN INTRODUCCIÓN INSTRUCCIONES DE DEFINICIÓN DE TABLAS E ÍNDICES INSTRUCCIONES DE DEFINICIÓN DE TABLAS E ÍNDICES

SQL. Orígenes y Evolución

UNIVERSIDAD NACIONAL EXPERIMENTAL POLITÉCNICA DE LA FUERZA ARMADA NACIONAL EXTENSIÓN BARQUISIMETO BARQUISIMETO ESTADO. LARA

Acceso a bases de datos MySQL con PHP

PL/PGSQL. Extensión "procedural" de SQL

T12 Vistas y tablas temporales

Bibliografía Oracle Database Concepts - 10g Release 2 (10.2) (Octubre 2005)

Lenguaje SQL (2ª Parte) Definición de datos

Bases de Datos SQL 1 SQL. Jorge Pérez R. Universidad de Talca, II Semestre 2006

SQL (Structured Query Language)

APÉNDICE SQL (Structures Query Language)

Bases de Datos SEGURIDAD E INTEGRIDAD EN BASES DE DATOS. Ejemplo del Lado del servidor

Sistema Gestor de Bases de Datos Relacionales (SGBDR), que maneja distintos tipos de datos:

Laboratorios de BASES DE DATOS. (I.T. Informática)

8 MICROSOFT SQL SERVER 2008 R2. CURSO PRÁCTICO RA-MA

LENGUAJE DE CONSULTA ESTRUCTURADO - SQL CONTENIDO

4- Uso de sentencias para el envió y extracción de datos

Pequeños apuntes de SQL *

Maestría en Bioinformática. Bases de Datos y Sistemas de Información SQL: DDL. Ing. Alfonso Vicente, PMP alfonso.vicente@logos.com.

Bases de Datos Ejercicio Número 2 Bogotá, Diciembre 5 de 2013

Transcripción:

RESTRICCIONES DE DOMINIOS - Cargo del personal de la inmobiliaria: create domain cargo_personal as character20 check value in Venta, Alquiler, Gerencial - Categoría del barrio: create domain categoría as character6 check value in Alta, Media, Baja -Tipo de operación inmobiliaria: create domain operacion_inmobiliaria as character15 check value in Venta, Alquiler, Todas -Tipo de inmueble: create domain tipo_inmueble as character15 check value in Casa, Departamento, Cochera, Terreno

DEFINICION DE TABLAS - Barrio: create table barrio nombre character20 not null, transporte character20, distancia_centro integer, categoria categoria, primary key nombre - Cliente: create table cliente login character20 not null, password character20, nombre character40, apellido character30, fecha date, calle character30 num_calle integer, dpto character4, dni integer, activo boolean, primary key login check num_calle > 0, check dni > 0

- Cuota: create table cuota financiacion_alquiler_id integer not null, num_cuota integer not null, precio integer, primary key financiacion_alquiler_id, num_cuota, foreign key financiacion_alquiler_id references financiacion_alquiler id on update cascade on delete cascade, check num_cuota > 0, check precio > 0 - CuotaPaga: create table cuota_paga operacion_id integer not null, pago_num_cuota integer not null, fecha_pago date, primary key operación_id, pago_num_cuota, foreign key operación_id, pago_num_cuota references pago operación_id, num_cuota on update restrict on delete cascade, check pago_num_cuota > 0 - FinanciacionAlquiler: create table financiacion_alquiler+ id integer not null, primary key id

- FinanciacionVenta: create table financiacion_venta num_cuotas integer not null, precio integer not null, primary key num_cuotas, precio, check num_cuotas > 0, check precio > 0 - Inmueble: create table inmueble inmueble_id integer not null, barrio_nombre character20 not null, cliente_login character20 not null, tipo character20, descripcion character20, antiguedad integer, superficie integer, calle character20, num_calle integer, operacion operacion_inmobiliaria, primary key inmueble_id, foreign key barrio_nombre references barrio nombre on update cascade on delete restrict, foreign key cliente_login references cliente login on update cascade on delete cascade, check superficie > 0, check num_calle > 0

- OfertaAlquiler: create table oferta_alquiler inmueble_id integer not null, financiacion_alquiler_id integer not null, primary key inmueble_id, financiacion_alquiler_id, foreign key financiacion_alquiler_id references financiacion_alquiler id on update cascade on delete cascade, foreign key inmueble_id references inmueble inmueble_id on update cascade on delete cascade, - OfertaVenta create table oferta_venta inmueble_id integer not null, num_cuotas integer not null, precio integer not null, primary key inmueble_id, num_cuotas, foreign key inmueble_id references inmueble inmueble_id on update cascade on delete cascade, foreign key num_cuotas, precio references financiacion_venta num_cuotas, precio on update cascade on delete cascade, check num_cuotas > 0, check precio > 0

- OperacionAlquiler: create table operación_alquiler operación_id integer not null, inmueble_id integer not null, personal_login character20 not null, cliente_login character20 not null, fecha_operacion date, fecha_inicio date, primary key operación_id, foreign key cliente_login references cliente login on update restrict on delete restrict, foreign key inmueble_id references inmueble inmueble_id on update restrict on delete restrict, foreign key personal_login references personal login on update restrict on delete restrict - OperacionVenta: create table operacion_venta operacion_id integer not null, inmueble_id integer not null, personal_login character20 not null, cliente_login character20 not null, fecha date, precio integer, primary key operacion_id, foreign key cliente_login references clientelogin on update restrict on delete restrict, foreign key inmueble_id references inmueble inmueble_id on update restrict on delete restrict, foreign key personal_login references personal login on update restrict

on delete restrict, check precio > 0 - Pago: create table pago operacion_id integer not null, num_cuota integer not null, monto integer, fecha_vencimiento date, primary key operacion_id, num_cuota, check monto > 0 - Personal: create table personal login character20 not null, password character20, nombre character40, apellido character30, dni integer, fecha date, calle character30, num_calle integer, dpto character4, activo boolean, cargo cargo_personal, primary key login, check dni > 0, check num_calle > 0

- Sector: create table sector inmueble_id integer not null, piso integer not null, numero character2 not null, primary key inmueble_id, piso, numero, foreign key inmueble_id references inmueble inmueble_id on update cascade on delete cascade

ROLES - Cliente de la inmobiliaria: create role usuario_cliente - Personal de venta: create role personal_venta - Personal de alquiler: create role personal_alquiler - Personal gerencial: create role personal_gerencial

VISTAS - Cuota paga de una operación de alquiler: create view cuotapaga_opalquiler as select * from cuota_paga as cp where cp.operacion in select opa.operacion_id from operacion_alquiler as opa - Cuota paga de una operación de venta: create view cuotapaga_opventa as select * from cuota_paga as cp where cp.operacion in select opv.operacion_id from operacion_venta as opv - Inmueble para alquiler: create view inmueble_alquiler as select * from inmueble as i where i.operacion = Alquiler or i.operacion = Todas - Inmueble para venta: create view inmueble_venta as select * from inmueble as i where i.operacion = Venta or i.operacion = Todas - Pago de una operación de alquiler: create view pago_opalquiler as select * from pago as p where p.operacion_id in select opa.operacion_id from operacion_alquiler as opa

- Pago de una operación de venta: create view pago_opventa as select * from pago as p where p.operacion_id in select opv.operacion_id from operacion_venta as opv

SECUENCIAS - Secuencia para las id s de los inmuebles: create sequence id_inmueble increment 1 minvalue 1 maxvalue 9223372036854775807 start 1; - Secuencia para las id s de las operaciones: create sequence id_operacion increment 1 minvalue 1 maxvalue 9223372036854775807 start 1; - Secuencia para las id s de las financiaciones de alquiler: create sequence id_financiacion_alquiler increment 1 minvalue 1 maxvalue 9223372036854775807 start 1;

TRIGGERS - Login único de cliente en tabla de cliente y personal: create trigger notrepeatlogincliente after insert, update login on cliente referencing new row as new for each row when exists select p.login from personal as p where p.login = new.login begin atomic end delete from cliente where cliente.login = new.login - Login único de personal en tabla de cliente y personal: create trigger notrepeatloginpersonal after insert, update login on personal referencing new row as new for each row when exists select p.login from cliente as c where c.login = new.login begin atomic end delete from personal where personal.login = new.login

- Borrar pagos de una operación de alquiler borrada: create trigger deletepagosopalquiler after delete on operación_alquiler referencing old row as old for each row begin atomic end delete from pago where operacion_id = old.operacion_id - Borrar pagos de una operación de venta borrada: create trigger deletepagosopventa after delete on operación_venta referencing old row as old for each row begin atomic end delete from pago where operacion_id = old.operacion_id - Cambiar el dueño del inmueble al insertar o actualizar una operacion de venta: create trigger changeowner after insert, update on operacion_venta referencing new row as new for each row begin atomic end update inmueble set cliente_login = new.cliente_login where inmueble_id = new.inmueble_id

- Crear usuario de logueo al insertar un cliente: create trigger insertclient after insert on cliente referencing new row as new for each row begin atomic end create user new.login with createuser password new.password in group usuario_cliente - Modificar usuario de logueo al modificar un cliente: create trigger updatecliente after update on cliente referencing old row as old, new row as new for each row begin atomic end alter user new.login with password new.password - Crear usuario de logueo al insertar un personal: create trigger insertpersonal after insert on personal referencing new row as new for each row begin atomic if new.cargo = 'Venta' then create user new.login with createuser password new.password in group personal_venta else if new.cargo = 'Alquiler' then create user new.login with createuser password new.password in group personal_alquiler else

end create user new.login with createuser password new.password in group personal_gerencial - Modificar usuario de logueo al modificar un personal: create trigger updatecliente after update on cliente referencing old row as old, new row as new for each row begin atomic end alter user new.login with password new.password

PRIVILEGIOS Privilegios para el Usuario Cliente Los permisos del usuario_cliente no los otorgamos mediante la sentencia grant de SQL porque como el cliente debe ver únicamente sus datos, los inmuebles que le pertenecen y/o alquila y el estado actual de sus pagos, deberíamos hacer un conjunto de vistas por cliente y eso sería muy ineficiente. En cambio, controlamos el acceso por parte del usuario_cliente a través del lenguaje php. Privilegios del Personal de Alquiler: - Privilegios sobre clientes y personal: grant all privileges on cliente to personal_alquiler grant select, insert, delete on personal to personal_alquiler grant update password, nombre, apellido, dni, fecha, calle, num_calle, dpto, activo on personal to personal_alquiler - Privilegios sobre barrio y sector: grant all privileges on sector, barrio to personal_alquiler - Privilegios sobre inmueble: grant select, insert on inmueble to personal_alquiler grant delete on inmueble to personal_alquiler grant update barrio_nombre, cliente_login, descripcion, antiguedad, superficie, calle, num_calle, disponibilidad, num_ambientes, operación, tipo on inmueble to personal_alquiler - Privilegios sobre oferta de alquiler: grant select, delete, insert on oferta_alquiler to personal_alquiler grant update inmueble_id on oferta_alquiler to personal_alquiler

- Privilegios sobre financiación de alquiler: grant select, delete, insert on financiacion_alquiler to personal_alquiler - Privilegios sobre cuota: grant select, insert, delete on cuota to personal_alquiler grant update num_cuotas, precio on cuota to personal_alquiler - Privilegios sobre operación de alquiler: grant select, insert, delete on operacion_alquiler to personal_alquiler grant update fecha_operacion, fecha_inicio on operacion_alquiler to personal_alquiler - Privilegios sobre pago: grant insert on pago to personal_alquiler grant delete, select on pago to personal_alquiler grant update num_cuota, monto, fecha_vencimiento on pago to personal_alquiler - Privilegios sobre cuota paga: grant insert on cuota_paga to personal_alquiler grant delete, select on cuota_paga to personal_alquiler grant update pago_num_cuota, fecha_pago on cuota_paga to personal_alquiler Privilegios del Personal de Venta: Privilegios sobre clientes y personal: grant all privileges on cliente to personal_venta grant select, insert, delete on personal to personal_venta grant update password, nombre, apellido, dni, fecha, calle, num_calle, dpto, activo on personal to personal_venta

- Privilegios sobre barrio y sector: grant all privileges on sector, barrio to personal_venta - Privilegios sobre inmueble: grant select, insert on inmueble to personal_venta grant delete on inmueble to personal_venta grant update barrio_nombre, cliente_login, descripcion, antiguedad, superficie, calle, num_calle, disponibilidad, num_ambientes, operación, tipo on inmueble to personal_venta - Privilegios sobre oferta de venta: grant all privileges on oferta_venta to personal_venta - Privilegios sobre financiacion de venta: grant all privileges on financiacion_venta to personal_venta - Privilegios sobre operación de venta: grant select, insert, delete on operacion_venta to personal_venta grant update fecha, precio on operacion_venta to personal_venta - Privilegios sobre pago: grant insert on pago to personal_venta grant delete, select on pago to personal_venta grant update num_cuota, monto, fecha_vencimiento on pago to personal_venta - Privilegios sobre cuota paga: grant insert on cuota_paga to personal_venta grant delete, select on cuota_paga to personal_venta grant update pago_num_cuota, fecha_pago on cuota_paga to personal_venta

Privilegios para el Personal Gerencial - Privilegios de lectura sobre todas las relaciones: grant select on cliente, personal to personal_gerencial grant select on barrio, inmueble, sector to personal_gerencial grant select on financiacion_alquiler, oferta_alquiler, cuota to personal_gerencial grant select on financiacion_venta, oferta_venta to personal_gerencial grant select on operacion_venta, operacion_alquiler to personal_gerencial grant select on pago, cuota_paga to personal_gerencial