loading...
Cover image for Starting With SQL

Starting With SQL

flippedcoding profile image Milecia McG Updated on ・4 min read

At some point in your web developer lifetime, you'll probably see or use SQL. You might dive deeper into it or you might only use it if no one else has time to write it. Either way you go it's good to know a little about this database querying language.

First a little background about databases. A database is used to hold different columns and tables of data. This is where usernames, passwords, birthdays, credit card numbers, and all of your other data is stored. There are relational databases that use keys to make connections between tables and there are non-relational databases that are used more for big data.

What is SQL

SQL is the querying language for relational databases. It's the language that lets you get the data you need based on the requirements you set. Nearly all relational databases use SQL. That means this is the same language you use in MySQL, Microsoft SQL Server, and even Oracle. There might be some slight syntax variations but once you know SQL it won’t take you long to get up and running on anything.

What does it do

You can just read the data, you can create new data, you can update data, and you can delete data. Using SQL, you can make changes to the database and use the information any way you want. This is how you are able to reset your password when you forget it on a website. There's a SQL query somewhere in the code that finds your specific data and makes that update.

If you need to filter or do some kind of calculation on the back-end with your data, SQL lets you do that. You can do your sorting and invoicing all on the back-end with a few SQL scripts. It's also extremely useful for handling any daily reports that you might have to show other people. You have can even make views of a table to get specific columns and some other advanced stuff.

When is it used

One acronym, API. SQL is a good friend to those who are responsible for writing the APIs for their applications. Sometimes you want the front-end developers to be able to work with some data without giving them access to the entire database. That's why APIs are so popular. You control everything about the data that the user sees and how it's handled before it gets to them. Although SQL is used for more than just APIs.

You'll definitely see it if you ever do any reporting. There's almost no way around SQL when it comes to report writing. Someone is going to want to know the outstanding balances for some client that hasn't responded to an email in 3 months or something else specific like that. Most of the time you can think of SQL being used when a question needs to be answered. It's still kind of weird the detailed answers you can get from looking through the data.

How is it used

It's written just like any other code. Sometimes back-end developers act like it's something else. 🙃 But really, you can write it in the same editors you use for your other code. The thing you have to pay attention to is your data model. It's going to pay off if you know which foreign keys go to which tables and a general knowledge of the database layout won't hurt either.

Most of the time if there's a procedure you'll be using multiple times, you'll save it as a stored procedure. Then you'll have a little script you can run whenever you need it and you can use it in your other scripts. Try to write your SQL clearly because you'll come back to it one day and it would help if you could read through it and figure out what you were doing and why you did it.

Why it's important

I'm sure you can see a lot of reasons why SQL is important. It's how you work with a relational database, which as of now are the primary type of database. SQL is the language that lets you create a new user profile on Twitter.

It's the language that shows you the balance of your bank account and all of your transactions. It's how you can delete that weird Tinder profile you don't use anymore. And really, it's that language that lets you keep changing your password because you never remember it. That's why SQL is so important.

Hopefully this helped you get a higher level understanding of where SQL fits in web development. It's an interesting thing you can get into and if you become a DBA… whew! That's a lot of job opportunities. At least that's what I hear. What exactly is a database admin? Somebody help me out in the comments.


Hey! You should follow me on Twitter because reasons: https://twitter.com/FlippedCoding

Posted on Jan 17 '19 by:

flippedcoding profile

Milecia McG

@flippedcoding

Milecia is a senior software engineer, but she also has a master's degree in mechanical and aerospace engineering and has published research in machine learning and robotics.

Discussion

markdown guide
 

Great to see a shout out for modern web devs to learn more about SQL. I first got into it when I started as a web and desktop developer back in the early 2000s (coding classic ASP and VB6 just to show how old I am!)

SQL has been a staple from those days on and helped me make the jump over to analytics a few years later. It really should be a cornerstone of all developers knowledge, never mind analysts, so was great to read this.

 

I'm an Oracle APEX Developer, so I use Oracle's SQL and PL/SQL very heavily for my job. I feel that a lot of other developers don't quite understand the power being able to find any and all types of data with a few lines of code, and I feel there's a certain lack of respect for the integrity and security for relational databases as a whole.

 

T-SQL was my introduction to programming. I work with it everyday and now that I am studying front end languages I have grown to love the back end database scripting side of things even more. Such a powerful tool.

 

I just started with SQL a few months ago for my job , and had to learn from scratch , but I love it so far , so any and all SQL related articles are a huge plus for me, thanks for this. 👍