I have this image table,
image_id
image_title
image_description
image_source
and I want this image table to associate with page table and sometimes with comment table
page table,
page_id
...
...
comment table,
comment_id
...
...
Should I put the foreign key of page_id and comment_id in image table?
image_id
image_title
image_description
image_source
page_id
comment_id
Or should I create a map table for each purpose?
a map table for image and page
image_id
page_id
and another map table for image and comment
image_id
comment_id
What is the best practice for this kind of scenario?
Will the image table get slow if I use map idea when the image table row increase (this is another main concern)?
Currently I do this,
image page table,
image_id
image_title
image_description
image_source
page_id
image comment table,
image_id
image_title
image_description
image_source
comment_id
but this doesn't look good as I am repeating the columns and it does not appear to be dynamic...
Any thoughts?
EDIT:
Sometimes the image is associated with the page and sometimes with comment. The upload image sometimes is for the article itself and sometimes is for the comment under the article.
image_id image_title page_id comment_id
1 a 1 NULL
2 b NULL 1
3 c 1 NULL
4 d 1 NULL