I am currently working in a product where different types of images like product images, user profile pictures, logo etc. are there. I need a database with good query performance.
I got two DB designs in mind.
OPTION 1. - Storing all images in a single table with id,title, url_full, url_thumb , status and timestamp field
Advantages
- I can use single ImageModel file to insert delete / update data. So there will be no multiple logic for image storage. It is just a single logic, "storing in a single table". So whenever image has to be saved, I can call the method of ImageModel
Disadvantages
- If there are lot of product images and less user images, the user image querying will become slow due to the huge number of products.
OPTION 2. - Storing different type of images in different tables with id,title, url_full, url_thumb , status and timestamp field
Advantages
- Increased number of records in one section won't affect the query speed of other
Disadvantages
- Has to write separate model files / functions for each image type.
- Whenever image has to be stored, type needs to be specified.
My question is , which is the better approach. Is the advantages and disadvantages a real concern.Also if there are any other advantages / disadvantages, please list. Or if there are any other god db designs, please suggest.
Please answer based on the practical scenario where there are lots of products and users.