r/SQL • • Aug 31 '26 • Hooray 1 Bravo 2

PostgreSQL [ Removed by moderator ]

Post image

[removed] — view removed post

428 Upvotes

31 comments sorted by

•

u/SQL-ModTeam Aug 31 '26

Your post was removed for violating the sub rule regarding posting of basic SQL tutorials

22

u/MetaHeuristican Aug 31 '26

Super helpful!!!

I got a question related to joining two M:M tables. How would you do that, by creating a junction table, or?

14

u/Pangaeax_ Aug 31 '26 • Bravo

yep, usually a junction/bridge table is the cleanest way to model M:M.
each relationship becomes a row with the two foreign keys, then you join A → junction → B.
I'd normally make that key pair unique too so duplicate relationships don't sneak in.

1

u/Alarming-Attempt4241 Sep 03 '26

This post was removed can you please share it again

5

u/UpperLiving5962 Aug 31 '26

Thanks for sharing it. I appreciate a lot

3

u/Pangaeax_ Aug 31 '26

glad it helped!

3

u/NuwandaPython Aug 31 '26

You’re an angel, this is just what I need. Thanks!!

4

u/Pangaeax_ Aug 31 '26

haha glad it reached you at the right time 😄 good luck with the SQL prep!

5

u/BelowFold Aug 31 '26

Really nice; I’d add something about CROSS JOIN, UNNEST, and QUALIFY window function.

5

u/Joelle_bb Aug 31 '26

Cross Apply, temp tables, and performance optimization defaults would be worth adding

4

u/MetaHeuristican Aug 31 '26

Another thought came to me. What about indexes?

3

u/Careful-Wasabi Aug 31 '26

Learning indexing back in the day was a game changer - makes queries EXPONENTIALLY more efficient

3

u/MetaHeuristican Aug 31 '26

Do Data Analysts create them or it's handled BY Data Engineers usually?

1

u/Kobosil Aug 31 '26

maybe add QUALIFY and DESC/ASC for ORDER BY

2

u/Pangaeax_ Aug 31 '26

good point on ASC/DESC. QUALIFY is really useful too, tho it’s dialect-specific and PostgreSQL doesn’t support it directly, so I left it out of the generic version. might add a dialect-specific section next time.

1

u/warnerg Aug 31 '26

Saved to my documents folder! Thanks! Very well explained, easy to understand.

1

u/tflemon67 Aug 31 '26

Nice 👍🏾

1

u/Wuthering_depths Aug 31 '26

That actually looks very useful, not just for interviews.

It's been a while, but unfortunately my few interview-related tests (for PHP and SQL Server) were full of bullshit minutia that I wouldn't remember unless I specifically crammed for the test. "On page 4 of the server installation wizard, which checkboxes should you pick?" type of bs. The PHP one asked about some function that literally nobody ever uses, don't remember exactly what it was but I looked it up afterward. A good interview tries to find out how someone thinks, not whether they can memorize every detail of installations and syntax. But that takes actual effort and thought on the interviewers part.

1

u/derpderpdave Aug 31 '26

This is super helpful! Where are you posting this info? Website link?

1

u/subduedunicorn Aug 31 '26

Great cheat sheet. For my daily use I'd find it helpful to have convert somewhere on there too

1

u/Sexy_Koala_Juice DuckDB Aug 31 '26

Add qualify to the query order in 1, especially since you talk about window functions in 6.

For interview patterns add 'gaps and islands'.

1

u/NoeZ Aug 31 '26

Common mistakes

Using WHERE instead of HAVING

no idea what having does, I guess I have homework! Haha

1

u/scumraid Aug 31 '26

Thank you for this!

1

u/Substantial_Ranger_5 Aug 31 '26

why are you re-creating the same thing that literally 1,000,000 other people made that can just be generated on the fly?

14

u/[deleted] Aug 31 '26

[removed] — view removed comment

4

u/Tackit286 Aug 31 '26

Interviews that try and catch you out with something obscure and outdated are a waste of time for everyone. No one can memorise things they never use. Why try and pass an interview for a job you either can’t do or wouldn’t want?

The purpose of this guide is to keep the fundamentals front of mind. The vast majority of technical interviews cover this sort of stuff to make sure you’re not a total fraud.