15.05.2013 Views

Restrições de Integridade Integridade Semântica - DIMAp

Restrições de Integridade Integridade Semântica - DIMAp

Restrições de Integridade Integridade Semântica - DIMAp

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

RIs na Definição <strong>de</strong> Tabelas<br />

create table Empregados (<br />

codEmp integer,<br />

nome varchar(40)not null,<br />

RG numeric(10) not null unique,<br />

ida<strong>de</strong> integer check (ida<strong>de</strong> between 16 and 90),<br />

estadoCivil char(10) check (estado_civil in<br />

‘solteiro’, ‘casado’, ‘viuvo’, ‘<strong>de</strong>squitado’,<br />

‘divorciado’),<br />

salario numeric(8,2) check (salário > 0),<br />

tempoServiço integer,<br />

codGer integer,<br />

codDepto integer,<br />

...<br />

RIs na Definição <strong>de</strong> Tabelas<br />

...<br />

constraint EmpPk primary key (codEmp),<br />

constraint EmpCodg foreign key (codGer)<br />

references Empregados on update casca<strong>de</strong><br />

on <strong>de</strong>lete set null,<br />

constraint EmpDept foreign key (codDepto)<br />

references Departamentos on update casca<strong>de</strong><br />

on <strong>de</strong>lete no action,<br />

constraint Ida<strong>de</strong>TS check(tempoServico < ida<strong>de</strong>),<br />

constraint EmpGer check(codEmp < > codGer),<br />

constraint SalarioGerente<br />

check(salario < (select salario<br />

from Empregados e<br />

where e.codEmp = codGer))<br />

);<br />

6

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!