lundi 28 décembre 2015

What is the most efficient way of persisting lists?

I am creating an Android application that allows the user to create different lists of friends. For each list, the items have a name and 2 parameters...

EXAMPLE

List 1: (Steve, param 1, param 2), (Lisa, param 1, param 2)... etc

List 2: (John, param 1, param 2), (Steve, param 1, param 2)... etc ...

What is the best way of dynamically persisting all these lists created by the user?

I was thinking about using SQLite since it is quite easy to implement.

I also though about working with plain JSON files, but this approach seemed too resource consuming, because the application deals with adding, reading, modifying stuff...

So, what is the best way of persisting these objects?

If I use a database, I thought it should have the following scheme:

PERSONS - columns: Person_ID, Person_Name

LISTS - columns: list

For LISTS, each row is just formed by some sort of set of tuples, representing a single list.

EXAMPLE

Row 1: [(Person_ID, param1, param2), (Person_ID, param1, param2), ...]

Where Row 1 is a single list with all the people contained in it.

Unfortunately this doesn't seem very efficient....

I also thought about creating an extra table

LIST_ROW - columns: row_id, Person_ID, param1, param2

and then each row in the LISTS table would just be a tuple of IDs for all the rows that belong to that list...

EXAMPLE

Row 1 would just become: (row_id, row_id....) representing the elements in the list 1.

Unfortunately, I am not sure on how efficient this is.

Can someone tell me what is the best way of achieving this?

Aucun commentaire:

Enregistrer un commentaire