Hi
Quick question about what method would be more efficient.
I have a table photo_uploads and columns ‘imageid’,‘type’,‘typeid’,‘url’
‘type’ can be ‘profile’ or ‘site’ and ‘typeid’ is the id of that particular site or profile.
So if i want to select all photos of a persons profile whose userid is ‘7’, i would have
SELECT * FROM photo_uploads WHERE type = ‘profile’ && typeid = ‘7’
I have another option which i thought of which is to have separate columns for profile_id and site_id
so in the example above i could rather have
SELECT * FROM photo_uploads WHERE profile_id = ‘7’
Which method is more efficient? Or am i doing this the complete wrong way?
My idea for the second option is that if a image is a site image and therefore profile_id is NULL for that row, mysql would perhaps skip that row and other similar rows when searching for all the profile images for that particular id making the query faster and more efficient.
Please advise!