Welcome to WebmasterWorld Guest from 54.226.147.190

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

creating category tables or just use lists?

     

whatson

9:36 pm on Aug 13, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Say for example you have a product page, and you wish to have 3 images of the product. You can create a field call images, and have a list of all the sources of the images, e.g. image1.jpg, image2.jpg, image3.jpg. Then you can create an array for your images and run a loop to display them.

Alternatively you can create a new table called images, that can match the product up with the images, e.g.
Product ID Image
1 image1.jpg
1 image2.jpg
1 image3.jpg

Which way is the best? and why?

swa66

8:50 am on Aug 14, 2012 (gmt 0)

WebmasterWorld Senior Member swa66 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



As far as I can tell you're asking if normalizing your database is a good thing ?
Sure it's a good thing, it's the essence of being for relational databases.

So yes: separate tables and relations is by far the superior long term choice.
Messing with creating structure yourself inside a field means the database can't help you anymore in the long run.

Just imagine in both cases what happens when you need a separate caption for each image, store the dimensions of the pictures, track the source where you got the picture, copyright status of each image, ...

You need to see a database as much more than a stupid table that holds data in a persistent manner.

topr8

9:20 am on Aug 14, 2012 (gmt 0)

WebmasterWorld Senior Member topr8 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



exactly as swa66 says

in my images table i store the height,width,alt, and various other info
 

Featured Threads

Hot Threads This Week

Hot Threads This Month