在这种情况下如何设置关键字?

How do I setup keywords in this case?

我正在制作一个数据库,用于保存图纸/文件/注释或指向这些项目的链接。然后我正在制作一个程序,让用户输入一个关键字,它会为他们提供指向图纸/文件/或注释的链接。但我不确定如何存储所有关键字并仍然足够快地工作。

Example Table Main
ID  Area  Type  Specific  File  Keywords
1   RX1    icc   tester   ..    Lock, SG1, Va2, CN1, CN2, SGP, Vu, Boof
2   RX1    ECU   tester   ..    SG1 , BA3, yys, yyz, yyx, Lock
3   RX3    ECU   Control  ..    SG2, SG3, VA2, YYS
etc.... 

因此,用户会 select 区域,然后输入具体内容,然后输入关键字以获取结果。大约有 10,000 行。关键字可以是 1 到 200 之间的任意值。

其次,这可以在 MS Access 数据库中完成吗?我知道 Access 有限制,但这是我已经安装并习惯使用的功能。

不要将关键词放在主table中。相反,为多对多关系保留一个关键字 table 和一个 fileToKeyword table。 那么你的每件商品的关键词数量就没有限制了。

此 table 的主键应该是两列(fileId、keywordId)并且您的搜索将是 3-table 连接。

I answered a similar question yesterday

Table 根据您在评论中的要求提供的示例:

Table Main
----------
ID  Area  Type  Specific  File
1   RX1    icc   tester   ..
2   RX1    ECU   tester   ..
3   RX3    ECU   Control  .. 

Table Keywords
--------------
Keyword_Id  Keyword_Text
1           Lock
2           SG1
3           Va2
4           CN1
5           CN2
6           SGP

Table FileToKeyword
-------------------
FileId   KeywordId
1        1
1        2
1        3
1        4
1        5
1        6
2        1
2        3

备注:
在关键字 table

  • Keyword_Id是主键
  • Keyword_Text 是独一无二的

在 FileToKeyword 中 table

  • FileId 是 table main
  • 的外键
  • KeywordId 是 table 个关键字的外键
  • 两列的组合为主键

您的 select 应如下所示:

SELECT ID, Area, Type, Specific, File
FROM Main
INNER JOIN FileToKeyword ON(ID = FileId)
INNER JOIN Keywords ON(KeywordId = Keyword_Id)
WHERE Keyword_Text IN('Lock', 'SG1')
AND Area = 'RX1'
-- any other conditions you might want to add