Topic: saving images in a new folder

Hi

in my project I record many entries with pictures.
Each entry might have 2 or 3 images and there are lots of entries about 500 entries which means that approximately 1000 pictures should be saved in the database and the database will be very heavy.
My question is that if the file "sqlite.db" gets bigger and bigger will it slow down the running of the project?

is there any way that pictures are shown in the project but they can be saved somewhere else and not in "sqlite.db"?

thank you in advance

Re: saving images in a new folder

Hello,


It's not recommended to store pictures in the database, it's will slow down the running of the project.


You can configure a component DBImage to store images in a folder, set the property Type = LinkFile
also you can set property CopyTo, more info about CopyTo
http://myvisualdatabase.com/help_en/com … opyto.html

Dmitry.

3 (edited by identity 2016-01-19 21:27:18)

Re: saving images in a new folder

Hi

the properties of the "DBfile" has type and I can choose between linkfile and linkfolder

but "DBimage" does not have type or linkfile

Could you please tell me how can I store image in a folder?

I have attached my project

thank you

Post's attachments

Attachment icon LinkedLists.rar 292.53 kb, 558 downloads since 2016-01-19 

Re: saving images in a new folder

identity wrote:

Hi

the properties of the "DBfile" has type and I can choose between linkfile and linkfolder

but "DBimage" does not have type or linkfile

Could you please tell me how can I store image in a folder?

I have attached my project

thank you

Unfortunately in old version this property not exists.

Dmitry.

Re: saving images in a new folder

hi
I have made a project which is very important for me, and the version I used for this project is 1.45

Is there any script for the pictures to be saved in a folder in this version?

I know that in the newer version of this program, the linkfile is enabled for the images but I can't upgrade it I don't have enough money to pay for it? I'm so sorry sad sad sad

Re: saving images in a new folder

identity
Unfortunately there is no possibility to implement it using script, but you can use component DBFile to store images, this component have mode LinkFile.

Dmitry.

Re: saving images in a new folder

Hello Dmitry and identity,


As a matter of fact, I thought a lot about whether or not to save images in the database. This subject has already been debated with Tcoton and Jean.B.


The pros are that, if images are embeded in the database, there is no risk of "loosing them" or the user messing with the folder containing the images.

The cons people think first about is : database size and reaction time.
There is another con which is : if a corrupted image is saved to the database, there is no way to erase it (I encountered the problem).


Anyway, my experience on the subject is : I decided to save images in the database. Currently I have 300 records, with 3 images per records. The database size is just under 200 Mo in size and I feel absolutely NO LAG and NO RESPONSE TIME.


I tested on a SDD and on a standard hard drive, and I have no problem at all when requesting a record and displaying the 3 images attached.
Of course, if you write a query that displays all the images at once, I think you can go and prepare some coffee while waiting smile


TIP1 : if you want to keep you database fast, try to make a separate table just for images and just for that


TIP2 : if you perform a lot of delete operation on your database, especially on images, try to implement a script to VACUUM your image table from time to time. Deleting an image delete the link to the image, but the size occupied is still there. VACUUM will reclaim that lost space.


Mathias

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor

Re: saving images in a new folder

thanks mathmathou for your reply. I have 2 questions in mind

1)
What do you mean by "make a separate table just for images" ?
If I make a separate table, images are still saved in the file "sqlite.db". Isn't it?
What can I do to make "sqlite.db" smaller in size?

2)
What is the script to VACUUM the image table?

thanks

Re: saving images in a new folder

Hello identity


yes, the image table is still in the sqlite.db file. Unless you manually, and by script, attach a second database to your project, everything goes into the sqlite.db file.


My making a seperate table for images i mean something like for example :
- a car table with ID,BRAND,COLOR and so on
- a image table with ID,CAR_ID,IMAGE


That way, you can have as many images as you want per CAR, and all the images are stored in on separate table, not mixed with text and integers.


To make sqlite.db smaller, you can not do much :
- limit the number of picture per CAR (in my example)
- limit the size of the images you save


You can VACUUM a whole database or only a specific table.
Command is (with the example of a table called car_images :

SQLExecute('VACUUM car_images');

THIS IS USEFULL ONLY IF YOU PERFORM A LOT OF DELETE ON THE TABLE, otherwise, I recommend you don't use it.


In my project,  there is a counter in database that is incremented by every delete operation, and when it reaches 30, the script is triggered.

Each time you vacuum, there is no changes made to your row id on the table (the ID of your records), so your data won't get messed-up.


Only if you reach the maximum number of row id for a table (which is 18446744073709551616)  then the system will start to reuse old row id left empty by the delete operation. It is very much unlikely to happen during the life cycle of your application smile


Mathias

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor

Re: saving images in a new folder

Hi mathmathou
thank you for your help

I have 2 questions in mind?
1) if I make a separate table for the images, will the speed of the database go up or it doesn't matter if the images are stored in the original table or in a separate table only with images?

2) you said (Unless you manually, and by script, attach a second database to your project, everything goes into the sqlite.db file)
how can I use a script to store the images in another file or database? the version I use is 1.45 and it doesn't have linkfile.
is there any script regarding storing images in another file because in my project there are approximately 1000 pictures and the size of the sqlite.db is about 1.5 Gigabyte therefor every time I want to check a record I have to wait a lot.
thank you