Venkat Chalapathi
Venkat Chalapathi

Reputation: 53

How to use Android Room to store data records

I want to store team information in an Android Room database. The information contains team name, players, batting, fielding, and bowling statistics.

These are my requirements:

Can anyone please give me suggestions to fulfill these requirements?

Upvotes: 0

Views: 84

Answers (1)

qwerty qwerty
qwerty qwerty

Reputation: 26

I can suggest you to store team names & players into separate tables with its primary and foreign keys, respectively, in order to make relation between them. After all, if you need to fetch stored data, you can join tables, or get by team name (if it is primary key) or anything else.

You can read more about @Relation here: https://developer.android.com/reference/android/arch/persistence/room/Relation

Relation can help you handle one-to-many, many-to-many states.

Note: do all tasks in background thread with the help of Rx/Coroutines.

Upvotes: 1

Related Questions