AnsweredAssumed Answered

How to prevent duplicates in join table?

Question asked by tomchandler on Feb 27, 2014
Latest reply on Mar 2, 2014 by erolst

I need to know how to prevent duplicates in a join table.


I am building a restaurant inventory database. I have three tables: Restaurants, Products and a join table between them. The restaurant and the products tables both have numeric primary keys. The join table has foreign keys that are related to the respective parents. How do I prevent duplicates like the ones shown below?


Restaurant IDProduct IDQtyMy Comments
11100This is ok.
1250This is ok.
11200Not ok; this is a duplicate because the restaurant ID and product ID match the values in the first record.
2150This is ok.
2275This is ok.