Introduction to
Structured Query
Language (SQL)
Regan Muthomi
What is a Database?
A database is a collection of data stored in a
format that can easily be accessed, modified,
protected and analysed.
Types of Databases
There are 2 main types of Databases
Relational Databases (SQL)
Non-relationa Databases (No-SQL)
In this course we"ll be covering relational databases
Relational Databases
A relational database is a type of database that
organizes data into one or more tables, with each table
consisting of a set of columns and rows. The tables in a
relational database are related to each other through a
common field.
These tables have a prefined logical structure called a
schema.
DBMS
We primarily interact with a database through
a database management system (DBMS).
A DBMS is a computer program that is used to
create, access, modify and maintain a database.
Database
DBMS
User User User
DBMS for Relational
Databases (RDBMS).
MySQL
PostgreSQL
SQLite
Microsoft SQL Server
SQL
SQL or Structure Query Language programming language used to
communicate with relational databases.
SQL is a declarative language; one just needs to specify the result that they
want to see and submit the query to RDBMS.
RDBMS executes the code at the backend and gives the desired output.
SQL is database dependent - It has different dialects for the different RDMS.
This means that, SQL for MySQL is not the same as for SQLite.
However, these dialect/versions of SQL are more the same than they are
different.
Types of SQL Queries.
Data Manipulation Language (DML) queries: These are used to manipulate data
within a table, such as SELECT, INSERT, UPDATE, and DELETE statements.
Data Definition Language (DDL) queries: These are used to define the structure
of database objects, such as tables, indexes, and views. Examples include
CREATE, ALTER, and DROP statements.
Data Control Language (DCL) queries: These are used to control access to the
database, such as granting and revoking permissions. Examples include GRANT
and REVOKE statements.
Transaction Control Language (TCL) queries: These are used to manage
transactions within the database, such as COMMIT and ROLLBACK statements.
Data Query Language (DQL) queries: These are used to retrieve data from the
database, such as SELECT statements.
QA