in my java application I'm maintaining a users database and I have to store user account picture together with other details. i can store the photo in my database or I can store the image in my file system and store relevant path in the database. which one is more suitable in terms of memory and running time ?
-
If the picture is not big, I suggest you to store all datas in DB as in one DB access you will be able to get all datas you need. If you store the picture in a file system, you'll need to get the user ID (or whatever) in DB in order to find the user picture in file system. Two requests in this case.JGeo– JGeo2014-03-26 09:20:41 +00:00Commented Mar 26, 2014 at 9:20
-
@JGeo On the other hand, an image in the filesystem can be accessed by the fileserving facilities of the webserver at any time without running any Java code or SQL queries. For example if a website visitor caches an image -- visits 10 times and doesn't need the image -- but subsequently needs the image because the cache expired.Mihai Stancu– Mihai Stancu2014-03-26 09:28:16 +00:00Commented Mar 26, 2014 at 9:28
-
@JGeo But that's a very "web" related thing. If we're talking about a stand alone application with no web interface then you still have to rebuild the GUI Scene and render the image again -- so what you say may apply there.Mihai Stancu– Mihai Stancu2014-03-26 09:30:48 +00:00Commented Mar 26, 2014 at 9:30
-
1@MihaiStancu : Yes you're right. It depends on the application concerned. But as I said in my first comment, storing picture in DB is only available if picture size is small. Otherwise he should stores them in a file system.JGeo– JGeo2014-03-26 09:33:01 +00:00Commented Mar 26, 2014 at 9:33
Add a comment
|
3 Answers
Reference taken from this article:
You should take decision based on your system complexity and scalability. I suggest you to go with File System and Database Storage is not allowable, but still it is advisable. Management is always easy with database storage, but will create a performance issue in some circumstances. Management is quite complex with file system, but you will get more performance.
Comments
You should store file on file system. You can read about this on programmers stackexchange: https://softwareengineering.stackexchange.com/a/150787