Got the foreign keys to work for the database.

Code looks awful, though! There's definitely too much going on in
swatches_controller. The end functionality should be somewhat
different, though, so hopefully that'll lift away some of the strain.