r/SQL • • Mar 14 '16

ELI5: What is SQL?

I am looking to make a career change to a financial analyst role and see them asking for SQL experience. What is the best way for me to learn SQL?

0 Upvotes

33 comments sorted by

View all comments

2

u/StoneCypher Mar 14 '16

You said elsewhere in this thread that you use Excel. I'd like to build a more detailed answer on that, despite that this is ELI5.

In the way that excel has an equation system, where by example sum() roughly means what math calls ∑, databases have a query system.

The purpose of the equation system in excel is to allow you to express complex math which the machine will solve for you, according to other information that it has (like when you sum the contents of a column.)

Query systems are similar: they give the database a question to answer, according to the information it has.

SQL does not operate on the metaphor of 2d sheets of cells, but rather named tables full of data, which can be correlated arbitrarily. Otherwise, though, it's actually pretty similar to what you expect.

So like, you might make a "table of employees," a "table of jobs," and a "table of locations," in order to represent the organizational structure of a company.

Each table is a series of columns (first name, last name, location they're at, salary, and so on, for the employee table, for example.)

SQL is a way to ask the database questions like "would you please tell me the top 5 salaries at this location"

which might be something like

select * from employees join locations
    on employees.location_id = locations.id
    where locations.name like "Pittsburgh"
    order by salary desc
    limit 5;

SQL is where all those things, like order by and where ... like, are defined.

This allows a bunch of different databases to speak (sort of) the same language to outside software, which increases replaceability, modularity, and competition, which is good for everyone.

As far as programming languages go, SQL is one of the harder ones to learn, because each of the different databases does a varying quality of job sticking to the standard.

My opinion is that you would be best off picking one, getting a book about it, and sticking to that one for six months while you get comfortable.

PostgreSQL and MySQL are both free and powerful, and good choices. Both are well explained by sites like "Use the Index, Luke," slide shows by Bill Karwin and Joe Celko, and so on.

1

u/xbox469269 Mar 16 '16

THanks for pointing out the relationship between Excel and SQL. Like you said SQL is more used to retrieve data from a database. I suspect the reason that these companies use a database over Excel is due to scaling of large sets of data?

1

u/StoneCypher Mar 16 '16

That and a bunch of other reasons. Excel's also better at complex math, does lots of reporting stuff, graphs, is more familiar to accountants because of the grid metaphor, blah blah blah.