GetMeCoding - What is SQL?

What is SQL? A Lesson Using Luke Skywalker

Learning to code SQL with databases can be an interesting if you use the right example data.  In my last post I explained WHAT IS A DATABASE and provided a STAR WARS database example download.  As a huge Star Wars fan, using this data to learn is so much more fun.

But let’s cover a few things first….. oh….and May the Force Be With You!

GetMeCoding - Learn SQL
Image courtesy of StarWars.com

But I was going into Tosche Station to pick up some power converters!

When learning about databases, don’t be like the young Luke Skywalker who just wanted to hang out with friends.  Dive in and start learning SQL now…. believe me, it will help you in the long run!

What is SQL?

SQL is the acronym for Structured Query Language and it is used for querying and managing data stored in a database.

It has its beginnings at IBM in the early 1970’s and then was standardized in 1986 by the American National Standards Instituted (ANSI) and 1987 by the International Organization for Standards (ISO).  I share this so you can see that this is something that has stood the test of time and really isn’t going away anytime soon.

Although there is a SQL standard, databases do differ a bit when you have to write the code.  That means if you use an IBM database management system, some of the coding is different than if you were creating code for a Microsoft database management system.

Get Started

Is SQL a programming language?

It is not a formal programming language like C# or Java.  Nor is it a scripting language like Javascript that runs in a web browser.

It is considered a sub-language as it only pertains to working with data.

GetMeCoding - Learn SQL
Image courtesy of StarWars.com

You want the impossible.

When you first learn SQL, it may seem difficult.  Give it time and keep at it.  You will find that in time, it all makes sense.

Do you need to know it to write programming code?

The short answer is “maybe”.

If you want to be a programmer that needs to get data stored in a database, then yes, knowing SQL becomes important and many websites, apps, video games, and software programs need data from databases.

SQL commands can stand alone or you can intertwine them with certain programming languages such a Java, C#, and PHP to name a few. This mixing of SQL code with programming is known as “Embedded SQL”.

If you are new to coding, check out this blog post on WHAT IS CODING.  When you write a program (aka code), it will do some kind of activity or task.  Many programs need data to do the task. To get to the data, you need to know SQL.

Some of the major companies in the tech industry also have their own variations of SQL:

Are there different kinds of SQL commands?

Yes, it is a very broad body of knowledge and with that comes many commands.  Textbooks, training, and certifications are built all around the following topics which can also lead you to a whole database profession.

Generally speaking, the commands fall into one of 4 categories known as:

  • DML (Data Manipulation Language)
  • DDL (Data Definition Language)
  • TCL (Transcation Control Langauge)
  • DCL (Data Control Language)

DML (most widely used by software coders)

  • SELECT – retrieves data
  • INSERT – inserts data
  • DELETE – deletes data
  • UPDATE – updates data

DDL

  • CREATE – create a database an its objects like a table or view
  • DROP – removes an object from the database
  • ALTER – modifies an object
  • TRUNCATE – remove all records from a table
  • RENAME – renames a database object

DCL 

Used to change how a user can interact with the database

  • Grant – assign various privileges in the database
  • Revoke – take away those privileges

TCL

  • Commit – this behaves like a SAVE on a pc.
  • Rollback – the concept is simliar to an UNDO on a pc
GetMeCoding - Learn SQL
Image courtesy of StarWars.com

Impressive — every word in that sentence was wrong.

As you begin creating your SQL, errors will happen.  When they do, you may find it is a combination of how you are reading your database diagram (ERD) and how bad you type!

How do you write SQL Commands?

SQL is typed either directly into your programming code or you can use a specific database tool that allows you to get to your data.  It is SQL gets the data and then your programming code can use it to be displayed.

GetMeCoding - SQL Flow

Next steps...

In the next post, I will review how you can use the SQL DML commands that most coders use when writing code that works with data stored in a database.

As Obi Wan Kenobi said, you can take a step into a “much larger world” with my database course here.

Happy Coding!

GetMeCoding.com Mr Fred

 

 

 

Mr. Fred

Start Coding Today In 5 Minutes!

Get Me Coding Free Activity

Take 5 minutes and try a FREE coding activity!

Let Me Help You

GetMeCoding Mentoring

If you are a teacher or someone looking to help others learn to code, let me help you.

Scroll to Top

it only takes

5 Minutes and 22 Seconds