Ok, I've been trying to figure this out but haven't been able to come to a conclusion. I'd love to get some results from y'all, tips to do some more testing, or some more resources to read.
The situation is simple. There is a primary table of pictures. Probably of cat_pictures
. There is a secondary table of cat_pictures_comments
. Some smart developer made sure that cat_pictures
has an auto-incrementing primary key of ID_PICTURE
, and comments are stored with an index of ID_PICTURE
as well.
Our application has a page that wants to show all of the pictures with all of each pictures comment.
Do we
Just
INNER JOIN
cat_pictures
withcat_pictures_comments
(and make sure things are ordered correctly)Get all
cat_pictures
, then loop through each and getcat_pictures_comments
for each picture
A: What if the application is PHP?
B: What if cat_pictures
had the entry ID, picture filepath, and another 20,285 fields for the cat's genome? And the cat_pictures
were also INNER JOIN
'ed with each cat's owner's psychiatrist (a 1-1 relationship). ( Basically, there's way more data attached to the primary table compared to our little pissant comments table. )
Thanks all.