[eluser]tonanbarbarian[/eluser]
what you need to ask is... will an image be alowed to be linked to multiple articles?
and the answer to this also comes down to how you want the site to work
if when the user is creating the article you allow them to upload one or more images, and those images only link to the article and cannot be linked to other aticles, you have a one-to-many relationship
If you have a place on the site where the user can upload images, and then when they are creating an article they can select from a list of images and assign one or more to the article, then you have a many-to-many relationship
so if you have a one-to-many relationship you have have 2 tables
articles:
id
name
body
... etc
images:
id
article_id
filename
...etc
As you can see the article_id in the images table indicates which article this image always belongs. The image can belong to only one article, but the article can then have multiple images, thus a one-to-many relationship
If you have a many to many relationship you need 3 tables
articles:
id
name
body
...etc
images:
id
filename
...etc
articles_images
article_id
image_id
So this time the images table does not have an article_id and instead we have the join table called articles_images which links the 2 tables via the article_id and the image_id.
This allows each article to have many images and each image to belong to mutliple articles, thus a many-to-many relationship
You can add a unique id primary key to the articles_images table if you want, but it is not necessary if you make both the article_id and image_id part of the primary key.
Sometimes when you are allowing the user from the website to select one article_image record and edit or delete it, it can be easier to work with if you have a unique id for the row in question, because you only have to pass a single id, rather than 2 id fields to identifiy the record you are processing.
As a result something I use an id field which is the primary key, and other times I do not. It depends on the processing required by the site