I need to create a database in which several tables have images.
For example, users have profile pictures and uploaded ones and products have many pictures, as well.
Is it better to have one SQL table "images" or add "images" to every table that contains them?
Also, how would you add many images into one column?
I've read about the advantages of storing the file paths vs the actual files in the database but what about a long string with many file paths vs many rows?
For example
INSERT INTO images (userid, image1, image2, image3)
VALUES (autoincrementedPK 'pathtofile1', 'pathtofile2', 'pathtofile3')
or
INSERT INTO images (userid, images)
VALUES (autoincrementedPK, 'pathtofile1, pathtofile2, pathtofileN')
Which option is better and why? Is option two viable? and if so, how would you implement it?
Best Answer
First about storing file paths:
Regarding storing actual images as BLOBS.
Note: I can't give you syntax because I'm not familiar with MySQL datatypes.