Thursday, March 3, 2011

Two DB tables vs one DB Table

Hi folks,

I have a table of music albums. I have a second table of album art. Unfortunately, not every album has some album art data. As such, i will need to do an OUTER JOIN between music and album art.

Assumption: both tables just contain ints and varchars .. no blobs, etc.

Question

  • Is it better to merge both tables into one to reduce the outer join requirement?
From stackoverflow
  • Just use one table, with nulls for albums with no art. I don't see any advantage to having a second table...unless you have a lot of albums that share the same art.

  • The only reason I can see to keep them in separate tables is if one album can contain multiple pieces of artwork. If each table only contains, and will only ever contain, 1 piece of artwork, then sticking them in the same table should be fine. If you are joining these two tables in a lot of different instances, you may want to create a view in order to simplify your SQL statements.

    Pure.Krome : Cheers :) i'll use this.
  • Two tables in this case would usually imply a one->many relationship which is probably not what you want, although I guess some albums come with multiple artwork.

    So theoretically you should merge the tables into one, unless you had a very good reason to have them split into two. Why do you want them as two tables?

0 comments:

Post a Comment