Mysql – Advisable number of foreign keys in a single table

database-designforeign keyMySQL

I was wondering, keeping performance and optimizations in mind, while designing the database, is there any advisable number of foreign keys you should keep in a single table?

At present, few of my tables are using 4 foreign keys. Would like to know, if number of foreign keys in a single table causes some performance or scalability issues?

I am using MySql

Best Answer

Yes, ultimately FKs can affect performance. They will certainly affect insert/delete performance (more lookups), but you have the advantage of guaranteed data integrity.

You should be more than happy to pay a high price for data integrity - a high performance database with inconsistent data is worse than useless - certainly not as much use as a database that's a bit slow but with consistent data.

Yah gets what yah pays for!