You can download the completed project here:http://wikisend.com/download/168242/allDone.zip
Inside of newTable.txt you will find the sql for the new table. You must run this sql on your database before any of this will work.
The ratings table represents a many to many relationship between recipes and users. Therefore, the ratings table acts as a join table between the users and the recipes with the user_id and the recipe_id acting as identifying foreign keys between the two tables. These two identifying relationships form a compound primary key. A user and a recipe together identifies a rating (hence an "identifying relationship). This forms a compound primary key on the rating table (user_id, recipe_id).
If no ratings have been submitted for a recipe, no rating is supplied. If there have been ratings, then I simply use the AVG and COUNT aggregate functions in MySQL to get the average rating and number of ratings.
If a user is signed in, they can rate a recipe that they did not enter
. A user cannot rate their own recipe. Once a rating has been entered, the user will see it whenever they view the recipe. If the user wishes, he can change his previous rating. However, it is impossible to enter more than one rating per recipe. This is accomplished with the ON DUPLICATE KEY UPDATE functionality in MySQL.
I think you will find that this meets all of the requirements and does so quite nicely. I believe your instructor will enjoy the stars on the view_recipe page.
Let me know if you have any questions. I'm here to help.
Please remember to rate my answer. Thank you so much!