使用 SqlCe 创建电子邮件数据库并为其建立索引

发布于 2024-09-01 18:23:36 字数 497 浏览 2 评论 0原文

我正在创建一个简单的电子邮件客户端程序。我使用 MS SqlCe 作为电子邮件存储。用于存储消息的数据库架构如下:

StorageId int IDENTITY NOT NULL PRIMARY KEY,
FolderName nvarchar(255) NOT NULL,
MessageId nvarchar(3999) NOT NULL,
MessageDate datetime NOT NULL,
StorageData ntext NULL

在 StorageData 字段中,我将把 MIME 消息存储为字节数组。但是当我要对存储的消息进行搜索时,问题就出现了。我不知道如何在此架构之上索引消息。

谁能帮我建议一个好的但简单的模式,以便它在存储空间和搜索友好性方面也有效?

问候,

Anindya Chatterjee

I am creating a simple email client program. I am using MS SqlCe as a storage of emails. The database schema for storing the message is as follows:

StorageId int IDENTITY NOT NULL PRIMARY KEY,
FolderName nvarchar(255) NOT NULL,
MessageId nvarchar(3999) NOT NULL,
MessageDate datetime NOT NULL,
StorageData ntext NULL

In the StorageData field I am going to store the MIME message as byte array. But the problem arises when I am going to implement search on the stored messages. I have no idea how I am going to index the messages on top of this schema.

Can anyone please help me in suggesting a good but simple schema, so that it will be effective in terms of storage space and search friendliness as well?

Regards,

Anindya Chatterjee

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

著墨染雨君画夕 2024-09-08 18:23:36

一些注释,恐怕不太有帮助:

  • 我相信 rfc5322 将电子邮件中任何单独行的长度限制为 999 个字符。虽然可以将标头字段扩展到多行,但在我看来,这是消息 ID 长度的合理上限。
  • SQL CE 不支持全文搜索,因此基本上您必须编写自己的搜索引擎。将文本切成单词,然后创建一个单词表,并与一个包含它们链接到的 StorageId 字段列表的字段配对。相当多的工作,并且您可能最好使用第三方解决方案
  • 考虑添加一个“父”字段,该字段根据消息 ID 和 In-Reply-To/References 标头将线程链接在一起。

Some notes, not too helpful, I'm afraid:

  • I believe rfc5322 limits the length of any individual line in an email message to 999 characters. While it is possible to extend a header field over multiple lines, it seems to me it's a reasonable upper bound for the length of a message-id.
  • SQL CE doesn't support full-text search, so basically you'll have to write your own search engine. Chop the text up into words, then create a table of words, paired with a field containing a list of the StorageId fields they link to. Quite a bit of work, and you're probably better off with a third-party solution
  • Consider adding a "parent" field that links threads together based on their message-ids and In-Reply-To/References headers.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文