I'm creating an application where I thought of a possibility to insert all the existing addresses in the system into a single table, for users, clients, suppliers, etc. the structure of my table would look like this:
__id => CHAVE_PRIMÁRIA
__status
* idReferencia => CHAVE_EXTRANGEIRA_CONJUNTA (REF. GENÉRICA COM BASE NO txTabela)
* txTabela => CHAVE_EXTRANGEIRA_CONJUNTA (STRING: 'CLIENTE','FORNECEDOR',etc)
txGenero
nmCep
txLogradouro
txComplemento
txBairro
txLocalidade
txUf
txIbge
Is there any way I can mount this foreign key using an existing string in the txTabela
field? or will I have to keep these addresses in countless different tables and significantly increasing the size of my database without need? (obs, this would also happen with contacts, documents and other types of generic values)
I'm sure if I do not use foreign keys I'll be able to build my system structure completely, but with the keys the data loading improves ..