3

I've been using stl for a while but i'm just getting to know sql.

Can sql functionality be simulated using stl/boost containers and algorithms? if not, where do the limitations start?

for example, I could create a database by simply using std::vector<std::unordered_map<std::string>> or even better with boost multi-index.

then, the sql operations can be mimicked with algorithms:

  • WHERE -- std::copy_if
  • JOIN -- std::set_union

It may be possible to do the optimization of the queries using lazy evalluation.

I do understand that sql is not in ram. but it's not that important if database is not that big. plus, there is also stxxl.

So my question is mainly about when do you stop using stl/boost and switch to sql?

kirill_igum
  • 3,953
  • 5
  • 47
  • 73
  • 1
    This is useful. I've written and seen very limited implementations in the past, but am not aware of anything vaguely complete. A quick GOogle turns up a "select"-only project with non-C++ dependencies - https://github.com/mfragkoulis/PiCO_QL. "when do you stop using stl/boost and switch to sql" - the most important difference is that SQL queries can be handled at run-time, so if you need to accept/build queries based on user/file/network input then you'll need some parsing and optimisation ala SQL. – Tony Delroy Dec 04 '13 at 23:31
  • @TonyD I'm not looking for an implementation. I'm looking more to see if algorithms of boost and stl can cover the functionality of sql. – kirill_igum Dec 06 '13 at 03:40
  • 1
    That question just doesn't mean anything, because the devil's in the detail... there are obviously differences (e.g. run-time query specification and optimisation is expected of an SQL system but not built into the Standard library containers/algos nor - to the best of my knowledge - boost). Ultimately, whether enough similar functionality is covered depends on your needs, about which you've written zilch. – Tony Delroy Dec 06 '13 at 14:42
  • @TonyD if no specific restrictions on usability of stl/boost instead of sql come to your mind (assuming you are an expert in sql and stl), it answers my questions. – kirill_igum Dec 06 '13 at 20:33

0 Answers0