Jump to content

Advice on creating albums within a mysql database photo gallery


php_beginner_83

Recommended Posts

Hi All

 

I'm currently trying to develop a database driven photo gallery. So far I have it working and displaying images no problem. The next step I want to take is to create seperate photo albums, e.g an album with my Christmas photos, another for holiday photos etc.

The idea I had was in the table in my database to include 2 additional fields, one to record the name of the album the photo belongs to and another to indicate whether that picture is the cover photo of the album. Then I could use a MySQL query to get all the photos that belong to the albums and get the cover picture. On my webpage, I would like to display the cover picture with the name of the album beneath it and when the user clicks the name of the album, a page will open displaying the contents of the selected album.

I would like your opinion of my way of thinking. Do you think it is a good way to do this or do you have a more simple idea. I would really appreciate any advice you have to give.

 

Thank you.

I think it would be better to keep the table of photos separate rather than add 2 columns with album and isAlbumCoverPhoto type of column.

 

You could perhaps add just one column, albumID FK (int).  Then create a table "albums" which has a auto increment "albumID" PK (int), albumName (varchar?), coverPhoto FK (int).

 

I don't think it'd be wise to create a column such as "isalbumcoverphoto" on the photos table because you will basically have NOs for all but the # of albums that exist - a waste of space and irrelevant to the photo itself.

 

Looking forward however, you may create another separate table including the "photoID, albumID" so that photos can exist in multiple albums.  This example would have 3 tables: photos, photos-albums, albums.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.