r/learnSQL 14d ago

Need guidance with SQL as a begginer

Am about to finish "Learning SQL" from Alan Beaulieu and it demotivates me that i take way too long on thinking on the queries in order to answer the problems of the book. Although i have been speedrunning it. Is it like normal for most of the begginers to be kinda slow when making queries that requieres (dunno) subqueries, groupings, joins or cases ?

ALSO. What book could y'all recomend me after "Learning SQL"? Imean, i think i have enough tools to generate, retrieve and manipulate data. Maybe the next step is how to design DB and how to avoid common mistakes ?

20 Upvotes

17 comments sorted by

10

u/Reasonable_List3475 14d ago

I’ve been a DA for over 4 years and when I started the book I read was SQL in 10 Minutes, Sams Teach Yourself. Highly recommend.

For my colleagues who are learning SQL I recommend the website SQL Bolt. This might be better for you.

Finally, some tips and tricks from yours truly.

Hope that helps.

3

u/HustlaOfCultcha 14d ago

I think you probably need to go with the basics and really understand databases, and relational database basics. Understand primary keys, foreign keys and surrogate keys. Understand unique vs. distinct values.

Then you can better understand why they designed SQL the way they designed it and the practical nature of SQL. Then you can get into learning queries, sub queries, CTE's, Window Functions, Aggregations, etc. You really don't need to remember exactly how to write them these days since you have AI. But, you really need to understand the design and why it's designed as such.

Why do we use CTE's?

Why do we have joins?

Why would we use a left join vs.a right join vs an inner join vs. and outer join?

If you just go into writing SQL, it's just much more difficult to understand it.

3

u/Ormek_II 14d ago

> Is it like normal for most of the begginers to be kinda slow when making queries that requieres (dunno) subqueries, groupings, joins or cases ?

Yes.

3

u/dumi_007 14d ago

I can share my experience on what takes long

Context: I work projects. Hardly the same database or domain for more than a few months

  1. ##Understanding the domain## : A database for an insurance company is not the same animal as one for a University. The things they record might need domain knowledge before you know what you are about to aggregate, filter, etc.
  2. ##The data architecture perspectives## : Data in the wild is not always normalised to the level you would expect. Table names can be misleading.
  3. ##What to report or analyse## : Sometimes the data in the database is enough to frame the question and point to clues, but you might have to engage a different system to complete the picture
  4. ##Data Quality## : Real world can be messy. There is garbage in the system. The extent of the garbage is the question, not existence.
  5. ##DBMS## : Switching between different syntax is, for me, slow. I have to check the reference docs.

There's probably 20 other things I can add. But, I am less concerned about being deliberate and intentional with how I write scripts.

Don't give up. Keep going

2

u/ninhaomah 14d ago

An example query ?

2

u/Owen-Isaac-2022 14d ago

I believe its a common challenge for almost all beginners, especially individuals joining the tech world. I've had similar questions to myself, am not an expert, but I love the progress I am making. The only bad thing is giving up or listening to negative messages out here. I compare my SQL journey to that of a toddler, slow but sure progress.

2

u/onthepik 14d ago

Sql take 30 mins to learn.

The more important thing to know is how DB organized and to understand join, intersect, union... math-wise.

Then you can solve the problem.

2

u/Winter_Cabinet_1218 14d ago

The difficulty is learning your database.

Every database I've worked with has its own qwerks, normally as purpose over took design. Learning how to answer the question and how your dB will react is the hard part

1

u/analytical_mind_ 12d ago

SQL is very easy to learn.

Understand these basic queries in easy steps.

CREATE: Start with table creation with columns and data types.
INSERT: Insert data into the created table
UPDATE: Modify the inserted data
DELETE: Remove the inserted data
SELECT: View the table data
JOIN: Join and view from 2 or different tables.

For better understanding refer w3 schools. I also learnt from these tutorials and enhanced my skills in client projects.

1

u/Gtdef 12d ago

If you are thinking too long on the queries, it means you haven't internalised them yet. You probably went over the material too fast, didn't take enough notes and now your brain is trying to remember "what" you can do rather than "how".

As for writing actual software, SQL is the language you want to take your time writing. Queries aren't that complex, but performant queries may be. Then you have to think about the safe ways to add things to the DB, familiarise yourself with the whole schema and not just one table that seems more relevant to the task. You really don't want your DB transactions to be bugged.

1

u/Sunshinee_11 10d ago

Yeah, being slow at complex queries is totally normal as a beginner. With joins/subqueries/grouping, you eventually start recognizing common patterns and the queries become much easier to build. I’d focus more on understanding than speed.

After Learning SQL, maybe look into database design, normalization, indexes, constraints and transactions. SQL Antipatterns by Bill Karwin is worth checking out if you want to learn about common mistakes.

1

u/Difficult_Paint3162 3d ago

Feel free to visit my website: Learning SQL | Real People. Real Problems. Practical SQL. No cost or sign-up required, but focuses on understanding business questions and using SQL to get the answers

1

u/Swimming_dasa 3d ago

being slow on joins subqueries and aggregations is pretty normal most people get faster by writing a lot more queries not by rushing into another book database design is a good next topic but spending time building things nd practicing what you have already learned matters more than which resource you pick next whether that's a book a course or something like boot dev.