问题
I am developing an events storing app where each event has its guest list. I am new to android and also sqlite so any help would be greatly appreciated.
e.g in C language it would be
struct event{
int ID;
String eventName;
String place,date,comments,venue;
// guest[] myGuestList; (i can not achieve this goal)
}
struct guest{
String guestName;
String guestContact;
String guestEmail;
}
this is somewhat my requirement in the Android app im developing. So far I have achieved creating a SQLite database which maintains a table of events. How do I add a guestList to each of my events in my SQLite database? What is the best design for my requirement?
回答1:
Depends if same guest can be included in multiple events.
If yes, you would need three tables, one for events, one for guests. The third table will link guestID to EventID, one row per guest per event.
If no, you can skip the third table, and add the eventID directly to the guest table.
This is a common SQL setup, and you should to a little SQL research before you continue.
来源:https://stackoverflow.com/questions/38559909/how-do-i-use-struct-arrays-or-similar-data-structures-in-android-sqlite