Try two tables like this:
Table photos
ID/Name/filepath/filename/description
Table categories
ID/photo/category
In table photos you set ID as autoincrement and primary key, Name is a user given name for the file, filepath is the location in the server, filename is well..., description is a set of keywords.
Table categories is set up as follows:
ID is again a primary autoincrement key, photo is a field where ID field of the photos table is stored (photos.ID). If a photo fits a category an entry is placed in the categories table
Given your example
Entry for photos table
ID/Name/filepath/filename/description
1/Mary_and_Joe/imgdir/img001.jpg/Joe Mary birthday party
Entry for category table
ID/photo/category
1/1/people
2/1/special events
3/1/birthday parties
You then join the tables on a SQL
select * from photos, category where photos.ID=category.photo and category.category="people" or category.category="special events"
This SQL selects all photos that belong to the people and special events category. You could also add : photos.description like "%mary%" to select all records that include mary...etc.
Hope it helps
Saludos
Gerardo