title: MySQL - Foreign key on delete set null in not null field
body: <p>This is probably a trivial question, but I'm still a little clumsy when it comes to foreign key constraints so I wanted to make sure.</p>
  
  <p>Let's say I have a table <code>countries</code> with the fields <code>country_id</code> (PK) and <code>name</code>, and a table <code>cities</code> with the fields <code>city_id</code> (PK), <code>name</code> and <code>country_id</code> (FK).</p>
  
  <p>The foreign key <code>cities.country_id</code> has the constraint <code>ON DELETE SET NULL</code>. As I understand it, this means that if a record from <code>countries</code> is deleted, any records in <code>cities</code> that reference that deleted record's <code>country_id</code> will have its <code>country_id</code> field set to NULL.</p>
  
  <p>What if, however, <code>cities.country_id</code> has the attribute <code>NOT NULL</code>? Will this prevent the foreign key constraint from working properly? It would make sense that it does, but I just want to check.</p>