How many images can I save in a blob mysql field?

3

Can I record multiple images in one field blob ?

Or do I have to create multiple fields? Imagem1 , Imagem2 etc ...?

I wanted to know if there is any way to do this without having to create multiple fields.

    
asked by anonymous 04.08.2014 / 15:37

2 answers

4

A blob field stores a binary set of data. You can store more than one image, if both are converted to a single stream of data before. This has two immediate side effects: you need to know where one image starts and the other ends, and you will necessarily have a larger file in that field.

This can be useful if you need to compress data - multiple files in the same compressed package can result in a higher compression ratio than multiple files in separate packages.

However, I believe your problem is to save several images without knowing in advance how many images you have to save for each record in the bank, right? In this case the ideal is to save the images in another table, with chave estrangeira where the record will be.

    
04.08.2014 / 15:45
3

Generally a blob column is made to store a single image.

If you need to store more than one image per entity, the solution to your problem would be to normalize the blob to a second outer table:

Example:

    
04.08.2014 / 15:47