I'm sorry I quickly scanned this and didn't read it in full... 

Here is my 2 cents.

"InnoDB rejects any INSERT or UPDATE operation that attempts to create a
foreign key value in a child table if there is no a matching candidate
key value in the parent table." So the parent has a valid entry before a
row is created in the child?

I noticed in defining the mysql table you use:
    foreign key (companyId) references company(id)

Which has no ON DELETE or ON UPDATE clauses... so of course the above
becomes:
    FOREIGN KEY (jcompanyid) REFERENCES company(id)
        ON DELETE RESTRICT
        ON UPDATE RESTRICT

This would prevent you from deleting the parent or changing the foreign
key in the parent if there is a dependant child.  I bring this up
because I noticed the use of CascadeType's.

Reply via email to