Marco
Marco

Reputation: 1025

How is the difference between database and a 2D matrix?

I am creating a Visual basic program which will handle 100k strings. Yes! "100K". Each string is a sentence long. I need to make sure a search function in my program is reasonably fast. The search function returns all strings in the memory that contain a search keyword.

I am new to VB. My question is whether I should use database (No experience) or I should use 2D string array? What would be advantages and disadvantages of each method?

Upvotes: 0

Views: 143

Answers (1)

Alexei Levenkov
Alexei Levenkov

Reputation: 100620

If you need many searches just build map of all encountered words to list of sentences (i.e. Dictionary<string, List<int>> where int is index of a sentence).

You may be able to compress sentence representation by representing it as list of words (may use String.Intern, to avoid duplicate copies of the same word in memory) if you are too worried about memory usage.

Upvotes: 1

Related Questions