Zac Blazic
Zac Blazic

Reputation: 607

For a simple application, should I be using XML files or a real database or something else?

I'm currently working on a simple Java application that calculates and graphs the different types of profit for a company. A company can have many branches, and each branch can have many years, and each year can have up to 12 months.

The hierarchy looks as follows:

-company
   +branch
   -branch
     +year
     -year
       +month
       -month

My intention was to have the data storage as simple as possible for the user. The structure I had in mind was an XML file that stored everything to do with a single company. Either as a single XML file or have multiple XML files that are linked together with unique IDs.

Both of these options would also allow the user to easily transport the data, as apposed to using a database.

The problem with a database that is stopping me right now, is that the user would have to setup a database by him/herself which would be very difficult for them if they aren't the technical type.

What do you think I should go for XML file, database, or something else?

Upvotes: 1

Views: 102

Answers (3)

Michael Kay
Michael Kay

Reputation: 163342

If it's a single-user application and the amount of data is unlikely to exceed a couple of megabytes, then using an XML file for the persistent storage might well make sense in that it reduces the complexity of the package and its installation process. But you're limiting the scalability: is that wise?

Upvotes: 0

stivlo
stivlo

Reputation: 85496

It will be more complicated to use XML, XML is more of an interchange format, not a substitute for a DB.

You can use an embeddedable database such as H2 or Apache Derby / JavaDB, in this case the user won't have to set up a database. The data will be stored only locally though, so if this is ok for your application, you can consider it.

Upvotes: 3

Tudor Constantin
Tudor Constantin

Reputation: 26861

I would defintely go for the DB:

  • you have relational data, a thing DBs are very good at
  • you can query your data in that relational much easier than in XML
  • the CRUD operations (create, read, update, delete) are much more easier in DB than in XML

You can avoid the need for the user to install a DB engine by embedding SQLite with your app for example.

Upvotes: 3

Related Questions