If the barcode is generated based on unique number of the entity, should we store the barcode image in database ? Or should we use javascript libraries to draw barcode whenever necessary?
Should we store barcode in database?
2.5k views Asked by Tej Patil At
2
There are 2 answers
0
On
Store barcode image is not necessary and will full your database with data that will be obsolet soon and will be stored for ever. in addition, barcode is not requested every time user request the page. and also don't consume a lot of cpu to be drawn. So, it's best you save just the number and just if user request, you draw the image. this way. you'll keep your database light.
If you can generate the barcode on the fly then I would advise storing the code rather then an image.
My reasoning for this is as follows:
You will take up less space in the server's database.
You will use less internet bandwidth by serving a simple number verses an image.
Even if you reduce the image colour palette to monochrome and compress the image. A primitive type (i.e. strings,integers...) will take fewer bytes than an image.
The code for storing a number will be a lot less complex than storing an image.
Operations can be performed on numbers later. For example you could use the data for processing. If you need to change the IDs then the operation will be a lot simpler than regenerating all of the images in your database. You could also do more complex queries in the future with that number and you could use it to tie information together in a relational database.