This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Simple database engine?

Hallo

Do somebody know of a simpel, small database engine for C??

This is the scenario:

Car information (Make, model name, year etc) are presented in a Excel spread sheet. The information is text based.
The same information is then put onto the targets data flash (Either as raw text, binary or other format).
The car information is presented to the user in a sorted manner, depending on the user selection. (so it must be sorted run time)

So the idea was to either pre-generate a database file, that is flashed to the data flash. A database engine are then using this file, for getting the needed information to the GUI.

Or the car information are flashed to the data flash as a simpel text/binary file. The data are then read by the application. All sorting and string formating is done by the application.

As for know the car information is around 46 kBytes. I do have 8 MB flash and 16 MB RAM so no problem having space for it.

I use a LPC2478.

I have SQLite in mind, but is it overkill for the task ??

Any one know SQLite??

/Thomas

  • Databases are good for doing _operations_ on data.

    You don't mention anything about adding/changing any data in your device. And you only seem to have a single table, so you obviously don't seem to need any relational operations where you perform any join between multiple tables.

    Then it is probably simplest to have:

    typedef struct {
        int field1;
        char field2[20];
        char field3[10];
    } rec_t;
    
    rec_t my_data[] = {
        {17,"hello","there"},
        {30,"benny","drunk"},
        {9,"late","night"}};
    unsigned sort1[] = {2,0,1};
    unsigned sort2[] = {1,0,2};
    unsigned sort3[] = {1,2,0};
    


    Then you can browse the data sorted using the lookup tables sort1, sort2, sort3 as you want.

    And you can use bsearch on a sortx[] array to locate an entry in log2 n attempts if you have n entries.

    If you have the time, and don't want to precomute multiple sort arrays to index the data, you can just use qsort() to sort the entries before letting the user browsing them. Running qsort() on an array of just integers mapping to the real entries means you don't need to copy any actual data - so the table data can be kept in flash all the time and one table of n integers (+ stack space for qsort) are your RAM requirements.

  • I have SQLite in mind, but is it overkill for the task ??;

    Only about as much as using a 5 pound sledgehammer to squash a mosquito would be. ;-) For the job at hand, you don't need a database engine at all, much less a relational DBMS toting SQL.

    For the amount of data you're looking at, your controller can quite probably go through the entire dataset before the human user notices that you're using any time at all. I.e. there's not even a strict necessity to precompute anything.