Dec 13 | 8:50 AM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Dec 13 | 8:55 AM |
Ahmad M. | has entered the room |
Dec 13 | 9:00 AM |
Ahmad M. |
hi Mr.Mark i have question about Room Database
|
Mark M. |
hi! go right ahead!
|
Ahmad M. |
View paste
(33 more lines)
|
Ahmad M. |
View paste
(6 more lines)
|
Dec 13 | 9:05 AM |
Ahmad M. |
the user may chose one type of repeat types
|
Ahmad M. |
i want to store one of different types of Repeat types
|
Ahmad M. |
View paste
(10 more lines)
|
Ahmad M. |
those my repeating types how i build database for this
|
Mark M. |
you seem to have a field for this int value in Repeat
|
Dec 13 | 9:10 AM |
Mark M. |
I do not know where Repeat belongs with respect to the rest of your database -- perhaps it should be an @Embedded field on TodoModel
|
Ahmad M. |
yes , but i think Repeat should belongs for Todos with Reminder
|
Ahmad M. |
if Todo has Reminder it may has Repeat also
|
Mark M. |
OK, so, perhaps there should be an @Embedded Repeat field on Reminder, then
|
Ahmad M. |
i do not know if the user want his Todo with Repeat in Monthly or Weekly ..
|
Mark M. |
personally, I usually think of the to-do item as being what repeats, not the reminder
|
Ahmad M. |
i want to create for Example a WeeklyModel at runTime
|
Mark M. |
regardless, somewhere, you will need to ask the user what repeat interval the user wants for this particular to-do or reminder
|
Dec 13 | 9:15 AM |
Mark M. |
so, either design the data model that you want, then create a UI that matches the data model, or mock up the UI that you want, then create a data model that reflects that UI
|
Ahmad M. |
i aready creat The UI
|
Mark M. |
OK, so, where are you asking the user for the repeat interval?
|
Ahmad M. |
pleas minute
|
Dec 13 | 9:20 AM |
Ahmad M. | |
Mark M. |
from this, it would appear that TodoModel should hold the Repeat data
|
Ahmad M. | |
Ahmad M. |
this when prees Weekly
|
Mark M. |
this screen, though, illustrates a more complex rule than what your Repeat class can support
|
Mark M. |
a collection of Repeat objects might be able to represent this rule
|
Ahmad M. |
yes that i come for (:
|
Mark M. |
if you think that will work, then there would be some separate table for the Repeat data, and a 1:N relationship between TodoModel and that Repeat entity
|
Mark M. |
you would set that up to be similar to how you have a relationship between TodoList(?) and TodoModel, using a @ForeignKey
|
Ahmad M. |
yes i haf that
|
Ahmad M. |
View paste
(11 more lines)
|
Ahmad M. |
this the list entity
|
Mark M. |
so, just as listOfTodo has a relation to TodoModel, TodoModel would have a relation to Repeat
|
Dec 13 | 9:25 AM |
Ahmad M. |
but the query going to be hard
|
Mark M. |
your Repeat class would have a todoModelId field that you use for the relation
|
Mark M. |
your DAO would have a @Query that can return the List<Repeat> for a given TodoModel's ID
|
Dec 13 | 9:30 AM |
Ahmad M. |
ok how i suppose to set the relation between Todomodel and Repeat as foreiginKey
|
Ahmad M. |
??
|
Mark M. |
View paste
|
Mark M. |
(off the cuff -- it has been a couple of months since I wrote a @ForeignKey)
|
Mark M. |
Repeat would need an @Entity annotation, and you would need to add a @PrimaryKey column (here referred to as uniqueRepeatId, to match your existing naming convention)
|
Mark M. |
so, just as you have tables for the lists and for the todos, you would have a table for the repeat rules
|
Dec 13 | 9:35 AM |
Ahmad M. |
all my problems is in how to design Databaes
|
Ahmad M. |
thank you so much for your help
|
Mark M. |
you're welcome!
|
Dec 13 | 10:00 AM |
Mark M. |
OK, that is a wrap for today's caht
|
Mark M. |
er, chat
|
Mark M. |
the next chat is Saturday at 4pm US Eastern
|
Mark M. |
the transcript for today's chat will be posted on https://commonsware.com/office-hours/ shortly
|
Mark M. |
have a pleasant day!
|
Ahmad M. | has left the room |
Mark M. | turned off guest access |