Making an app with Express, React and MySQL for a tattoo shop, with a cms for management and employees to add photos to their portfolio pages, update artist information and add / delete artists as well. And appointment / consultation tracking, all from the CMS.
However, now that i’m trying to get photos involved. And this being my first time using SQL for the database. How does one store images in SQL? Should i use something else like Firebase Firestorage? if i go that route, is there a way to synch it with my SQL database? or would i need to write some functions in app to attatch to the correct artitsts?
Would like to be able to store them in the mySQL DB considering how convienent having all the data together would be. Open to any suggestions, and would like to know why one ways better than the other. Thanks!
I’ve been looking into putting it straight into the MySQL DB, with the VarBinaryMax type. But that sounds like a bit more work than necessary and don’t want to really slow down the mysql server too much. Correct me if i’m wrong, about photos potentially slowing things down. The application is not going to be remotley close to having more than a few hundred photos max.
2
Answers
According to my opinion store the images on a cloud storage service like Firebase Firestorage, AWS S3 or Google Cloud Storage and store image URL in your MySQL database. It help to reduce the size of the database and and make it easier to manage the images. In cloud storage services’ have APIs to upload and retrieve images and sync them with your MySQL database. You can use those APIs.
It’s generally not recommended to store images directly in the db. It’s a waste of space, and the performance is usually poor. The most common approach would be to store them in the file system, while you would persist only URLs in the DB. You can also use the Cloud like S3 or as you mentioned Firebase Storage. There’s also an option to go with CDN like Cloudflare.
If your website is primarily static I would go for CDN or filesystem. Some CDNs offer a pay-as-you-go pricing model, which might be what you want for a low-medium budget website.