tags:

views:

92

answers:

6

Table: PhotoAlbum
Columns:
AlbumID
AlbumName
AlbumDate
AlbumDescription

Table: Pictures
Columns: PictureID
AlbumID

The issue is that i am using picture ID as a reference to a pic within an album so the data is duplicated for each album for that field.

+5  A: 

PictureID, unless I'm missing something...

Swingley
+9  A: 

Unless I'm missing something, I would think that PictureId would be primary, and AlbumID would be a foreign key.

David Stratton
It kinda felt like a trick question, didn't it?
Swingley
Or possibly homework, or a realllly tired developer in need of some coffee.
David Stratton
+9  A: 

I would say that PictureID is the primary key because it is (or should, anyway) be unique to each picture. After all, the definition of primary key, according to Wikipedia:

In relational database design, a unique key or primary key is a candidate key to uniquely identify each row in a table. A unique key or primary key comprises a single column or set of columns. No two distinct rows in a table can have the same value (or combination of values) in those columns. Depending on its design, a table may have arbitrarily many unique keys but at most one primary key.

Thomas Owens
+1  A: 

If you want each Picture to belong to one and only one Album, then only PictureID is fine.

If you want each picture to appear in multiple albums, then you could make PictureID and AlbumID a combined primary key. That is, a picture is uniquely identified by the combination of the PictureID and the Album it belongs to. Then keep your PictureData in another table (Picture would then be better described as PictureAlbum or something)

kibibu
+1  A: 

On First view pictureId should be primary key. BUT if I am assuming right , there will be a table which will store information about Pictures ( say PictureMaster ) which has PitctureId as primary key THEN

In table Pictures pictureId and AlbumId togethere will create PrimaryKey ( Composite Primary Key) and AlbumId,PictureId will be ForeignKey.

Mahin
+1  A: 

PictureID is the primary key and the AlbumID is the Foreign key... PictureID is a unique don't have same name and the AlbumID is a group that has a unique name also..