Wolfish
Wolfish

Reputation: 970

Replicating the style and function of a database on local, micro scale

The process of setting up a database server is far too complicated for my programs needs, not to mention expensive, and I wish to use local files as a stopgap measure until our webapp can be deployed.

I'd ideally like to use three files - one for the item database with the primary key, one for upcoming conditions, and one for archived conditions. Using a text file would be time and memory consuming, however I am intrigued by the usage of XML. Is this something XML can do? Or, should I look at some sort of simple table (consequently, is there a table as such)?

Upvotes: 0

Views: 35

Answers (2)

Kjartan
Kjartan

Reputation: 19141

First of all: I'm not sure why you would think XML might be a good alternative if you think a text-file would be too time- and memory-consuming (xml is text based, after all).

Anyway, another option might be to simply create your needed structure (or structures) in C# as one or more objects, and serialize these to a file. For instance, you might create three dictionary-objects to contain the data you mention, then include all of these as members in a data container class.

Now you can serialize an instance of this class to a file. Check for the existence of such a file, or create a new instance if needed next time you run the program.

As long as this is only used within your own application, this aught to work well enough.

Update: Serializing an object basically means that the data contained in a .Net object is converted into a format which can be stored on a drive, for example. You can serialize to various formats - including "plain text", and XML. When an object has been saved this way, you may be able to open the file in a text editor and see and understand the basic structure. You can retrieve and recreate a stored object by deserializing such a file.

Example result from a quick search: Serialize an object to string

Upvotes: 1

ram hemasri
ram hemasri

Reputation: 1634

Its better to use SQLite or LocalDB.

Upvotes: 0

Related Questions