Mas nem todo dependente tem CPF, especialmente crianças. Em 25 de maio de 2011 16:29, Flavio Henrique Araque Gurgel <fha...@gmail.com > escreveu:
> > Pensei em algo tipo: > > CREATE TABLE dependente ( > > cpf_pai bigint not null, > > cpf_mae bigint not null, > > nome text not null, > > tipo integer, > > primary key(cpf_pai, cpf_mae, nome), > > foreign key (cpf) references funcionario(cpf) > > ); > > Se você colocar dois campos referenciando a mesma tabela (no seu caso, > funcionario) você não terá com forçar a integridade referencial. > Sugiro fazer uma tabela intermediária: > > CREATE TABLE dependente_funcionario ( > cpf_dependente bigint not null, > cpf_responsavel bigint not null, > primary key (cpf_dependente, cpf_responsavel), > foreign key (cpf_dependente) references dependente(cpf), > foreign key (cpf_responsavel) references funcionario(cpf) > ); > > Esta tabela faz a "cola" entre a tabela de dependentes e funcionários. > > []s > Flavio Gurgel > _______________________________________________ > pgbr-geral mailing list > pgbr-geral@listas.postgresql.org.br > https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral > -- Atenciosamente, Alexsander da Rosa http://rednaxel.com
_______________________________________________ pgbr-geral mailing list pgbr-geral@listas.postgresql.org.br https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral