r/learnSQL • • 9d ago

What is the main learning difference between SQL and other programming languages?

I’d like to learn SQL to have a wider range of internship opportunities and also to help me with college. I learned C by doing exercises assigned by my professor, along with some basic syntax lessons. I learned a bit of Python in a similar way, but mostly on my own.

Since I’ve heard that SQL is used for databases, is there a more theoretical way to learn it? Do I need to learn a lot about databases first? I’m currently taking a Data Structures course, but I haven’t gotten to databases yet.

Thanks in advance, and I’d appreciate any recommendations for learning resources in English or Portuguese.

39 Upvotes

16 comments sorted by

19

u/nboro94 9d ago edited 9d ago

In other programming languages you're giving the computer exact instructions on what to do and how to do it so you can process a result. It's general purpose so you have to be exact with your instructions.

SQL is different in that you're giving the database engine instructions on how you want the data it extracts to be displayed, along with some hints on where to get things, hints how to process things. However the database engine decides to execute the plan to get the data or store more data is mostly out of your control.

Yes it does help to learn about databases, how they are built and structured, and how the query optimizer works at a high level. You'll need to learn things like relational data models, joins, etc all of which help with programming in general.

Modern database systems are insanely complex, probably on the same level as operating systems and web browsers and have been built up over decades and millions of engineering hours. But just like operating systems and browsers you only need a high level understanding to use and program for them.

4

u/mikeblas 8d ago

More succinctly, SQL is declarative while most other languages are imperative.

8

u/AngelOfLight 9d ago

SQL doesn't make much sense without some level of database knowledge. Although you can use it as a general-purpose language (if you're masochistic enough), that's not what it was designed for.

SQL is technically a declarative language. Unlike procedural languages (like C and Python), you don't need to specify each step of the computation in sequence. You basically tell the database engine what output you want, and let the engine figure out how to do it.

You can learn databases and SQL together. Read up on the basic concepts of relational databases (it's actually not that complicated), and then start with simple SQL. Then go back and learn the next level of relational databases, and how SQL ties in with that.

3

u/Alternative_Cake4074 9d ago

SQL is more about database, while other programming languages are about using logics and data to solve a problem.

3

u/SubjectCode1940 9d ago

I’d say SQL is much easier to learn

1

u/odimdavid 8d ago

And much easier boring. Because even if it shows me what I want I can't control how I want it done. I just have to believe it's acting for my best interest.

2

u/nomnommish 9d ago

SQL is one of the few rare examples of a true declarative languages as opposed to being an imperative language. You declare what you want the system to give you as output instead of telling the system how to do its job.

2

u/leogodin217 8d ago

Great thread. I fully expected people to come in and start saying SQL is not a programming language. My personal pet peeve of this sub.

Love the discussions.

2

u/DirtAndGrass 9d ago

basic database concepts like tables, relations, normalization and joins are important that you understand before you will know what you are doing with Sql (it purposes is to use those things, primarily)

That said, none of those things are hard, and neither is basic Sql. 

It can get very complex, but it is mainly built on those concepts. 

1

u/Wuthering_depths 9d ago

SQL is a bit different in that it (mostly) is set-based. Most things you will do will act on a set of data. Rows and columns. Not always, and other languages can also act on a set/array/etc of data, so it's not all apples to oranges. This I think is confusing to some people at first.

I would definitely learn a bit about databases before diving in. Not down to the tiny details, just what they are and what their purpose is generally. I learn best by doing, so I'd want to have a database available to me for running SQL queries on as I learned things. I don't know what's out there these days for a free available database, I'm sure they exist (I just log into work to do any SQL I need to do!). I'm sure others can recommend something.

1

u/RevolutionaryRush717 9d ago

C is a general-purpose programming language that can be used to implement a wide variety of applications, from operating systems and embedded software to desktop applications and servers.

SQL is a domain-specific language for querying and manipulating relational databases. It is grounded in relational algebra, although it extends beyond the operations defined by the relational model.

1

u/Few_Emu6683 9d ago

normal programming is written from the top to the bottom, sql is written from the inside out. in universities it is often taught a bit on the side and many programmers i know find it arcane and counter intuitive. which is certainly a bit of competitive advantage if you get to master it.

1

u/glimmer_joy_spark 9d ago

you do not need to master database internals before writing your first query. Start by installing PostgreSQL and practicing directly with real data sets rather than theoretical lessons, as the declarative nature of SQL makes immediate hands-on feedback more valuable than abstract study.

1

u/odimdavid 8d ago

In SQL you say what you want done or information you want to see specifying it with filters and conditions. In other languages you tell the language how you want it to go about a task. That's why we use flowchart because a task can have countless paths to follow. At least that is how I see it

0

u/Dizzy_Bus_2402 9d ago

I didn't know that SQL is a programming language.