Mark Mark - 7 months ago 40
MySQL Question

mysql - table design for embeding system

I am working on an embedment section on my site where users can embed different media from various services, youtube, myspace music, vimeo etc

I am trying to work out the best way to store it. Users do not have to embed all of the options and can only embed one of each type (one video for example).

Initially I thought just have a table with a row per embeded item like so:

  • embedid (auto increment primary key),
    userid, embedded_item_id (e.g a
    youtube id)

but then I realised that some embedable items require multiple arguments such as myspace music so I thought id make a table where each user has one row.

  • userid, youtubeid, vimeoid,
    myspaceid1, myspaceid2

but it seems a bit clumsy especially considering there will always be empty rows as users can not ever have all of them. Does anyone have a better solution?

  • `EmbededItem' table has columns common to all items.
  • YouTube, Vimeo, MySpace have only columns specific to each one.