Hey guys (and probably girls). I'm modelling a huge database in mysql for a company that i work and i'm stucked on things that you might help me.
My question is very simple: How do i know that a number of foreign keys is enought ?
I have 8 tables that describes the following datas:
1st relationship
(city => state => country)
2nd relationship
(role => sector => department)
3rd relationship
(company => legal entity)
And finally i have a ninth table called employee and this table have foreign key references of all the tables previously described.
(primary) empresa_entidade_juridica_cidade_cidade_id (empresa table)
(fK) cargo table
The main concept of this model is.
legal entity must be placed on country => state => city
I have a register of a company
Company should have a referece to the legal entity table (that owns address, phone, state id, city id, country id, postal code and etc...)
I have a register of a role
And finally, the main table called employee described on the image above.
I hope you guys have undertood me !
See ya.
You can have 100 foreign keys in your table if that's what's required to keep your data properly normalized. Don't worry about the number. Worry about keeping your fields appropriately atomic and your schema normalized.