Skip to main content
Inspiring
December 12, 2006
Question

SQL performance - multiple tables or one bigger one?

  • December 12, 2006
  • 1 reply
  • 229 views
One product will have 5 different types of media that need to be
associated with it.

Some products will have, perhaps many items in one column while none in
other columns

For Example

Product ID | ###
images | photoID1, PhotoID2
multimedia |
testimonials |
Pdfs | pdfid1
INserts | insertid1, insertid2 insertid3

Anyways, I am wondering if creating one table with multiple columns is
better than many tables with just one of each of these categories?

In other words, would it be better to have a table for multi-media, a
table for pdfs and so on or one table for all of them. Some rows will be
empty.

does the server take a bigger hit accessing multiple tables win
individual items or one table with more columns that are, perhaps empty?
This topic has been closed for replies.

1 reply

Inspiring
December 12, 2006
.oO(Lee)

>One product will have 5 different types of media that need to be
>associated with it.
>
>Some products will have, perhaps many items in one column while none in
>other columns
>
>For Example
>
>Product ID | ###
>images | photoID1, PhotoID2
>multimedia |
>testimonials |
>Pdfs | pdfid1
>INserts | insertid1, insertid2 insertid3
>
>Anyways, I am wondering if creating one table with multiple columns is
>better than many tables with just one of each of these categories?
>
>In other words, would it be better to have a table for multi-media, a
>table for pdfs and so on

That would be one possible way.

>or one table for all of them. Some rows will be
>empty.

Don't do that, at least not in the way you described above. But you
could do it with a single table if you would add a column that describes
the media type:

productId
mediaType
mediaId

There would be a record for every single associated media. A product
with 3 PDFs and 5 images would have 8 records in the media table.

Micha