views:

32

answers:

1

Hello fellow stackoverflow family members?

I know it is un-efficient to create one extra sqlite table in iPhone CoreData system. (X)

Currently, My app has one sqlite table but there are preset data to users to no need to waste parse time. But if I adding new entity in current structure of SQLite table, it wipes up the whole preset data. I haven't tried to use immigrate method but I don't think it wouldn't be just adding a new entity on the table. I'm thinking it also wipes up previous preset data.

Current Architecture of SQLite file.

  • entity : A
  • attributes : contains data

I want to keep A with attributes still contain data but also add new entity : B.

entity : A

attributes : previous contained data

(PLUS+)

entity : B

attributes : new data

Do I need to create extra persistence set to separately store entity B (create another SQLite file and use as storage) or Is there possible way to add entity B in current SQLite with no changes in entity A?

Thank you.

+1  A: 

To directly answer your question: Yes, you can reference multiple SQLite files in Core Data. You'll want to use a unique persistent store for each one.

I don't understand the rest of your question though, so it may be likely that creating multiple persistent stores is not what you want at all.

I know it is in efficient to create one extra sqlite table in iPhone CoreData system.

This is untrue. Creating multiple entities (aka, tables, but that is abstracted away) can lead to much more efficient queries.

Currently, My app has one sqlite table but there is no need to change preset sqlite table but want to add some other attribute.

Just add the attribute to your entity. If your app has already been released or you want to maintain existing data, you'll have to set up a migration and/or turn on lightweight migration.

So commit with new attribute and update coredata is not valid. Because it flash off current data set and need to spend another hours to type manually.

This didn't make any sense to me. Can you clarify?

kubi
What I tried to add extra entity was launch the UIAlertView for rate my app and records on the entity depends on condition. The condition is: 1> if user has not pressed okay button then ask for every i%7==0 days 2> if they did already pressed okay button, then ignore.
Yoon Lee
Current Table contains data that I don't want to get erase or re-parsing due to the inputted manually. Do you think Apple's immigration method should work? I'm confused..
Yoon Lee
Yes, definitely. Follow the migration link included in my answer. This allows you to add/remove entities and attributes without losing the data you already have in your store. This is only tangentially related to your question, but I'd advise finding a way to automatically load your data. Manually inputting data into an iPhone app is a huge pain and being able to wipe your database and start over again is incredibly useful.
kubi