How to insert into 2 tables which are dependant on each other I have this 2 tables (MySQL) that are dependent on each other and I don't know what to do when creating a new company as it needs a document type...and a document type needs the id of the company it belongs. I was thinking about asking (in a form) for the document type's info (it has only 2 fields) and then inserting it, but it will trigger a foreign key constraint fail as neither keys exists, right?

CREATE TABLE Company
(
    id long not null,
    document_type_id long not null
)

CREATE TABLE Document_Type
(
    id long not null,
    company_id long not null
)


Which approach should I take?
with correction after comment from author:

example of procedure

CREATE DEFINER=`root`@`%` PROCEDURE `udp_insert_company`(`v_id` double, `v_document_type_id` double)
BEGIN
declare v_error_text varchar(200);
set v_error_text = '';

IF NOT EXISTS (SELECT id FROM document_type where id = v_document_type_id) THEN
        SELECT CONCAT('ERROR - id ', CAST(v_id AS CHAR), ' not found') into v_error_text;
    SELECT v_error_text;
ELSE
    INSERT INTO company VALUES (v_id, v_document_type_id);  
END IF; 

END


it just example, You can use any other method for return error code

@call `test_db`.`udp_insert_company`(4, 3);

ERROR - id 4 not found