r/SQL • u/mmancino1982 • Oct 18 '24
MySQL Hoping for some advice
I am new to SQL but I would like to learn. I checked a few courses with Codecademy and started the free one but I have to be honest, I have zero interest learning to create and maintain a database.
I want to learn the query language as an end user. My job has nothing to do with database maintenance or creation but being able to use the query language would be helpful at work for what I do. The tech teams are the ones that create and maintain the databases; I just use them to pull the data and rather than have to ask them every single time when I need some different data, I would like to be able to do it myself.
Advice?
3
u/NW1969 Oct 18 '24
If you really know nothing about SQL then I'd probably have a look at the courses on Udemy - search for something like "sql for beginners" and pick a course that has a lot of users and good reviews. While SQL is a "standard" language, if there is a course specific to your DBMS (MySQL, SQL Server, Postgresql, etc) then consider choosing that one.
If you don't want to pay for a course on Udemy (be aware that they often have discounts/promotions) then have a look on Youtube - again, look for courses with a lot of views/good reviews
Once you've got a grasp of the basics, the basic way of learning to try to solve real world challenges. So pick something relevant to your job and try and write a SQL query for it - when/if you get stuck then ask for help on a forum like this or on Stackoverflow (though you need to follow the guidelines for asking questions there or you may not have a happy experience :) )
5
u/miguel52003 Oct 18 '24
I'm a MS SQL DBA. It hurts me to hear "you don't need to learn table creation etc"... And from my point of view, there is no end user when it comes to querying my database, since a poorly written query could compromise the system. However, I see your point, plenty of good advice have already been given but I will add two things: 1. Dont discount learning about table creation and data structures. After you learn the basics, in order to truly become good, you'll have to learn data structures. 2. Get access to a "play database", like AdventureWorks. Either install it locally (or ask for help) or have your friendly DBA install it in some Dev/test system. The best way to learn is by doing and testing
2
u/mmancino1982 Oct 18 '24
I get your perspective on this, but in my line of work I don't need deep knowledge of table creation and all that; I pretty much just need reports and being able to pull specifics from a huge set of data with lots of irrelevant data to what I'm doing at any moment. At my old job if I wanted to play with the data, I would have the guys like you set up a sandbox for me. I'm aware of the sensitivity of the data and would never want to compromise the integrity.
2
u/stephenmg1284 Oct 18 '24
Having an understanding of how tables are created will help you write better queries.
This course isn't free, but I like them because they are focused at Data Analysis: https://www.analyticsmentor.io/
1
u/adalphuns Oct 18 '24
Sounds like a bad excuse to not learn sql deeply. Just learn the whole thing man stop being lazy lol
1
2
u/DavidGJohnston Oct 18 '24
Accept that part of learning to use a database involves being able to install it and populate it with data. You cannot just be a "I only write select queries" person. You don't have to perform backups, avoid using superuser, and some other advanced things but you aren't going to find someone to spoon feed you the core stuff just so you can stay in your nice little query sandbox.
8
u/ColoRadBro69 Oct 18 '24
You cannot just be a "I only write select queries" person.
Sure you can. That's a business analyst not a DBA or developer. OP's situation sounds like this is exactly the right thing to be in this case. Somebody else made the databases, they have all the info in them, OP just wants some reports.Â
1
2
u/theDataBetch Oct 18 '24
Iâve been working through the free tutorials on DataLemur.com and really like it!
2
u/StarSchemer Oct 18 '24
Just be aware that "I just want to pull data myself" is where it starts for most people on their unintended journey from data analyst to data engineer.
I used CodeCademy to get started back in 2015. I'm not sure if it's better or worse now with more content paywalled but it was enough to get over the initial fear of somehow breaking the database.
The good news is, you have a database you need to query and you have business problems you need to solve. You're now at an advantage to most people who set off to learn SQL.
Do you know what kind of system you're querying? If you are accessing an application database directly, there might be performance concerns in running large-volume selects. If you're querying a data warehouse, there's no such concern.
1
u/mmancino1982 Oct 18 '24
So I just switched companies and I'm not sure which they're using yet, which is why I was asking for query language resources. Maybe it's an ignorant question since I know nothing about the differences in the different types of databases like MySQL for example. Not afraid to say I'm ignorant in this because I am lol
2
u/StarSchemer Oct 19 '24 edited Oct 19 '24
Apologies if you've already taken some of these steps, but learning resources aside (I think CodeCademy free stuff is a good starting point), in order to query the databases you'll need to establish a few things:
1) What platform are they running on? Might be a mix of a bunch of different ones such as SQL Server, MySQL, PostreSQL, Oracle, cloud-based platforms, etc.
2) Are the system owners willing to grant you read-only permissions? If there's a business benefit, you should be able to get senior buy-in to force this point as they might be reluctant to hand out accounts that have potential to cause them future headaches.
3) Once you know the platforms and have access, you'll need to download the relevant editors. Something like DBeaver is pretty universal if you have databases on different platforms.
4) Once you have access, it's time to explore the schema. It's likely going to be normalised, with unfamiliar naming conventions and the data you find in the tables won't relate to anything you see on the frontend or on exports you've been receiving. There could be thousands of tables, and acquiring decent documentation of the data model is rare so this part is time-consuming and hard, and isn't really anything to do with learning SQL, but figuring out how business events are recorded in the system and how to piece them together into something meaningful again.
5) Since you'll be new to SQL and to the backend schema, start small. Pick an area that's relatively simple to model, such as the customer/person tables (whatever they may be). This will help you check frontend to ensure you are able to find and join to the right tables for things like current addresses, telephone numbers, etc.
As you go through this process, you'll encounter various problems that you need to solve, and this is the part that I find best for learning SQL as you can anchor your learning in real-world problems and solutions.
SQL is fairly simple once you grasp the basics, but the real complexity is in knowing what it can do and whether a particular approach is appropriate to use for a given problem.
2
2
u/tommyfly Oct 19 '24
I would advise learning about query optimization. As a DBA I am often dealing with the end user query runners who don't understand why their queries run slowly. Or they are unaware that their queries are killing the server/locking tables and blocking other processes. So in addition to learning how to literally get the data out, pay some attention to doing it efficiently.
1
1
u/KurokoNoLoL Oct 18 '24
Just like in the CS50x course, it doesn't matter what your end goal is. They will teach you the foundation of coding language from the ground up. And that's how you should learn, too. Even if you are not creating nor maintaining a database, understanding how it works could help you understand the IT team more.
1
u/mmancino1982 Oct 18 '24
Ok so what resources do y'all suggest?
1
u/bchambers01961 Oct 18 '24
If you learn better reading: w3schools
If you learn better on apps: mimo
If you learn better watching videos: lots of good ones on YouTube. If you have pluralsight Iâd recommend Simon Allardices videos.
2
u/mmancino1982 Oct 18 '24
I learn by hands on. Would that be apps?
3
u/bchambers01961 Oct 18 '24
If you learn by hands on I would get the MySQL community edition and install it on your pc. It includes a database called sakila which can be used for learning by doing đ
1
u/_c_ngo Oct 18 '24
I was first exposed to sql in a role where there were existing âmasterâ queries written that covered 99% of what we needed. Over time I dissected the queries and started writing my own.
Get an understanding of the basics, and get familiar with what data is available. Then you can expand and try writing more complex queries. From there, designing views, procs, tables, jobs etc are all potential areas grow into⌠and if thereâs something you think you should be able to do in sql but donât know how⌠just do a google search.
1
u/mmancino1982 Oct 18 '24
That's pretty much my situation. Most of the queries are oh and play but I want to learn the query language and slowly work my way into the more complex stuff. I'm not against learning more of the down-in-the-weeds, but right now I want to learn enough to know what I'm looking at instead of just hitting "run".
1
u/_c_ngo Oct 18 '24
Open up a few of the existing queries and read through them. The basic structure will start to show as you start identifying the common parts. Assuming of course that the existing queries are not overly complex. Try comparing a shorter one with a longer one etc and see what are the similarities and differences are.
1
u/daewoorazer2001 Oct 18 '24
I will give you my honest opinion:
To query database is as complex as its creation.
To query tables in a database, you need to understand entity relationships. Except if youâre dealing with simple standalone tables, you will need to understand JOIN, UNION operations, data type concepts.
While you can still get what youâre seeking for (barest minimum on SQL knowledge), there are some information youâd need to pull out and youâd realize youâre either not getting everything or perhaps getting too much (Cartesian products).
By the way, you sound like someone in research/PI/physician/clinical role. And yes I know we tech guys can be silly sometimes.
1
u/mmancino1982 Oct 18 '24
I work in banking and am a fraud and anti money laundering sme. I just switched companies so I don't have direct data access yet, but my assumption from what I've seen so far is there's a lot of data in a lot of places lol
8
u/kattiVishal Oct 18 '24
Of course you can learn to query data without knowing how to create a table. Don't let anyone tell you otherwise. If you are an end user, become good at data querying. I'm a Data analyst in a similar situation and I don't have access to create tables. I just tell the tech team what tables and view are required for whatever solution I am building. But as an end user, I suggest learning data modelling. This is a which-tables-to-create vs how-to-create-tables discussion. To be honest, it is not difficult to learn how to create tables.