Database design help

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
speedy33417
Forum Contributor
Posts: 128
Joined: Sun Jul 23, 2006 1:14 pm

Database design help

Post by speedy33417 »

I'm working on a photo album and I need help designing my database. It's pretty standard: the pictures are collected in albums, and more albums can be in albums as well. Addition to that users can leave comments for individual pictures.
Obviously pictures could have comments from zero to any number.

What is the easiest way to design my database?

I'm thinking I might assign to each picture a unique number no matter what album they're in and have a separate table for comments. For each comment I'll assign that unique number and list them in order underneath my picture.

Does it sound like a good way to go? Or can you guys recommend a better way?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Can any photo be in any album?

As for comments, I would make comments in their own table and refer to an image_id, so you can relate comments to their appropriate image.

I might also suggest an album table and an image table, then a join table for the two, depending upon how they relate to one another.
User avatar
speedy33417
Forum Contributor
Posts: 128
Joined: Sun Jul 23, 2006 1:14 pm

Post by speedy33417 »

No, right now any image would only be only in one album.

How do you deal with different level of albums? Let's say in the main album there's an album that contains pictures, but another would contain more albums in them. How do you design your album table?

Thanks.
Post Reply