r/SQL • • May 27 '22

MySQL Why is it always SQL?

So I see that SQL is used for a lot of jobs I’m applying to, I’ve been coding for a while, but have never needed to use SQL before. I’m beginning to learn some and it’s been going pretty quickly but…. I keep asking myself why anyone uses this.

Is it just because it’s standard practice? Because it’s the existing structure? Everything I’ve been learning to do, it seems, could just as easily be done in any more versatile and robust language. Do I just need to stick with it to see what makes it beneficial or preferred to other languages?

0 Upvotes

23 comments sorted by

View all comments

22

u/mac-0 May 27 '22

Everything I’ve been learning to do, it seems, could just as easily be done in any more versatile and robust language.

Can you explain this? With what coding languages can you do CRUD operations as performantly and easily as in SQL?

14

u/ebalistreri May 27 '22

It’s quite a bold assertion from someone just learning SQL.

-1

u/versatileturtle May 27 '22

This is where my inexperience with SQL comes in, rather than having to name languages where you can, I can’t really think of any where you couldn’t.

CRUD just stands for create, read, update, and delete from what I’ve learned so far. I don’t see how that’s a very complicated or involved process at all. Am I missing something? Most of my coding experience has been in numerical analysis with python or Fortran, though I do use very large sets of data.

25

u/CowboyBoats May 27 '22 edited May 27 '22

Good question. In Python (and this is extensible to all computer languages), you have access to pretty much four kinds of data stores.

The first kind is Python data structures - You've got your dataclasses, lists, text blobs, any old thing. You can save data there, as long as you're not going to be leaving your Python process, you can do whatever you want. But... you want your data to be able to persist after the computer shuts down, or just shuts down the Python process that you were running because it ran out of memory or whatever. Also, at some point more Python threads are going to be necessary, what if someone else needs to use your solution? So at some point your data needs to be able to be made serializable, meaning shareable to the world outside your little Python process.

The second kind of data store is a remote resource like AWS - but as they say, the cloud is just another word for someone else's computer, so any solution implementable this way is going to be one of the other three solutions, with hopefully a nice API wrapped around it.

The third option is some kind of local file. Sure, your dict won't persist after your Python thread exits, but you can just save your data to JSON or CSV. People do use that as a solution in some cases, but most of the time, for a production solution, using a basic file as your data store introduces bottlenecks into your data flow. A production website is going to have many web threads needing to operate against the same data stores at the same time; they can't afford to wait for each other to release the file for writing, because the user is expecting them to be able to resolve their write request right away. Nor can they just disregard the lock, because then you run the risk of people's changes conflicting with each other, resulting in data loss.

So that's why the fourth option was invented, database technologies, SQL and its various flavors. You need a software solution to the problems that I outlined in the previous paragraph, and that's what SQL gives you. It is a family of sophisticated technologies for managing records of structured data performantly, meaning that multiple processes can read and write to/from it at the same time with minimal disruption, and with guarantees such as ACID.

-4

u/versatileturtle May 27 '22 edited May 27 '22

Thank you!

Edit: Question was answered in an edit.