Storing binary files in a relational database is not very efficient. The process of saving and retrieving the files from a database is generally much slower than using file storage. Also, it is a good idea to keep your database as small as possible. If the database is huge, backups become very large and difficult to manage.
Instead of keeping large files in the database, we recommend putting them on disk or in a file storage service (such as S3 in AWS). The database should keep only the URL, path, or some other file identifier.
Let’s see how it should be done. We will use a simple shop diagram as an example:
Our Product
table has a VARCHAR column called image
:
Note that the data type used is VARCHAR as this column will store a URL, a path, or some other file identifier.
How to Change a Column’s Data Type in Vertabelo
To change the data type in Vertabelo, first select the table. In the right pane, find the Columns section and click the gear icon next to the column type .
A new window with the available data types will appear. The VARCHAR data type can be found in the String section. Note that you can configure VARCHAR’s maximum length.