简体   繁体   中英

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.

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

How keyword is represent inside database

With TEXT field containing "one two three"

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM