0

I'm new to objective c and core data. I am making an iOS app kind of like a flash card app. I have a core data set up with an EnglishWord entity in a many to one relationship with ForeignWord entities (different languages).

For each ForeignWord entity I want to keep track of certain metadata: how many times I have viewed the word, the dates I viewed it, a score I give it, etc. Ideally would be if I could have an array/dictionary as an attribute within the ForeignWord managed object itself. This is not possible.

The only option I can think of is to create a new entity called 'Score', with each ForeignWord entity 'owning' many Score managed objects (one to many), a new 'Score' managed object being created every time I view the foreignWord.

However, this sounds very messy. If I have 1000 words then I would have 1000 different tables in the sqlite database, one for each card.. does that slow things down? is it bad to have 1000 different tables?

is this really the way to do it? Is there a more elegant solution? Thanks!

4

2 回答 2

1

您可能会考虑添加一个名为“查看”之类的表,该表与 EnglishWord 和 ForeignWord 都有关系(到 1)。然后,您可以在此表中跟踪您感兴趣的元数据并汇总此表中的数据,以确定您查看特定单词的次数,是否正确识别它等。

于 2013-09-05T16:47:29.737 回答
0

我会创建一个名为 ViewEntry 或其他东西的新表,并将关系链接到您的两个单词表。这样,当查看一个单词时,您可以存储您想要的任何元信息,并拥有指向英语和外国版本的活动链接。像这样的东西:

在此处输入图像描述

这样,您可以创建一个新的 ViewEntry,将其foreignVersionword属性设置为英语和外语单词,设置日期、分数和总回答时间(以及您想要的任何其他内容)。然后你可以做一些非常好的查询来提取有用的信息。

  • 给我所有分数低于50%的英文单词“school”的外文版本。

  • 我想要用户尝试俄语翻译“house”和相关分数的所有时间。

  • 哪些英语单词得分最差/最好?

  • 什么是最多/最少的英语(或外语)单词?

所有这一切都将相对容易,因为英文单词可以访问它被查看的所有时间,并且任何英文版本的任何外国版本都可以这样做。您还可以访问分数和查看日期,并从该数据中提取所有英文/外文版本。

您也不需要创建 1000 个表 :)

于 2013-09-05T16:57:09.830 回答