I am working on a relational database design for a photo organising app, and as I have mentioned before, am very new to databases. I need to include exposure, aperture value and focal length. The values I have been provided are:

Exposure: typically represented in seconds, using, e.g. 1/1000 for fast exposure and 20 for very slow;

Aperture: ranging from e.g. 1.1 up to values such as 45;

Focal Length (mm): ranges from about 8 to 1200.

Would you recommend representing these as enums with a range of values, or rather, for example varchar for exposure, text for aperture and int for focal length (I am using MySQL)?

I still am not 100% clear on why you would use which datatypes.

Thanks again for your insight and advice.


What will you do with the numbers?

If you will only display them, then use a string type such as VARCHAR(20).

If you need to do math on them, then FLOAT is probably suitable.

If you will be searching for exact numeric value, then either of the above.

If you will be searching for a range, then probably FLOAT.

If the value is clearly a whole number, then use a suitably-sized INT. For example, SMALLINT UNSIGNED allows values 0..64K, good for pixel width/height. But megapixels would need INT UNSIGNED. Or, that could be a FLOAT, as in "10.3" megapixels.

If it is just specifications for a product -- not searchable, not computed on, etc, then a longer string, like "F4.5, 1/400s, no flash".

Or look at the specifications for EXIF format. Keep in mind that technology will advance. EXIF is an extensible format.

I pulled out width, height, and filesize, plus a string for EXIF. That was good enough for what I have, while not losing the EXIF info in case I change my mind later.


you can use double/float for both exposure and aperture because they carry floating points and int/smallint for focal length. you can use varchar for all this but if you need to do any calculation on these that's not good and when you sort you can't get correct out put you wanted because sever treat these values as strings (if use varchar). in my case i always use numeric data types for numbers.

  • Thank you @Rick and Hewarathna, that's helpful. I don't believe these will be used for calculations or searches. As with a normal photo storage app, I would think these are really just metadata
    – zv426
    Jun 24 '20 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.