Create a conditional using the relational model

2

I'm trying to create a "conditional" or "just using the relational paradigm:

Since the tables pessoa , cliente , funcionario and considering that a person can be a client or be an employee (a 1: 1 ratio, not null), it would be correct to reference the cliente table and funcionario with the same foreign key from the pessoa table? Example:
Theforeignkeyfk_tiporeferenceFuncionario.pk_funcionarioandCliente.pk_cliente.TheonlyproblemIencounteredinthismodeisthattheClientetablecannothaveaprimarykeyequaltotheotherprimarykeyoftheFuncionariotableandviceversa.SoIwouldhavetoreviewthewaythesekeysweregenerated.

IsthereanyotherwaytoaccomplishwhatIwantbyusingtherelationalmodeltothemaximum?

Ps.:itisnotaduplicateof".

    
asked by anonymous 13.09.2014 / 03:01

1 answer

2

Actually, I think the ideal would be the other way around. Have in the tables: employee, customer an FK_PESSOA. That is, every customer is a person. Every employee is a person. A person can be a client or an employee. It would be +/- so, from what I understood:

[pessoa] id, nome, demais campos relativos à pessoa...
[cliente] id, id_pessoa, demais campos relativos a cliente...
[funcionario] id, id_pessoa, demais campos relativos a funcionário...
    
18.09.2014 / 15:48