SQL Lite or Xml?

Discussion in 'iOS Programming' started by floyde, May 4, 2009.

  1. floyde macrumors 6502a


    Apr 7, 2005
    Monterrey, México
    Hi guys, I'm working on my first iPhone project and I could use some help. I'm looking into data storage on the iPhone and so far I've got Core Data (which I think will be available until OS 3.0), SQL Lite and Xml.

    I've worked a lot with non-phone mobile devices (mostly windows ce), but I've never used a database for these types of projects. Since it's been a while since I last developed desktop apps, I'm much more proficient at Xpath than I am at sql (although I'm still pretty decent at it).

    I can't get into the details of the data, but I imagine using just a few hundred records. What would you guys recommend? Is there a significant difference in performance between SQL Lite and Xml? Is one of them easier to use?

  2. jpyc7 macrumors 6502

    Mar 8, 2009
    Denver, CO
    OO, RDBMS, or hierarchical

    I haven't actually done iPhone programming so I don't know about performance, but unless you're sure performance is going to be an issue you might not want to make a decision based on data retrieval speed.

    However, the 3 choices you enumerated fall into these 3 data model categories: object-oriented data (CoreData), relational database (SQL lite), or hierarchical (XML).

    You might want to consider which data model most closely matches your application. Note that the first two data models can be structured to provide hierarchical relationships. I think it is possible to make object-oriented data have the same sort of constraints used in relational databases, but you may have to write all that constraint enforcement code yourself.

    My guess is that using SQL lite will increase your code size, which shouldn't really be that big an issue. XML has the benefit of being human-readable. Someone knowledgeable about CoreData probably can tell you what its advantages are. I'm not familiar with it.

    Anyway, if you think that you're best at coding XML then you might want to use that for prototyping with the idea that you can go back and re-do the data storage code.

    My 2 cents.
  3. kainjow Moderator emeritus


    Jun 15, 2000
    Core Data will use either XML or SQLite, it's configurable for each database. But I'm not sure if the iPhone allows this. If you're using CD I would recommend SQLite since you're not going to be interacting directly with the database.
  4. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    Is the data static or will it change while the app is running?

    You should also consider using a plist. It will have similar performance to the xml file but may be easier to deal with.

    sqlite will be most performant and most flexible. If you might eventually get to 1000 or more records you should probably go that way.
  5. floyde thread starter macrumors 6502a


    Apr 7, 2005
    Monterrey, México
    Thanks for the input guys. I'm currently leaning toward SQL Lite. I think it could come in handy in a future project and I'm better off learning to use it from the start.

    The user creates the data, so it won't be static.
  6. wakka092 macrumors 6502


    Jun 20, 2007
    Go for SQLite. Parsing straight XML (w/o using Core Data, which is supported in 3.0) can be painfully slow if you have over, say, 50 entries. SQLite is very fast in terms of loading.

Share This Page