Hello, I am using mysql as database, innodb as tables engine. Some of my tables have foreign keys referencing to other tables primary keys.
Since the definition of foreign key is to restrict the value of itself, I would like to know if I should check the existence of the primary key in the parent table before inserting in the child table (therefore 2 queries: SELECT then INSERT). Or I should directly insert in the child table and mysql will do this for me (therefore 1 query with other hidden mysql job). Please note that performance is important for me. If any advantage/disadvantage applies let me know. Thank you, best regards