I have a table called listings. For each listing, the user can upload 5 images. In the table listings, I have a multidimensional array images text[][]
. Each multidimensional element will hold [ a base64 string, filename of image]
.
The only time I would do a search on the images[][]
array is if the user removes a image, I would search for the filename of image in the images[][]
array and remove it.
I would really like to avoid having a table just for images. No image will ever belong to more than a single listing I can not justify the cost of foreign key looks ups for what there is really no benefit.
I read in PostgreSQL documentation:
Arrays are not sets; searching for specific array elements can be a sign of database misdesign.
Since the only time I am searching for a specific array element is when a user deletes a image... does this constitute a database misdesign? I was really hoping to use denormalization for the images of a listing.