Introduction to Databases and SQL

In the previous tutorial you learnt to install SQL on your device. Now, let's learn about SQL and databases.

Introduction to Databases

A database is an organized collection of data.


Types of Databases

In general, there are two common types of databases:

  • Non-Relational
  • Relational

Non-Relational Database

In a non-relational database, data is stored in key-value pairs. For example:

How is data stored in non-relational database?
Example: Data stored in non-relational database

Here, customers' data are stored in key-value pairs.

Commonly used non-relational database management systems (Non-RDBMS) are MongoDB, Amazon DynamoDB, Redis, etc.


Relational Database

In a relational database, data is stored in tabular format. For example,

How is data stored in a relational database system?
Example: Relational Database

Here, customers is a table inside the database.

The first row is the attributes of the table. Each row after that contains the data of a customer.

In a relational database, two or more tables may be related to each other. Hence the term "Relational". For example,

Relationship between two tables in a relational database
Relationship between two tables

Here, orders and customers are related through customer_id.

Commonly used relational database management systems (RDBMS) are MySQL, PostgreSQL, MSSQL, Oracle etc.

Note: To access data from these relational databases, SQL (Structured Query Language) is used.


Introduction to SQL

Structured Query Language (SQL) is a standard query language that is used to work with relational databases.

We use SQL to perform CRUD (create, read, update, and delete) operations on relational databases.

  • Create: create databases or tables in a database
  • Read: read data from a table
  • Update: insert or update data in a table
  • Delete: delete tables or databases

SQL Example: Read Data From a Table

SELECT first_name, last_name FROM Customers;

Here, this SQL command selects the first name and last name of all customers from the Customers table using the SQL SELECT statement.

Example: SQL SELECT Statement
Example: SQL SELECT Statement

SQL is used in all relational databases such as MySQL, Oracle, MSSQL, PostgreSQL etc.

Note: The major SQL commands are similar in all relational databases. However, in some cases, SQL commands may differ.

In this SQL tutorial series, we will learn about SQL in detail. We will cover any SQL command differences among MySQL, Oracle, SQL Server, Postgres, and other commonly used database systems.

Did you find this article helpful?