简体   繁体   English

什么是将关键字存储在数据库中,与语言无关的最佳方法

[英]what is the best approach to store keywords inside database, language agnostic

My question title is self explanatory. 我的问题标题是不言自明的。

I'm aware that there is no exact answer on this subject cause it depends on many subjects but if you have time to share ideas and thought on how would you collect keywords, store them into db. 我知道此主题尚无确切答案,因为它取决于许多主题,但是如果您有时间分享想法并考虑如何收集关键字,请将其存储到数据库中。 Pseudo code would be just fine, or plain english. 伪代码就可以了,或者是简单的英语。

Here's what I'm thinking 这就是我的想法

Collecting keywords from the user 从用户收集关键字

User enters using some form (web or desktop) and sends them to the database. 用户使用某种形式(Web或桌面)输入并将其发送到数据库。

txtKeyword1 = "one"; txtKeyword2 = "two"; txtKeyword3= "three";

How keyword is represent inside database 关键字如何在数据库中表示

With TEXT field containing "one two three" 包含"one two three" TEXT字段

Problem With using this approach I'm coming to the problem when I want to display keywords separated one from another. 问题使用这种方法时,当我要显示彼此分开的关键字时遇到了问题。 I was thinking to separate each word with ','(comma) but what if keyword has more than one word? 我当时想用','(逗号)分隔每个单词,但是如果关键字有多个单词怎么办?

Should I use one more property inside viewmodel to represent separated keywords as List<string>Keywords property (once I come with solution how to separate them) or I should store this property directly inside domain object. 我应该在viewmodel中使用另一个属性来表示单独的关键字作为List<string>Keywords属性(一旦我提供了如何将它们分开的解决方案),或者应该将该属性直接存储在域对象中。

Please share you're thoughts. 请分享您的想法。

Thank you 谢谢

Please ask if you need more information. 请询问您是否需要更多信息。

It sounds like you want to have a one-to-many relationship of records and keywords. 听起来您想与记录和关键字建立一对多的关系。 Best achieved by using three tables: 使用三个表可以达到最佳效果:

The first table should have the records, and no reference to the keywords. 第一个表应该有记录,并且没有对关键字的引用。

The second table should be just single individual keywords. 第二个表应该只是单个单独的关键字。

The final table is a lookup table. 最终表是一个查找表。 For each keyword that a record has, this table has an entry for the index of the keyword and an index of the keyword. 对于记录所具有的每个关键字,此表均具有关键字索引和关键字索引的条目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在服务器应用程序中存储配置信息的最佳方法是什么? (没有数据库) - What is the best approach to store configuration info in a server application? (No database) 动态创建UI和数据库,最好的方法是什么? - Creating UI and database dynamically, what is the best approach? 轮询数据库时最好的方法是什么? - What is the best approach while polling database? 什么是缓存数据库查询的最佳方法 - What is the best approach for caching database queries Windows Store App的登录屏幕-最好的方法是什么? - Login Screen for Windows Store App - What would be the best approach? 在数据库中存储货币价值的最佳方式是什么? - What is the best way to store a money value in the database? 存储和检索文件的最佳方法? - Best approach to store and retrieve files? 将有限数量的项目存储在数据库(不可知)C#中以获取代码 - Store a limited number of items in database(agnostic) C# for code 什么是自动增量的最佳方法 - What is Best Approach for Auto Increament SerialPort 上多线程的最佳方法是什么 - What is a best approach for multithreading on SerialPort
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM