There is something I have never ever worked out how to do and this is a simple review system for a tutorials website.
Let’s say I have a table that holds the tutorials
///// tutorials table /////
tutorial_id
tutorial_subject
tutorial_ text
The table holds all my tutorials. Let’s say I have 20 tutorials in total. Each tutorial has its own unique id number.
I want to allow users to be able to write a review about any tutorial.
So the simplest way and most wrong way of doing it would be to do the following.
///// tutorials table /////
tutorial id
tutorial_subject
tutorial_ text
review1
review2
review3
review4
review5
This way each tutorial could hold up to 5 reviews. However what happens if one tutorial only has two reviews and an another tutorial has 20 reviews how would i do this?
I suppose one thing I could do is just create a table for reviews. Each review has it own unique id number.
//// reviews table ///
id
tutorial_id
review
When a review is submitted, it gets a unique id number, but also inserts the tutorial_id in to the database.
Am I on the right track? How would I join the tables together?