The SQL Programming Language

July 14, 2025 (1y ago)

3 min read

Updated 19 Oct 2026

Programming#SQL#Databases#Data
Cite this article

SQL (Structured Query Language) is the standard language used to work with relational databases. It was created by IBM in the 1970s and is still used today in many database management systems, including MySQL, PostgreSQL, SQLite, Oracle, SQL Server, and others.

What Is SQL Used For?

With SQL, you can work with data in a database in several important ways:

These operations are often grouped under the term CRUD:

Create, Read, Update, and Delete.

Core Concepts

1. Table

Data is stored in rows and columns. Each table represents a specific type of information. For example, a Users table can store user information.

2. Primary Key

A primary key uniquely identifies a row and cannot be null. It may consist of several columns. It prevents duplicate key values, not every kind of duplicate business record.

3. Foreign Key

A foreign key constrains non-null referencing values to match a referenced key. It enforces referential integrity; it does not automatically eliminate repeated data. Add NOT NULL separately when the relationship must be present.

4. Query

A query is an instruction written in SQL. You use it to retrieve, insert, update, or delete data.

Real Code Examples

The example below creates two tables, Users and Posts, and connects them with a relationship.

-- Create the Users table
CREATE TABLE Users (
  id INT PRIMARY KEY,
  name VARCHAR(100),
  email VARCHAR(100) UNIQUE
);
 
-- Create the Posts table and connect it to Users
CREATE TABLE Posts (
  id INT PRIMARY KEY,
  user_id INT,
  title VARCHAR(200),
  content TEXT,
  FOREIGN KEY (user_id) REFERENCES Users(id)
);

Adding Data

INSERT INTO Users (id, name, email)
VALUES (1, 'Ziya Mammadov', 'ziya@example.com');

Searching for Data With SELECT

-- List all users
SELECT * FROM Users;
 
-- Find the user named Ziya Mammadov
SELECT * FROM Users WHERE name = 'Ziya Mammadov';

Joining Tables

-- Show users and their posts
SELECT Users.name, Posts.title
FROM Users
JOIN Posts ON Users.id = Posts.user_id;

Advantages of SQL

Conclusion

SQL is not just another programming language. It is one of the most important skills for anyone who works with data.

Whether you are a developer, analyst, or data engineer, SQL is the tool that lets you "talk" to data.

If this post was useful for you, share it and let me know what you think.

The question before a join

Before running a join, I would ask whether one input row should produce one output row, several, or none. A query can be valid SQL and still count the wrong thing. Stating the intended unit of each result row makes duplicated totals easier to spot than inspecting the final number alone.

Reference

PostgreSQL’s guide to constraints explains primary keys, foreign keys, and null behaviour in detail.

Cite this article

Mammadov, Z. (2025, July 14). The SQL Programming Language. https://ziyamammadov.me/blog/sql