Wikimedia Apps/Team/iOS/Database Architecture

YapDatabase
We are currently transitioning to YapDatabase. Ann open source key-value store built on top of SQLite.

Data Stores
A WMFDataStore provides access to a specific type of object in the DB. Essentially there is a WMFDataStore subclass for each collection in the database. The current plans are to to have three Data Store classes:

WMFArticleUserDataStore
Used to access WMFArticleUserData which contains user data for a given article including whether an article is in history, saved, black list, last reading position.

WMFFeedDataStore
Used to access WMFFeedSection objects and associated content. A feed section defines a section in the Explore Feed. The associated content is 1 or more search results that are used to populate the section.

WMFArticleContentDataStore
Used to access WMFArticleContent objects which contain the full HTML and metadata about an article. This is the object used to populate the article content in a web view

Propagating Changes
Changes are propagated from the datastore in 2 ways:

WMFDatabaseChangeHandler

MWKItemUpdatedNotification

DataSources
WMFDataSource is a protocol and objects that implement it can power collection views and table views. They manage a view. They are connected to a particular Data Store.

You can call methods for getting row and section data and subscribe to delegate calls to animate updates.

DataSources also implement the WMFDatabaseChangeHandler protocol