beginner database questions

This is a discussion on beginner database questions within the Windows Programming forums, part of the Platform Specific Boards category; Hi, I am working on some new functionality for an app I have been working on over the summer and ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    89

    beginner database questions

    Hi, I am working on some new functionality for an app I have been working on over the summer and I decided to give it the ability to look up items from a database. My problem is I do not know the best way to approach this. Right now I have a very basic solution setup where I have I database class which has a map of Product objects. The database is constructed from a text file each time the program is loaded and is then searchable by name/product number/barcode. It contains 5-10k items and isn't so bad but I am just wondering if there is a more... standard or professional way of handling this. I'm not familiar with databases at all really besides their basic function and a very vague idea of how they work effeciently. The only criteria I really have is that the database can be updated from a text file (I get the file every monday and want to update it then, automatically if possible). Maybe the way I have it setup now is appropriate for what I need, I don't really know. I am just looking for some input/ideas/links which I can start looking into.
    Thanks
    -ac

    edit: Sorry, I forgot to mention I am working in VC++ Express which is why I posted in this forum.

  2. #2
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    University of Waterloo
    Posts
    1,903
    You might be interested in SQLite. If you haven't heard of SQL at all, it's a very popular database language used by a very large number of websites and servers (the alternative tending to be MSSQL). SQLite is a C version of SQL which is a bit toned down feature-wise, but still boasts the same power as SQL itself. The biggest pro of SQLite is that you get to have the power and speed of a database in any C/C++ application you create. The language itself is also very easy to pick up and should have you up and running in no time.

  3. #3
    Registered User Rennor's Avatar
    Join Date
    Aug 2006
    Location
    Finland
    Posts
    45
    A bit of OT.

    jverkoey, thanks for bringin up SQLite. I am relatively proficient with databases, been working with MSSQL, Oracle, postgre, btrieve and MySQL for years now (though never with C/C++). I allways wondered what I am going to do when I need to write application in C/C++ and have "portable"/local database engine with it.

    Maybe I dont need it right away, but I found SQLite highly fascinating project. Now I can sell out my Pervasive and C/C++ DB toolkit books

    Back to Topic

    ac251404, I might not be the guy to help you to incorporate SQLite to your applications but I am sure it's documentation is surely enough to get you started. Feel free to bother me if you need some DB inisght.

  4. #4
    Registered User
    Join Date
    May 2006
    Posts
    89
    thanks for the suggestions. Gonna start reading up on SQLite today and see what I can get going. I'm am pretty positive documentation or not I'll be running into problems so thanks for your offer of help.

  5. #5
    Registered User
    Join Date
    May 2006
    Posts
    89
    Okay so after looking through the documentation a bit I had some thoughts/questions I was wondering if anybody could address.

    - For implementing this within my current VC++ project should I just #include the .DLL and then I will be able to access the API?

    - I think I understand how the callback function works but I am just not sure where in my program it should go. Right now my program has a form, main, 3 datatypes I created (each with a .h/.cpp file) and another class for connecting to a telnet session. Should I place the callback function in my main? Or possibly in my form where I am actually going to be accessing the db?

    - If my database is going to be of "product" datatypes where each product has a name, a product number, and a price (to simplify things) each column would hold one piece of information, name/number/price, and the rows would represent each product? I just want to make sure I am understanding how the data is actually stored so I can picture it in my mind.

    - If I am getting a new text file once a week, do you think the best way to deal with it would be to write a small updater application which maybe compares the last file with the newest file, finds all the removed items and all the added items (thinking of just parsing each file into a set and doing set operations to get the specific products I want) and then makes the appropriate changes to the database, first removing then adding new items. Does this seem like a reasonable approach?

    thanks

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    For simple DB apps (for a MS OS target) I use Access and MFC, connecting to the DB with ODBC.

    Access is slow but is free with Office. I find MFCs CDatabase and CRecordset wrappers are easy to use.

    Visual Studio will derive classes (ODBC consumers) from the DBs tables (or views).
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  7. #7
    Registered User
    Join Date
    Feb 2006
    Posts
    20
    i was just looking through the forum for something to read but damn sqlite looks so fecking intresting

  8. #8
    Registered User
    Join Date
    May 2006
    Posts
    89
    im having fun figuring it out bit by bit. Its really easy to use just looking thru the docs and it ended up being perfect for my application since I can keep the DB on a network drive and my app can then use it from any of the 4 pcs in my office. I even wrote a quick C++ program to load the DB from a space delimited text file and also has the ability to update the database using the old file and a new file. This was necessary because the only information I have to build off of is a 5000 line file of products that I get every monday so now I just run that every monday morning and viola, nice updated product database.

    Only promblems I had were figuring how to get it setup with Dev-C++ and VC++. Dev I got working but not visual yet.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Some beginner questions.
    By Meikj in forum C++ Programming
    Replies: 3
    Last Post: 05-01-2009, 12:37 PM
  2. Total beginner questions
    By Sparky in forum C Programming
    Replies: 5
    Last Post: 06-22-2008, 05:50 AM
  3. several beginner questions...
    By Taikon in forum C Programming
    Replies: 2
    Last Post: 02-09-2005, 09:53 AM
  4. 2 beginner questions
    By GCat in forum C++ Programming
    Replies: 15
    Last Post: 11-24-2004, 03:55 AM
  5. database questions
    By massive_attack in forum C++ Programming
    Replies: 2
    Last Post: 12-16-2001, 08:26 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21