Access数据库中关键字相似搜索的一种最佳方法 [英] An optimal way of keyword similar search on Access Database

查看:401
本文介绍了Access数据库中关键字相似搜索的一种最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我有一个包含28个字段的数据库(访问),每个字段由2个部分组成,并由一个特殊的字符串(即* H *)分隔
exp:约翰Q * H *塞缪尔"

我想在此数据库上搜索任何类似的条目X. X可以是整个数据库的28个字段中的第1部分还是第2部分.

我使用了下面的简单代码

Hey guys ,
I have a database (access) with 28 fields, each field consists of 2 parts separated by an special string (i.e. *H*)
exp : " John Q *H* Samuel "

I want to search for any similar entry X on this database. X can be whether the 1st part or 2nd part of any of the 28 fields of whole database.

I used the simple code below

DamerauLevensteinMetric DLM = new DamerauLevensteinMetric();
List<int> Item_arrays_2_show = new List<int>();
 
for (int i = 0; i < Database.Rows.Count; i++)
{
   for (int j = 0; j <= 28; j++)
      {
         string[] t = Seperate(Database.Rows[i].ItemArray[j].ToString(), "*H*");
 
         if (DLM.GetDistance(t[0],textbox.Text) < 10 ||
         DLM.GetDistance(t[1], textbox.Text) < 10)
            Item_arrays_2_show.Add(i);
      }
}



但正如您注意到的那样,该算法的复杂度为O(Database.Rows.Count ^(28 * 2))
如果我们假设DamerauLevensteinMetric函数的运行时间为1

如果数据库有1,000条记录,那么可以想象,需要多长时间才能找到匹配项!



but as you notice the complexity of this algorithm is O(Database.Rows.Count ^ (28 * 2))
if we suppose that the running time of DamerauLevensteinMetric function is 1

if the database has 1,000 records its imaginable that What a LONG time is needed to find matches !!

Is there any optimal way of doing this ?

推荐答案

首先想到的是:
1.为什么将值存储在列中.为了有效地搜索数据,它们应该放在行中
2.不应将不同的值连接到单个列中.在这种情况下使用两列会更有效.

您可以使用以下内容搜索数据:
First things that come in mind are:
1. Why do you store the values in columns. To efficiently search the data they should be on rows
2. Different values shouldn''t be concatenated into a single column. Using two columns in this case would be much more efficient.

You could possibly search for the data with something like:
... Field LIKE 'SomeValue *H*%'
OR  Field LIKE ' %*H* SomeValue'
...


但这似乎相当荒唐……


But that seems quite ackward...


感谢您的答复,

1-这些值属于某些产品,它们是产品的规格.实际上在一行中,我有65个字段,其中28个字段保留了此搜索所需的信息.

2-存储在这28个字段中的值不是2个不同的值,实际上只是一个值,但是我的搜索关键字可以位于这两个部分中.

3-使用LIKE,我也许可以将字段中的两个部分分开,但是我可能无法搜索任何相似之处
假设我的一个字段的值是:肖恩·鲍尔* H *安东尼·伊斯特伍德"
我想搜索说安东尼!
如果我使用LIKE,则当我的搜索键是Antoni时将无法找到Anthony
Thanks for response,

1- the values belong to some product, and they are the specifications of the product. actually on one row, I have 65 fields, which 28 of them keeps the info needed for this search.

2- Values stored in those 28 fields are not 2 different values, actually only one value, but my search key can be in either parts.

3- using LIKE I might be able to separate the two parts in a field, but I might not be able to search for any similarities
suppose the value on one of my field be : " Sean Bower *H* Anthony Eastwood "
I wana do search for say Antoni !!
if I use LIKE, I will not be able to find Anthony while my search key is Antoni


这篇关于Access数据库中关键字相似搜索的一种最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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