Database as a storage option

This last spring I had taken a C++ course at a local community college. It was a one day per week arrangement, so by the time that day came I always had a load of questions concerning my latest endeavor. There was a day I brought questions with me about what the best way might be to save a large set of prime numbers. My teacher offered possible solutions. I could use an array. I could use a vector. I could use a text file arranged in csv format. I could also use a database.

I am very familiar with all of these options now except the database. Weirdly enough, I rarely run into any code that leans toward that direction. How is this kind of thing approached? Do people usually write C++ code that somehow syncs with something like SQL, or do they create the database in C++? I haven't actually used SQL yet, but I am interested in knowing what the usual solutions are.

I may be interested in writing code for a Point Of Sale program for a pizza delivery store. The program should keep track of thousands of customers with names, phone numbers, addresses, and additional information. I imagine this might be best done in a database? Please advise me.

The computers that would run the software would be 32bit Windows machines if that makes a difference.
Last edited on
C++ program can include a database engine. You won't write it, you will use an existing library.
For example, the SQLite http://www.sqlite.org/about.html

C++ program can act as a SQL client. Again, you link in the client library of a SQL server of your choice.
Some C++ frameworks, like Qt, can help in that: http://doc.qt.io/qt-5/qtsql-index.html
It is possible. It depends what database server you want to use. Normally (in my experience) you connect to a running database server, normally (but not always) on an external server. As an example, here's the docs for an example connection with a MySQL database: https://dev.mysql.com/doc/dev/connector-cpp/devapi_ref.html
Topic archived. No new replies allowed.