简体   繁体   中英

Cleaning up Database entries

On an App v1.0 I gave the user the possibility to add data on a database, only an attribute at a time. As examaple lets say that the user can add a person name and his/her surname. Later on, let´s say he/she adds the age. The database would look like this:

在此处输入图片说明

(where the attibute ´Name´ is unique)

I´m going to update the code so that before saving another attribute (say ´alias´), it will chech whether the name has already been used. If it is, it will add the alias in the same entry and if not, it will create a new one.

What I´d also like to do is to clean up the database. In this example it would merge entries #1 and #2, to get something like:

在此处输入图片说明

(former entry #2 would be deleted).

I seem to remember that there was an automatic way to do that, but I´m not sure if I´ve immagined it or it was somewhere else such as MS Access because I cannot find it again.

So, is there a way to do that automatically or should I explore a programatically approach?

 NSError *err = nil;
 NSUInteger count = [managedObjectContext countForFetchRequest:request error:&err];
 [request release];
 if (!err)
 {
   return count;
 }
  else
   return 0;

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