I would imagine that this will be a simple answer for someone who has developed many database schemas, but I have recently found myself tasked with optimizing (or attempting to optimize rather) a database schema and have been reading through "High Performance MySQL", and am left with a question concerning the use or "over-use" of foreign key relationships within a schema. For example lets say I have the following tables:
CUSTOMERS: __________________________________ |CustIDPK| Name | RegDate | ---------------------------------- | 1 | frank | 01-30-2014 | | 2 | terry | 02-01-2014 | | 3 | amber | 02-02-2014 | | 4 | sara | 02-06-2014 | PRODUCTS: ____________________________________ | ProdIDPK | ProdName | AddedDate | ------------------------------------ | 1 | Phone | 01-01-2014 | | 2 | TV | 01-02-2014 | | 3 | Tablet | 01-02-2014 | | 4 | PC | 01-05-2014 | PRODUCT_RATINGS: __________________________________________________________________ | ProdRateIDPK | ProdIDFK | CustID | Rating | TimeRated | ------------------------------------------------------------------ | 1 | 1 | 1 | 8 | 01-01-2014 | | 2 | 1 | 2 | 7 | 01-01-2014 | | 3 | 1 | 3 | 8 | 01-02-2014 | | 4 | 2 | 4 | 6 | 01-02-2014 | | 5 | 2 | 4 | 6 | 01-03-2014 | | 6 | 2 | 3 | 4 | 01-01-2014 | | 7 | 3 | 2 | 5 | 01-02-2014 | | 8 | 3 | 1 | 7 | 01-03-2014 | | 9 | 3 | 1 | 4 | 01-04-2014 | | 10 | 4 | 2 | 9 | 01-04-2014 | | 11 | 4 | 3 | 8 | 01-01-2014 | | 12 | 4 | 4 | 7 | 01-01-2014 | The CUSTOMERS table exists independently of the PRODUCTS table therefore no relationship is defined. The PRODUCTS table has a one-to-many relationship with the PRODUCT_RATINGS table since any one product can have many ratings. This much is clear.
Now in the existing schema within the PRODUCT_RATINGS table the column CustID is a foreign key to the CUSTOMERS table, representing a one-to-many relationship with the product ratings since any one user can have many ratings in this table (each rating representing a separate product).
My question: Should the 'CustID' column be defined as a foreign key creating a one-to-many relationship with the CUSTOMERS table? I do not see where the need for a join of this data would be necessary. From what I can tell, the 'CustID' column is only used in the application to distinguish which customer issued the rating...