views:

59

answers:

0

My iPhone application is using a SQLite database with the following schema:

  • items(id, name, ...) -> this table contains 50 records
  • tags(id, name) -> this table contains 50 records
  • item_tags(id, item_id, tag_id, user_id)
  • similarities(id, item1_id, item2_id, score)

The items, tags, item_tags and similarities tables are populated with pre-defined records, hence also the similarities between different items have already been calculated offline (using cosine similarity algorithm based on the items' tags).

Users are able to add additional tags to items and to remove their custom tags later on. Whenever this happens the similarity scores between the items should be updated locally, i.e. without contacting the server application.

My question now is the following: What is the most efficient way to do so? So far, on startup of the iPhone application, I compute a term-document matrix for all the items and tags (which reflects the tag frequencies for each item) and keep this matrix in memory as long as the application is running. Whenever a tag is added or removed, I use this matrix to update the similarities in the database. However, this is rather inefficient. Do you have any suggestions?

Thanks!