简体   繁体   中英

is it possible to use more than one SQLite files in CoreData?

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.

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM