Proper table design

  • What's the proper way to design this database?

    #1

    Table: Galleries

    gallery_id (int, pk)

    title (varchar)

    Table: Albums

    album_id (int, pk)

    title (varchar)

    Table: Images

    image_id (int, pk)

    title (varchar)

    Table: AT_Galleries_Albums

    id (int, pk)

    gallery_id (int)

    album_id (int)

    Table: AT_Albums_Images

    id (int, pk)

    album_id (int)

    image_id (int)

    --- OR ---

    #2

    Table: Galleries

    gallery_id (int, pk)

    title (varchar)

    Table: Albums

    album_id (int, pk)

    gallery_id (int)

    title (varchar)

    Table: Images

    image_id (int, pk)

    album_id (int)

    title (varchar)

    Basically what I'm asking is should I store the related ids within the associated tables (#2) or in seperate (linkage type) tables (#1)? The relationships should be obvious but I can supply a diagram if needed. I apologize if there are not enough details here.

    Thanks!

  • We would need to know the relationships between these items in order to answer that.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • Can an Album belong to more than one Gallery? Can an image be in multiple albums?

    For each YES you need a "glue" table, for each NO you can do not.

  • Thank you, that makes perfect sense.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply