Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
246 views
in Technique[技术] by (71.8m points)

android room - How to design database schema for a tracking app?

I am trying to make a tracking app.

For each subject I want to track, there are several parameters, for example: Sub1 has several params P1, P2, P3. These parameters change over time (this is why I want to track them). The app allows tracking of several subjects: Sub1, Sub2, Sub3...SubN and they all have the same set of parameters.

One approach is to create a table for each subject, with each parameter is a column. This way the table for Sub1 might have 4 columns like this: Day, P1, P2, P3.

There is one problem with this approach: If I were to use Room, I would have to predefine all the subjects I want to track, and create all the tables for them beforehand. Which mean I can't allow the user of the app to easily add new subjects to track in the future, because each time a new subject is added, then a new table must be created for it, which means a change in Room database schema, which requires database migration...

Is there a more flexible approach which allows the user to add new subjects to track, without the need to perform database migration?

question from:https://stackoverflow.com/questions/65953084/how-to-design-database-schema-for-a-tracking-app

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...