Embedding Database Programming C++

This is a discussion on Embedding Database Programming C++ within the C++ Programming forums, part of the General Programming Boards category; Dear all, A significant portion of computer programmes today work with large amounts of data. A language such as C++ ...

  1. #1
    Registered User Vespasian's Avatar
    Join Date
    Aug 2011
    Posts
    181

    Embedding Database Programming C++

    Dear all,

    A significant portion of computer programmes today work with large amounts of data. A language such as C++ can build powerful applications but cannot efficiently define database structures and is poor at generating adhoc queries. On the contrary, a language such as SQL is very good at defining structures of databases and generating adhoc queries but cannot build sophisticated database applications or any applications.

    My questions are as follows:

    1) I often find myself wanting to access the, say, fourth element of the 10th row of a flat table called X. In C++ I would traditionally access these elements by opening the database in a tab delimited text file and counting the new lines and tabs to reach to the desired column/row element.
    I do not take pride in this method as it is too low level, cumbersome, unsophisticated and lacks the high level power to do complicated queries.
    Would this concern of mine be best answered if I use an embedded database language within C++?
    2) If answer one is in the positive, I would need to use Pro*C/C++, correct? If answer one is in the negative, what do all of you use when accessing rows and columns of large databases and want to perform non-basic queries? What else would you suggest apart from Pro*C/C++?
    3) How would I go about implementing Pro*c/C++? It seems the documentation quotes that you need a completely separate compiler to recognize C/C++ and SQL. Why is this? Why cant they merely add a LIBRARY of SQL type functions? I guess that is impractical to use when typing in queries in the form of functions? EDIT: I see that Pro*C/C++ is a pre-compiler in which case I think I understand its benefits. But I still dont need a library? How do I make my IDE recognise the Pro*C/C++ Pre-compiler?

    Regards,
    Last edited by Vespasian; 10-21-2013 at 06:07 AM.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,662
    Quote Originally Posted by Vespasian
    A language such as C++ can build powerful applications but cannot efficiently define database structures and is poor at generating adhoc queries.
    The former is incorrect since C++ can be used to write a database engine.

    Quote Originally Posted by Vespasian
    Would this concern of mine be best answered if I use an embedded database language within C++?
    Maybe, maybe not. It depends on your other requirements. As stated, your problem can be solved by say, making use of some database API to access an external database, or perhaps by embedding a database engine like SQLite.

    Quote Originally Posted by Vespasian
    It seems the documentation quotes that you need a completely separate compiler to recognize C/C++ and SQL. Why is this? Why cant they merely add a LIBRARY of SQL type functions?
    I believe the point is to make it easier to write those SQL statements within your C or C++ code (i.e., to embed the SQL). Doing that means that your code is no longer valid C or C++, so the pre-compiler turns it back into valid C or C++ by replacing what you wrote with calls to the provided library function.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User Vespasian's Avatar
    Join Date
    Aug 2011
    Posts
    181
    Quote Originally Posted by laserlight View Post
    The former is incorrect since C++ can be used to write a database engine.
    True, I meant to say something along the lines of C++ although can be used to write database engine, does not have support for basic database commands.


    Quote Originally Posted by laserlight View Post
    Maybe, maybe not. It depends on your other requirements. As stated, your problem can be solved by say, making use of some database API to access an external database, or perhaps by embedding a database engine like SQLite.
    Thanks, I just checked up on SQLLite. I think this is what I was looking for instead of Pro*C/C++!
    I see SQLite has a serverless model with its own internal database and the biggest advantage for me is the following from its official documentation page:
    Quote Originally Posted by SQLite Official Documentation
    Internal or temporary databases

    For programs that have a lot of data that must be sifted and sorted in diverse ways, it is often easier and quicker to load the data into an in-memory SQLite database and use queries with joins and ORDER BY clauses to extract the data in the form and order needed rather than to try to code the same operations manually. Using an SQL database internally in this way also gives the program greater flexibility since new columns and indices can be added without having to recode every query.
    Im going to try give it a go and see if I have any more questions.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. database programming with c#
    By rafay_07 in forum C# Programming
    Replies: 2
    Last Post: 12-09-2011, 09:34 PM
  2. Database programming in C
    By #include in forum C Programming
    Replies: 1
    Last Post: 11-23-2004, 01:49 AM
  3. Database programming
    By bigSteve in forum C++ Programming
    Replies: 1
    Last Post: 06-08-2004, 05:01 PM
  4. database programming
    By bigSteve in forum C Programming
    Replies: 2
    Last Post: 07-02-2003, 07:58 AM
  5. Database Programming In C
    By hanry in forum C Programming
    Replies: 0
    Last Post: 11-27-2001, 07:16 AM

Tags for this Thread


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