如何在Android / SQLite中使用struct数组或类似的数据结构? [英] How do I use struct arrays or similar data structures in Android/SQLite?

查看:137
本文介绍了如何在Android / SQLite中使用struct数组或类似的数据结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个事件存储应用程序,其中每个事件都有其来宾列表。我是Android的新手,也是sqlite,所以任何帮助将不胜感激。

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.

例如
在C语言中将是

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;
}

这有点是我在Android应用程序开发中的要求。
到目前为止,我已经创建了一个维护一个事件表的SQLite数据库。如何在我的SQLite数据库中的每个事件中添加一个guestList?
根据我的要求,最好的设计是什么?

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?

推荐答案

取决于同一个客人是否可以包含在多个事件中。
如果是,您需要三个表,一个用于事件,一个用于客户。第三个表格将guestID连接到EventID,每个客户每个事件一行。

如果不是,您可以跳过第三个表,并将eventID直接添加到访客表。

这是一个常见的SQL设置,您应该继续进行一些SQL研究。

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.

这篇关于如何在Android / SQLite中使用struct数组或类似的数据结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆