XML vs CoreData question

Talk to other Pedia users about the programs, share tricks and tips or ask questions about existing features.
Post Reply
SuperMacGuy
Junior Member
Junior Member
Posts: 3
Joined: Mon Aug 21, 2006 7:01 pm

XML vs CoreData question

Post by SuperMacGuy »

i see the new Pedias run on CoreData. I'm wondering why the change to this? XML is an open standard and even nearly-human-readable. I admit I do not know about CoreData except it exists, and only on the Mac. Is its data structure more portable, more secure, or more compact? Is the data file itself easy to move to another computer, ie just saved as any other file? I know that I could modify or 'fix' an XML file outside of Pedia if I needed to, but can I do that with CD?
I'm not bashing either CD or XML but just curious to the reasons to change from what is a known standard.
Can Pedia export to an XML file and re-import it?

Chris
danco
Addicted to Bruji
Addicted to Bruji
Posts: 94
Joined: Fri Aug 31, 2007 3:06 pm

Post by danco »

With my book database of more than 4000 books, I reckon that the new format is slower to load than the old, but significantly faster to respond to any changes. I think the response speed was the reason for the change.
User avatar
Conor
Top Dog
Posts: 5346
Joined: Sat Jul 03, 2004 12:58 pm
Contact:

Post by Conor »

We switched to Core Data because of its speed. One of the great things about Core Data is that it lets you choose SQL as one of the formats to store the information in. This is the format we are using with Core Data.

With the XML the entire database had to be in memory and every time it's saved it has to be written out as a whole. With SQL you can read only the sections you need as well as only save the sections where there are changes. This is especially useful with things like credits and entries that are in separate tables and are only loaded as needed. The pedias were always fast so at a hundred entries the changes are not drastic but when you get into the thousands you can feel the pedias launch faster, save faster, search faster.

Core Data also helps with the program maintenance. Before we were doing a lot of work ourselves, with Core Data we let OS X handle it. For example our previous smart collections took 1500 lines of code to be able to handle all the different cases, we had to do the equality test ourselves. With Core Data you can write "title contains alien" and tell it to fetch. which makes searches faster as it uses the SQL technology to run the query. It also provides undo support for almost free which was a big selling point, looking down the road we hope AppleScript support will be easier to write.

Not using XML means it's not human readable and modifiable outside of the pedias with a text editor. (SQL is also a standard and there are programs out there that can read the new file format just not text editors; SQLite Database Browser is a free version of one of those, but even Apple recommends not poking at the file behind Core Data's back.) We still have XML as the .xpedia format that is used when saving a collection. Exporting a collection still gives you the benefits of XML.

We trust in the stability of Core Data to keep the database in good condition. In fact there is a lot of validation that goes on, so that the database is never saved if it's not in a valid state. Of course backups are always important, so just like the old pedias this one makes a copy of the database every month. A user backup on a separate hard drive is ideal as well, and if you like XML for its text format you can use a .xpedia file export of the Library as backup as well.

The file is self contained just like an XML so it is still easy to move. As for size the SQL is a bit smaller due to the fact that it doesn't have to have all those XML tags.

There is a lot overhead involved with Core Data and a few losses but the gains are more substantial. Thanks to the great work of Apple engineers the pedias will be better with every OS X release. If you upgrade to Leopard you won't need to upgrade the pedias they will already be faster because Core Data is improved.
danco
Addicted to Bruji
Addicted to Bruji
Posts: 94
Joined: Fri Aug 31, 2007 3:06 pm

Post by danco »

My own feeling was that the pedias *launch* slower, but certainly save and change faster.

You say here that the pedias make a copy of the database every month. In your help page on Pedia Data Structures you say it saves every week.
User avatar
Conor
Top Dog
Posts: 5346
Joined: Sat Jul 03, 2004 12:58 pm
Contact:

Post by Conor »

Thank you, will update that information; it's a change I made on Nora without telling her; Core Data is so reliable I did not need to be so paranoid as to choose a weekly schedule.
Post Reply