mysql to many connections

pre: php array contains
next: primary keys and foreign keys