Go Premium for a chance to win a PS4. Enter to Win

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 371
  • Last Modified:

Windows application using embedded database

I have a small windows application that I needs to have an embedded database.  The database will maintain static data that will be used during the course of the application's use.  The database cannot be an external SQL server but rather an "embedded" resource installed with the application.  The data can be as large as 3 columns with 45,000 records all varchar.  What would the best case scenerio.
1 Solution
Rahul Goel ITILSenior Consultant - DeloitteCommented:
If you have got this kind of requirement. then I wll ask you to use XML Files as a embedded files in the assembliese


You can use mdb filea and embed that in assembly..and while using it you need to extract to some temp location and use it and delete it
Jaime OlivaresCommented:
this information will require about 0.5 - 1 Mb. This will inflate your application unless you store it compressed.
I think the best option is to save a deflated xml file as an embedded resource. Then inflate it at runtime into memory with an XmlReader or other classes to handle xml.
When you say the database cannot be an external SQL server, do you mean external as in running on a different machine or on the same machine?

You can package and distribute embedded databases such as iAnywhere (SQL Anywhere), SQL Server Compact Edition, SQL Lite, Perst, etc. all as part of your application. This is the most common way I distribute applications with data. However, most of my apps have many tables, not just one.

For a single table of data with 45,000 rows, you can get by with SQL Lite as a free option, it is part of your application, not an "external" server. Most all embedded databases are compiled in as part of the program.

I've also had success packaging a file as a simple fixed width record binary file, and loading in the index at runtime. There is no need to load the whole 45,000 records, you can simply load the key column, then randomly access the data file by index. Have used this technique with drug databases for example with about 80,000 rows.

XML is not the best solution if you want decent performance. If this is on a PC, I agree with loading into memory, but I would use a CSV format packaged with the app and load it completely into a Map or Hash object. Using CSV eases the maintenance of the file, you can use a standard database extract or use a spreadsheet. If it is a PDA or smaller memory device, I would probably not want to load the whole file in memory. Definitely not XML. XML will bloat the data storage, plus it does not solve the problem of random access. XML is not a database driver, it is simply a format. The advantage to using an embedded database is that it is stored in a B-Tree indexed format so there is no memory overhead at all.

Éric MoreauSenior .Net ConsultantCommented:
I would use http://www.microsoft.com/Sqlserver/2005/en/us/compact.aspx. Only 2 DLLs to copy with your application (no installation of SQL is required).

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Tackle projects and never again get stuck behind a technical roadblock.
Join Now