Chapter One SQL
Chapter One SQL
Chapter One SQL
It is a powerful tool for managing data that is organized into tables and
relationships between them.
SQL syntax comprises words, clauses, and commands that allow users to
create and modify tables, insert and retrieve data, and manage the database.
For example, users can create a new table and define its columns and data types
(e.g., text, number, date) using CREATE TABLE command.
The user can then add data to the table using the INSERT command, and retrieve
data from the table using the SELECT command.
Cont…
SQL can also be used to update, delete, and modify existing data
in the database.
With its powerful commands and functions, it can handle complex tasks
effortlessly.
SQL statements are written using the SQL language and follow a specific
syntax.
There are several types of SQL statements which
include:
3. Data Query Language (DQL) statements - used to retrieve data from one or
more tables in a database such as SELECT.
Cont…
Transaction Control Language (TCL) statements - used to manage transactions in a
database, such as COMMIT and ROLLBACK.
SQL statements are written with a combination of keywords, tables, columns, and
conditions.
For instance, a simple SQL statement for selecting data from a table would look
something like this:
WHERE condition;
Cont.…
SQL statements are commands used to interact with a database, and they are
crucial in managing, manipulating and retrieving data within a database.
Understanding DBMS Fundamental
A database management system (DBMS) is software that is designed to
manage and control access to a database.
There are several fundamental components of a DBMS that are essential for
its proper functioning and management of a database. These include:
1. Data model: A data model defines the structure of the database and
determines how data is organized, stored and accessed within the database.
2. Data definition language (DDL): DDL is a set of commands used to create and
modify database objects such as tables and indexes. It specifies the schema or
structure of a database and provides a framework for organizing data.
3. Data manipulation language (DML): DML allows users to insert, update, and
delete data from a database.
SQL (Structured Query Language) is one of the most widely used query
languages.
6. Transactions: Transactions are used to ensure data consistency and integrity within
a database.
If any one of these operations fails, the entire transaction is rolled back, ensuring
the database remains consistent.
Cont…
This document should include the data elements, data attributes, data values,
and relationships between data elements that are required.
The requirements specification should also include data access and security
requirements, including who has access to the data and how it will be
protected.
Cont…
This will return all the data from the "first_name" column in the
"customer" table.
1.5 Using clause to sort query output
particular function. Clauses are used to specify the conditions for the retrieval
1. SELECT Clause: This clause is used to retrieve data from one or more
database tables. It allows you to specify the specific columns to retrieve, the
2. WHERE Clause: This clause is used to filter out specific records based on
a specified condition. It is used to select only specific rows that meet your
criteria.
This query uses the WHERE clause to filter the employees table and select
all employees whose department is 'Sales'.
Cont…
• 3. JOIN Clause: This clause is used to combine data from two or more tables into a single table.
It is used to relate data between tables when there is a relationship between them.
This query uses the JOIN clause to join the "customers" and "orders" tables on the
customer_id field, in order to retrieve the name and order_date of customers who have placed
orders.
4. GROUP BY Clause: This clause is used to group data based on one or more columns. It is
used to aggregate data and perform calculations on subsets of data.