CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2007
    Posts
    491

    XML or Database?

    I want to create a small data table in one of my programs for HighScore. I was wondering if to use XML or to create a database. Does someone who worked with both XML & Databases can tell me what way is better and what way is faster?
    Also, Ill be happy to know what to use and when.


    Thanks for time, Tal.

  2. #2
    Join Date
    May 2003
    Location
    Germany
    Posts
    936

    Re: XML or Database?

    For small data amounts of data I would use XML. If you want to store large amounts of data a database is the better choice. Additional another point of view is how do you want to access the data. If you want to access from one application you can use XML but if you want to access from multiple computers you better use database because you can get problems with XML if two computers trying to write the file at the same time. I believe there are many other points which can influence your decision.

    For a highscore I believe a XML file is smart enough and you can work with it very fast with Serialization/Deserialization.
    Last edited by torrud; February 21st, 2007 at 11:23 AM.
    Useful or not? Rate my posting. Thanks.

  3. #3
    Join Date
    Mar 2006
    Location
    Craiova, Romania
    Posts
    439

    Re: XML or Database?

    If you want to use huge amounts of data and need to retrieve it quickly, you probably won't want to use XML. It's a sequential storage medium ( that means that a search would would have to go through most of the document ). A rdbms like MS sql server , Oracle or Mysql would scale much better. There are also other factors like security of the data ( if you will use xml then you don't need security ) or like budget. If is just a simple application I don't see the use of a rdbms.

    EDIT: Torrud was faster again
    Bogdan

    If someone helped you then please Rate his post and mark the thread as Resolved
    Please improve your messages appearance by using tags [ code] Place your code here [ /code]

  4. #4
    Join Date
    Dec 2003
    Location
    Middletown, DE
    Posts
    67

    Re: XML or Database?

    I would choose XML only if it were necessary to read or edit it from a text or XML editor. Otherwise, I don't see any reason why you couldn't just use a disconnected DataSet and serialize to binary file.

  5. #5
    Join Date
    Nov 2006
    Location
    North Bend, WA
    Posts
    487

    Re: XML or Database?

    Question: Is this a system-wide high score or a network-wide high score, or just a per-user high score?

    If it's just per-user, you could save the data in the application Settings object (you might want to encode it in some way that will prevent tampering, if that matters).

    Also, it isn't always neccessary to use XML. If the data is simple enough, you can just use a plain old text file. I think some people go a bit overboard with XML.

  6. #6
    Join Date
    Jan 2007
    Posts
    491

    Re: XML or Database?

    Thanks much for help everyone. Ill use the XML :P

  7. #7
    Join Date
    Dec 2003
    Location
    Middletown, DE
    Posts
    67

    Re: XML or Database?

    Care to explain why? There were more responses for alternatives than for using XML.

  8. #8
    Join Date
    Jan 2007
    Posts
    491

    Re: XML or Database?

    Quote Originally Posted by spoulson
    Care to explain why? There were more responses for alternatives than for using XML.
    I need to create 5 different HighScore tables. I see the the database as unnecessary and the Save SettingsObject (Or however it called) of the application is kinda too simple. I see the XML as the best way to do that :S

  9. #9
    Join Date
    Dec 2003
    Location
    Middletown, DE
    Posts
    67

    Re: XML or Database?

    That's understandable. My response was for something else, though. However, XML serialized objects should work fine for you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured