1. 2
  1.  

  2. 2

    Alt title: normal forms exist for a reason, JOIN on ugly schemas does surprising things.

    You could render the first problem there impossible by having a primary key and always joining on the primary key.

    I think usually left/right/inner joins are thought of as returning at most as many rows as are in the left/right/both table because usually you don’t use them on anything other than a primary key joined onto a foreign key.

    You could render the second problem here impossible by one of: adding a foreign key constraint to enforce that there is indeed one cost row for every product, or just putting the cost field back into the product table that you shouldn’t have removed it from in the first place.

    1. 1

      Title?