5

I'm creating an application that will use a lot of data which is, for all intents and purposes, static. I had assumed it'd make most sense to use a SQLite database to handle that data. I'm wondering if it makes sense to just use an XML file(s) and then access it as a raw resource. Bear in mind that there's likely going to be a LOT of data, to the order of hundreds of separate pieces.

Am I right to assume SQLite is best, both in terms of memory management and overall design considerations or does SQLite not make sense if the data is basically static?

LuxuryMode
  • 33,401
  • 34
  • 117
  • 188

3 Answers3

4

In fact, SQLite seems to be nonsense if the data is static. However, if what you are going to manipulate is a lot of data you should use it:

  • It will be easier to:
    • Retrieve data
    • Filter data
    • Sort data
  • Using XML files will cause some performance problems because of the way in which SAX or DOM parses XML.
  • It will be easier for you to update that set of data in the future (imagine that you want to add more data in the next release)
Cristian
  • 198,401
  • 62
  • 356
  • 264
  • Thanks Christian. Great points. So you believe SQLite makes a lot of sense because its more extensible, etc. And it makes sense even though the app doesn't necessarily allow users to add to the DB? – LuxuryMode Mar 06 '11 at 21:39
  • Exactly.. in fact, one of my apps, which has to hold more than 70.000 records is made with an SQLite database. Mix that with a SQlite Index and the performance will be increased a lot. – Cristian Mar 06 '11 at 22:18
0

Did you think of your data being stollen (from the sqlite database)? Because as a sqlite database, anybody with root can just pull the db file and use it

hery
  • 49
  • 6
0

Cristian is right. Database gives you better access time and allows to modify data in very convenient way. XML might be a better idea in case of tree-like data structures.

In my opinion there are 2 question here:

  1. what kind of data are you storing?
  2. Do you allow user to modify this data (for example in application or using Notepad)

There is also 1 big disadvantage of XML - it is eventually open text. So anyone can read it. To prevent it, you would have to encrypt the data (and this means additional effort). In case of XML, using marshaling techniques (JiBX, Castor, JAXB) might be convenient and might also lower memory consumption.

Please describe what kind of data you are storing in DB, so we might come up with better answer.

Sebastian Łaskawiec
  • 2,667
  • 15
  • 33
  • Thanks Altanis. This makes a lot of sense. The data is essentially a reference guide for a bunch of different commands that can be used in Linux and others. So there'll be the text of the command and then the description. That data will be organized by category, etc. Def. sounds like SQLite is the way to go. – LuxuryMode Mar 06 '11 at 23:39
  • In this case, database approach seems to be a very good idea. I think you might want to search this database with different criteria (by some part of description you might search for command; you might also search for commands description based on command name). Data you described fit ideally in table, so this another plus. And the last one - you don't need to encrypt the file (in this case it seems pretty important). There is one con in my mind - zipped XML would probably be smaller. To sum it up: in my opinion your choice is good. – Sebastian Łaskawiec Mar 08 '11 at 07:26