Solved

Windows application using embedded database

Posted on 2009-07-05
4
359 Views
Last Modified: 2013-12-17
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.
0
Comment
Question by:andy_ee
4 Comments
 
LVL 9

Expert Comment

by:Rahul Goel
Comment Utility
If you have got this kind of requirement. then I wll ask you to use XML Files as a embedded files in the assembliese

Or

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
0
 
LVL 55

Expert Comment

by:Jaime Olivares
Comment Utility
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.
0
 
LVL 40

Accepted Solution

by:
mrjoltcola earned 500 total points
Comment Utility
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.

0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
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).
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now