如何在Android / SQLite中使用struct数组或类似的数据结构?

编程入门 行业动态 更新时间:2024-10-25 18:26:11
本文介绍了如何在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数组或类似的数据结构?

本文发布于:2023-10-14 22:41:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1492422.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据结构   数组   类似   如何在   struct

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!