I have an existing program in C#.NET that uses a 2d dictionary for saving attributes as the program progresses. The outer dictionary is of type (string, dictionary) and the inner is (string, string) (basically the outer dictionary contains sections like summary, warnings, etc; and the inner dictionaries are the actual data).

Currently, it uses an .ini format with the general format as follows:


Name = john

Data = 2019/07/13


Problem is:

(1) somebody can edit the file directly and corrupt it

(2) if we let user edit the file, must be facilitated through the program and validated

(3) multiple apps use the same file and add different bits of info, and there are sometimes discrepancies between the two files, which must be centralized

So naturally, an embedded database comes to mind. I tried to fit SQLite with it, but I am not very good with SQL and didn't feel like it was appropriate with a key-value pair, and the headings as described.

I also looking into some No-SQL options, which seem better fitting for a dictionary, however some of them looked a touch unreliable w.r.t. support and long-lastingness (this system should be able to work for many years to come).

Something I also looked at is XML and JSON (both fairly similar) which probably seem like my best option, but 2 problems:

(1) Editable directly at the file level just as the .ini file was (maybe encrypt it or something?)

(2)I would ideally like for the database to know of all potential fields but only require a few main ones like name, date etc so that any attempts to save a file with unrecognized fields gets an error thrown. There are 300+ potential attributes that could be saved, and the aforementioned problem has occurred in the past.

Any advice please and thank you code gods of StackExchange?

P.S. sorry for the short essay here, I just wanted to outline the problem sufficiently

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.