The Basics of Web Development: Part IV

Let's start with the strict definition of what SQL is and move along trying to understand what it really means as we go.

SQL, Databases and Relational Database Management Systems

Excerpt from the Wikipedia page:

SQL is a special-purpose programming language designed for managing data held in a relational database management system (RDBMS).

To better grasp the real meaning of this definition, let's start with the more general, and at the same time essential, terms.

Why do we even need databases?

Databases are almost always used when developing serious Web applications these days. They are responsible for storing information necessary for the website, be it the content, various settings or users' login credentials. 

Even though a database can in fact store images, documents, etc., it is generally used to store only textual informationwhereas multimedia content and documents are stored as separate files.

The way a database is structured gives using it a number of advantages over plain text files:

  1. High access speed.
  2. Allow for random access to data (meaning it's easy to access a particular record in a database).
  3. Allow for retrieving only the data that complies with certain criteria.
  4. Using a database eliminates the need to worry about concurrent access to data. A number of people can request the same record at a time.

It would've been harder to implement the same functionality with files. Concurrent access to data is one of the main advantages of databases.

It is important to distinguish between a database and a relational database management system (RDBMS).

A database is the information that we store along with the structure of that information; at the same time a relational database management system is a program that provides access to that data to external applications.

A database is something we design for each and every project, building its structure based off the premise of our future application.

A relational database management system is something we pick from the list of available options (MySQL, Oracle, PostgreSQL,etc.) The most common bundle you'll encounter is PHP + MySQL.

Let's move on to relational databases. Relational databases are databases that consist of tables. “Relationship” implies the connection between tables that form the database. Tables in a database are the very same tables you've encountered numerous times over the course of your life: multiplication table, Microsoft Excel tablesetc. A table has a limited number of columns and an unlimited number of rows.

DB ProgrammingDB Programming

How can we insert new data into a database, modify/delete/edit records or perform other manipulations?

That's what SQL (structured query language) is for. It was specifically designed for managing relational databases. With SQL, we can perform almost any operation imaginable: from creating a database to retrieving a specific set of information from a database.

Generally, SQL queries are transferred to a RDBMS via an external program. The RDBMS in its turn runs the query and returns the result.

Every SQL command is either a query asking to retrieve certain data from a database or a request to a database that ends up modifying the database in a certain way.

In other words, SQL is that essential bridge that allows for interaction between a web application and a database (and its contents).

I hope the series shed at least some light on what's going on “behind the scenes” of Web development, and I wish you good luck in your future endeavours!

Referenced Windows applications

Comments