Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When should I use C++ instead of SQL?

Tags:

I am a C++ programmer who occasionally uses MySQL to work with databases, but my SQL knowledge is rather limited. However I am surely willing to change that.

At the moment I am trying to do analysis(!) on the data I have in my database solely with SQL queries. But I am about to give up, and instead import the data to C++ and do the analysis with C++ code.

I have discussed this with my colleagues, and they also push me to use C++, saying that SQL is not meant for complex analysis but mainly for importing (from the existing tables) and exporting (to new tables) data, and a little bit more such as merging data to - e.g. - joined tables.

Can somebody help me drawing a line? So I know when to switch to C++? Of course performance is also an issue.

What are indications that things get to complex in SQL? Or maybe I just take the wrong approach with designing the queries. Then where can I find tutorials, books, ... to take a better approach?

I hope this is not too vague. I am really a bit lost.

like image 664
AudioDroid Avatar asked Jul 06 '11 12:07

AudioDroid


People also ask

What is the difference between C and SQL?

So in summary, C is a language used to give commonly-understood commands to any arbitrary CPU while SQL is a language used to give commonly-understood commands to any arbitrary database back-end.

Is SQL faster than C?

They are both as fast as possible, if you make good code and good queries.

Can C be used for database?

C in DatabasesC programming language is mostly used in almost all the popular database tools in the computer world, namely, MySQL, Oracle, PostgreSQL, MS SQL Server, etc. The codes on these tools are written with the help of C, as well as C++.

Is SQL based on C?

If anyone ever asks you who wrote the first SQL database, you now know the answer: Oracle. So the answer is C - according to Burleson Consulting. Since SQL was originally written by IBM as part of System R, quoting what Oracle used to implement their variant of SQL is not entirely relevant.


2 Answers

SQL excels at analyzing large sets of relational data.

The place to draw the line is the scale of your analysis.

If you analyze individual records one at a time, do it in your application.

If you analyze large sets of records as a unit, SQL is definitely the best tool for that job.

Row-by-row analysis is not something SQL is designed or optimized for very well. But, if you want to know something about a million-row group of data, do it in the database.

like image 62
JNK Avatar answered Oct 16 '22 16:10

JNK


I have discussed this with my colleagues, and they also push me to use C++, saying that SQL is not meant for complex analysis but mainly for importing (from the existent tables) and exporting (to new tables) data, and a little bit more such as merging data to - e.g. - joined tables.

This is completely arbitrary. Learn SQL. There are a lot of resources available on the web for free.

like image 43
ascanio Avatar answered Oct 16 '22 16:10

ascanio