T
T
tiger_132019-09-05 18:35:49
Database
tiger_13, 2019-09-05 18:35:49

How to correctly build a database structure for a program?

I am writing a program - reader. Main page:
5d7128650caac510557777.png
Pages:
The first one is the main one.
The second is favorites.
The third is a global search (via the server).
On the main page, I show popular (also gives the server) and recent (follow the user).
The problem is that I don't know how to correctly build a model for storing data about books, because:
1) I have two related (by the meaning of uicollectionview) on the main page, because if the user selects a book in the PopularCollectionview, and does her favorite, then I want the RecentCollectionView to be updated (if it has such a Cell (Book), and that it also be with an asterisk). How to do it?:
5d7129dc4b415820147260.png
2) I operate with the following arrays: allBooks (if the user views a book from a global search, it will be added to this array, since it should appear in at least recent ones), recentBooks (add recent), favoriteBooks(favorites), popularBooks (get from the server ). It is possible to make one entity in Core Data - allBooks. It will contain the following additional variables:

var isFavorite:Bool = false
var isRecent:Bool = false

But what about the popularBooks that I download from the server? Should I include them in allBooks? Then the elements can be duplicated.
How to build a model? Help me please! Perhaps someone already had experience in building such programs.
PS
Which is better to use Realm or Core Data?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
briahas, 2019-09-05
@tiger_13

I would take Realm. Easier.
It's better to have separate arrays of models - everything, favorites, recent.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question