Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

SQL performance - multiple tables or one bigger one?

LEGEND ,
Dec 12, 2006 Dec 12, 2006
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?
TOPICS
Server side applications
229
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 12, 2006 Dec 12, 2006
LATEST
.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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines