Intro to SQL
Before learning about SQL, let us take a step back to understand what SQL does and why it is important. SQL, oftentimes pronounced, “Sequel” or “ess-q-uel” is a structured query language whose main purpose is to interact with a database. If you are anything like me you’re thinking, “what?” Let me decouple the definition of SQL. SQL is a structured query language, meaning there are rules to follow in order to query (ask) the database to return the selected information from said database. SQL follows simplistic CRUD operations. If you are unfamiliar with the terminology, CRUD is a commonly used tool in programming to create, read(retrieve), update, and delete information or items from a database or website application. It is a paramount aspect of your life as a developer and a life without CRUD is, quite frankly, difficult to imagine. SQL uses a similar commonly used tactic for querying a database. These commands are SELECT, INSERT, UPDATE, and DELETE. The definitions are as follows:
Statement | Description |
SELECT | Retrieves data from one or more tables. |
INSERT | Adds one or more new rows to a table. |
UPDATE | Changes one or more existing rows in a table. |
DELETE | Deletes one or more existing rows from a table. |
It is typical for a SQL programmer to use these data manipulation language statements to work with the data in the database. If you are a database administrator, your SQL statements will be used to work with database objects and will look like this:
Statement | Description |
CREATE DATABASE | Creates a new database. |
CREATE TABLE | Creates a new table in a database. |
CREATE INDEX | Creates a new index for a table. |
ALTER TABLE | Changes the structure of an existing table. |
ALTER INDEX | Changes the structure of an existing index. |
DROP DATABASE | Deletes an existing database. |
DROP TABLE | Deletes an existing table. |
DROP INDEX | Deletes an existing index. |
Despite your reason for wanting to learn SQL or your job responsibilities, you can see basic CRUD operations in action! One thing to note, writing in all caps gets a bad rap. I promise that I am not yelling at you. But while querying a database, it is always important to differentiate between the reserved SQL keywords and your statements. It is not a mandate nor a requirement of the nomenclature, but you will see me use all caps frequently throughout this course. In the next blog post, I will provide a brief written explanation about the relational database model.