I'me developing an iOS chat application and working on the db design for the contacts feature. There are 2 kinds of contacts-

  1. Unsaved Contacts - Contacts with who you've conversed with, but not saved as a contact
  2. Saved contacts - Contacts saved by the user. These are synced with the server as well. Saved contacts can fall under different "groups". Whenever the contact list is synced with the server, the local list needs to be updated as well (contacts no longer in the results need to be removed from saved contacts, new contacts need to be saved, etc.)

There's really not much of a difference between #1 and #2 (for now). So I had 2 approaches for the db design- 1. Have just one table for contacts, with an extra boolean column - isMyContact which is true for saved contacts. 2. Have a different table for saved contacts. This just references the other table on a key unique to every contact (an id or a url)

Which approach would be a better design decision? P.S- I'm using Sqlite.

  • This could be useful for you. – Alternatex Mar 28 '16 at 7:10
  • #1 will be a bitch to query and otherwise deal with, over time, within in the larger context of the entire application. #2 is a cross-reference table, easy to maintain and fast in a join because all it is a matched pair of indexed keys - user ids, and contact ids. – radarbob Apr 1 '16 at 1:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.