Is saving data in SQLite as BLOB, a good programming practice? - iphone

Currently I am working with the project in which I need to parse complex XML, which contains multilevel details (Name & Paths for PDFs, PNGs, etc) at each node.
I need to store all the data in local memory of iPhone/iPad.
Should I create classes for each of those details and make appropriate tables in SQLite or store the data as BLOB and retrieve all the data all the time?
Any Suggestions, thoughts are most welcome...
EDIT:
I am storing Files in DocumentsDirectory and path to SQLite database. Question is to create well defined database tables or to store data in BLOB form.
Pros and Cons for both approach would be much appreciated. Thanks.

in my opinion you should simply use BLOB : when you startup your app load you'r xml into an object all changes will be made to that object so you can win the time to rewrite back to disk
on exit application save all to disk..

Using of BLOB is not a good process .Store all pdf and images in Document directory..store that path only in DB...

Related

Is there any other way to store barcode in database?

I generated barcode and i need to save it in mysql database. I know there are 2 ways of storing it. 1. Insert image with the data type blob and another is we can achieve it by setting the path of the png file... My question is. Is there any other way to store barcode details in mysql database other than the above mentioned?

How to store wavefront .obj models in mongodb

I am trying to store 3d models in the .obj format into a database. I am using a mongodb database. How do approach this problem? do I convert it to binary or something?
Any help will be much appreciated.
Thanks
You do not store entire model in the database (mongodb or any other).
You just store the link to the .obj file on your server.
Similar thing as with the images, you just store url to them, not the entire object.
ID Name Url
0 dragon /models/dragon.obj
1 sponza /models/sponza_scene.obj
2 rabbit /models/rabbit.obj
...
If you for some reason need to store data directly into the database, take a look at this SO question.

Insert a PDF file into Core Data?

I'm using my app to import some PDF files.
But I'm trying to insert my PDF file int my database. I'm using Core Data. Is it possible to do this ? If it is, how can I do it ? Which kind of types I have to use (NSData, NSDocument, ... ?)
Thanks you so much! :)
To store a PDF (or really any big data blob):
Use the Core Data "binary" type for the attribute, which corresponds to NSData.
In your Core Data model, turn on "Allows External Storage" for the attribute so that Core Data can store the data outside of the persistent store.
It's often better to just write the PDF to a file, and store the filename in your persistent store instead of the whole file.
Usually for large files, i.e large images or pdf files, what you should save in core data is simply a reference to the file, and store the pdf in NSCachesDirectory or in a permanent directory, depending on your needs.
Hope that helps.

Storing UIImage in Core Data with the new External Storage flag

I know that the storing of UIImage's in core data has been discussed a lot, such as here, but that was pre-ios5. Now that we have the external storage flag, do you guys think it would be a fine idea to store UIImage's directly in the entity, as a separate entity, or still on the disk?
Here is a source explaining the external storage option.
Core Data Release Notes for iOS 5.0
When enabled, Core Data heuristically decides on a per-value basis if
it should save the data directly in the database or store a URI to a
separate file which it manages for you. You cannot query based on the
contents of a binary data property if you use this option.
And from your link External Binary Data, the heuristic seems to be
Objects that are smaller than 1MB are stored in the database. For
objects that are larger, an external file is created and the database
just stores a reference to it.
So the following advice is still valid: CoreData : store images to DB or not?
< 100kb store in the same table as the relevant data
< 1mb store in a separate table attached via a relationship to avoid loading unnecessarily
1mb store on disk and reference it inside of Core Data
The flag sets Core Data to follow that advice and automatically store images >1MB as a separate disk file.

Combining a datastore with Mapkit

Does anyone have any advice on using a datastore with mapkit to provide a database of locations (Restaurants) that are query-able by location?
I would like to use Core data but importing the information into it seems like a project in itself. If anyone has good advice on converting an existing sqlite/cvs file to a coredata sqlite file that would be appreciated.
Is old-fashioned sqlite better than using core data for the task, or is it a case that I should create a web service for the job?
I would like to be able to query the locations based on the map zoom also.
Thanks if you have any advice on the matter.
If you write your object model correctly, you can just point it at an existing sqLite database and it will read it as if core data generated it in the first place.
For example, suppose you have an existing sqlite db of people with columns like firstName, lastName, phone# etc. You just create a core data model with a entity with attributes of firstName, lastName, phone# etc. Spell them the same and make sure they have the right type and then point the NSPersistentStoreCoordinator at the existing database. It will read it in fine.
Core data is always the way to go for any larger data management task. It makes everything so much easier once you learn it.
Edit01:
Never mind the above. I was thinking of Enterprise Objects. Core data won't easily import most existing SQL.
Instead, I would export the sqlite to csv and then use something like cCSVParse to convert to plist. Then you can read it in easily to an array or dictionary and use that to populate the core data db.
That will work easily for db's that don't depend on complex relationships. I think the future benefits of having core data will eventually easily pay for the few man hours spent converting.