My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more
Starting With SQL

Starting With SQL

Milecia's photo
Milecia
·Jan 17, 2019

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.


I'm doing a free web development webinar on January 20th. I'll show you how to make a simple web app using HTML, CSS, JavaScript. There's only 3 days left to register. If you're interested, just register here Hopefully I'll see you on the 20th! Whoo!