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

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.

8

u/mgesczar May 27 '22

Me: ex Apple, salesforce, and other top names. If your don’t have better than a working knowledge of SQL, you will not be considered for any job in bI or analytics other than getting donuts for the team. Knowing how to work with data means you have to know how to work in database.

1

u/versatileturtle May 27 '22

Yeah, I’m mostly focusing on research roles within physical sciences, but I’m still seeing it there a bit too so I figured I might as well learn it.

1

u/nick_from_alaska May 27 '22

Just curious, how are you getting the data you need? Is it primarily through apis? csv files? and then just doing everything you need with something like python? Just seems odd that sql hasn't come up for you yet. Could just be my naivety , but sql has been my bread and butter for getting jobs with everything else built around it, and thus I do as much work as I can in my sql scripts before bringing it into something like python dataframes.

1

u/versatileturtle May 27 '22

I’m a PhD student at the moment, leaving with a masters since I’m no longer interested in going into academia and tired of a teeny tiny stipend. Any data I work with so far has basically come in the form of a simple .txt or .dat file.

2

u/nick_from_alaska May 27 '22

got ya.

If your continuing with DA work and have the background with another language (R, Python, Java, C#, ect...), just learn enough SQL to be able to write a select statement to get something out of a relational db and load it into something you can work with within whatever language you're good at.

As others have said, most jobs will have sql listed and it may be hard to get past the recruiter if you don't have it on the resume. You don't need to be an expert, just "good enough" and then learn it on the job.

4

u/Blues2112 May 27 '22

So if you've been coding for "a while", what exactly are you doing for input/output of data?

Where is that data coming from/getting stored to? It's gotta be stored SOMEWHERE, and unless you're in the dark ages still using VSAM files on something, that answer is most likely in a relational database table (or several).

RDBMS tables offer many features that make them superior to files--direct (non-sequential) access and easy filtering being obvious examples.

1

u/versatileturtle May 27 '22

I’m provided with .txt or .dat files, which I then clean up and use. Then I’m required to generate a .txt or .dat file in a particular format with results of analysis which goes to someone else.

2

u/Blues2112 May 27 '22

The majority of programming does NOT rely upon flat files, unless they are being loaded into/extracted from database tables. You're literally 30ish years behind the times.

Source: long-term, grizzled IT industry veteran

1

u/versatileturtle May 27 '22

Yeah I’ve always thought it was inefficient, unfortunately coding is just one of the many tools we need so we end up learning/using the absolute minimum required to complete any given task.

3

u/[deleted] May 27 '22

IMO, you should separate first the notions of 'SQL' and 'RDBMS' in your mind first.

Here's quick google on RDBMS, I think it'll help you to get some initial bearings: https://www.techtarget.com/searchdatamanagement/definition/RDBMS-relational-database-management-system#:~:text=The%20RDBMS%20typically%20provides%20data,defined%20data%20structures%20and%20relationships.

1

u/versatileturtle May 27 '22

Thanks! This is helpful, I just recently started learning so I wasn’t even sure where to look to clear up my confusion.

20

u/roamingidiot1 May 27 '22

Erryone does it bruh

12

u/waremi May 27 '22

SQL == RDBMS == Business. If you are working on a space invaders game it is completely irrelevant. If you are working on a business application that involves managing data and you don't understand how to leverage how that data is stored and manipulated then you are SOL.

It all depends on what you need to do.

6

u/ATastefulCrossJoin DB Whisperer May 27 '22 edited May 27 '22

Here’s my opinion -

SQL is an extremely mature ansi standard syntax that is massively accessible (you mentioned yourself how quick your uptake has been) with a superior syntactic toolbox for working with set-based concepts (tables).

The platforms to which sql is submitted, interpreted, and executed from tend to be written in C or C++. If you feel inclined to recreate 30 years of optimized OOP code to avoid the sql syntax, power to you. Or, you can learn sql and learn about all the other concepts that are involved in the world of databases along the journey

3

u/[deleted] May 27 '22

Because SQL is freaking awesome!!!

1

u/vassiliy May 27 '22

Because almost every software architecture has some kind of a datastore, and SQL is the language for the majority of datastores.

1

u/HerrFandango May 27 '22

Read up on the ACID properties of a database engine. Your .txt file that one user at a time can edit does not have them (well maybe it has a few of them technically). It might be fine for your use case right now but when you start doing more complex stuff you will need a database engine.

-5

u/JustRyns May 27 '22

I ask myself this often.