Handle NULL foreign key values correctly for the counter cache

Add specs for NULL foreign key handling for sum cache and touch
triggers as well, though those appear to handle NULL values
correctly.