0% found this document useful (0 votes)
2 views35 pages

PPT1 - SQL and Database - Introduction

The document provides an introduction to databases and SQL, covering definitions, types of databases, and the functionalities of SQL. It outlines various SQL commands categorized into DDL, DML, DQL, DCL, and TCL, along with examples of basic queries. Additionally, it mentions graphical user interfaces for SQL management, such as SSMS and MySQL Workbench.

Uploaded by

vinuthaskgowda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views35 pages

PPT1 - SQL and Database - Introduction

The document provides an introduction to databases and SQL, covering definitions, types of databases, and the functionalities of SQL. It outlines various SQL commands categorized into DDL, DML, DQL, DCL, and TCL, along with examples of basic queries. Additionally, it mentions graphical user interfaces for SQL management, such as SSMS and MySQL Workbench.

Uploaded by

vinuthaskgowda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 35

SQL and Database -

Introduction
Praveen Kumar R
Agenda
▪ A bit of myself
▪ What is a Database?
▪ Types of Database
▪ What is SQL?
▪ Where is SQL used?
▪ Few Basic Queries
▪ Summary

9/20/2023 SQL and Database - Introduction 2


A bit of myself
▪ B.E in Computer Science
▪ A Software Engineer with 5+ years of
experience
▪ Certified RPA Professional by role
▪ I build software robots and make human life
easier on a day-to-day basis
▪ Provided Industry level trainings on RPA tools

9/20/2023 SQL and Database - Introduction 3


So, Let’s Get Started…
What is Database?
▪ A database is a collection of organized data that is stored and
accessed electronically.
▪ Databases are used to store and manage large amounts of
data, including structured and unstructured data.
▪ Databases are typically stored on a computer system and are
usually controlled by a database management system (DBMS).
▪ Small databases can be stored on a file system, while large
databases are hosted on computer clusters or cloud storage.

9/20/2023 SQL and Database - Introduction 5


Information stored in database
What kind of information we can store in a database?
We can store all the information that is required for an
application to function.
For e.g., If we are building any eCommerce website (flipkart or
amazon), we need databases to store:
•Customer data, like usernames, email addresses, and preferences.
•Business data, like products, product colors, prices, and ratings.
•Relationship data, like the locations of stores with a specific product
in stock.

9/20/2023 SQL and Database - Introduction 6


Types of Database
There are many types of Databases available in the market. But
the main types are listed below:
▪ Hierarchical Databases
▪ Network Databases
▪ Object-Oriented Databases
▪ Relational Databases

Apart from the above ones, we also have NoSQL DBs, Centralized
DBs, Cloud DBs etc.

9/20/2023 SQL and Database - Introduction 7


• A hierarchical database is DBMS that represents data in a tree-like
form.
Hierarchical • The relationship between records is one-to-many. That means one
parent node can have many child nodes.
Databases • A hierarchical database model is a data model where data is stored
as records but linked in a tree-like structure with the help of a
parent and child level.
• Each record has only one parent. The first record of the data model
is a root record.

9/20/2023 SQL and Database - Introduction 8


Network
Databases
• This is an extension of Hierarchical
model.
• In this database, the data is organized
more like a graph, and are allowed to
have more than one parent.
• Since the data is more related as we can
establish more relationships, accessing
the data is easier and faster in this
model.
• This model was used to map many-to-
many data relationships.

9/20/2023 SQL and Database - Introduction 9


Object-Oriented Databases
• Object-oriented databases store and manage data in
the form of objects.
• This database type uses object-
oriented programming languages to create and
manipulate objects, which are then stored in the
database.
• These databases provide significant benefits, such as
code reuse, inheritance, and encapsulation etc.
• These databases are mostly used in programming
languages like Java, Kotlin, C#, Node JS and Swift.

9/20/2023 SQL and Database - Introduction 10


Relational Databases

• A relational database is a type of database that


stores and provides access to data points that
are related to one another.
• In a relational database, each row in the table
is a record with a unique ID called the key.
• The columns of the table hold attributes of the
data, and each record usually has a value for
each attribute, making it easy to establish the
relationships among data points.

9/20/2023 SQL and Database - Introduction 11


Four crucial properties define relational
database transactions: atomicity, consistency,
isolation, and durability—typically referred to
as ACID.
• Atomicity defines all the elements that make
ACID up a complete database transaction.
• Consistency defines the rules for
properties of maintaining data points in a correct state
RDBMS after a transaction.
• Isolation keeps the effect of a transaction
invisible to others until it is committed, to
avoid confusion.
• Durability ensures that data changes
become permanent once the transaction is
committed.
9/20/2023 SQL and Database - Introduction 12
What is SQL?
▪ SQL stands for Structured Query Language.
▪ It is a programming language used to store and process
information in a relational database.
▪ SQL is used to query, add to, remove from, and change
data in a Relational Database Management System
(RDMS)
▪ SQL was first developed at IBM in 1970s to manipulate
and retrieve data stored in IBM’s database product
called System R.

9/20/2023 SQL and Database - Introduction 13


So, what can SQL do?
▪ SQL can execute queries against a database
▪ SQL can retrieve data from a database
▪ SQL can insert records in a database
▪ SQL can update records in a database
▪ SQL can delete records from a database
▪ SQL can create new databases
▪ SQL can create new tables in a database
▪ And A lot more…

9/20/2023 SQL and Database - Introduction 14


Where is SQL used?
▪ SQL is a programming language used to communicate with
relational databases.
▪ SQL allows you to query the database in a variety of ways,
using English-like statements.
▪ It’s used on websites for back-end data storage and data
processing solutions (for example, Facebook uses SQL).
▪ SQL provides CRUD functionality for databases. What does
CRUD stand for?
C – Create R – Read U – Update D – Delete

9/20/2023 SQL and Database - Introduction 15


Different types of SQL commands
SQL commands are like instructions to a table. It is used to perform specific
tasks, functions, and queries of data. SQL can perform various tasks like creating
a table, adding data to tables, dropping the table, modifying the table, set
permission for users.

These SQL commands are mainly categorized into five categories:


1. DDL – Data Definition Language
2. DQL – Data Query Language
3. DML – Data Manipulation Language
4. DCL – Data Control Language
5. TCL – Transaction Control Language

9/20/2023 SQL and Database - Introduction 16


9/20/2023 SQL and Database - Introduction 17
DDL (Data Definition Language)
Data Definition Language consists of the SQL commands that can be used to define
the database schema. DDL commands used to create, modify, and delete database
structures but not data. These commands are normally not used by a general user,
who should be accessing the database via an application.
List of DDL commands:
• CREATE: to create the database or its objects (like table, index, function, views).
• DROP: to delete objects from the database.
• ALTER: to alter the structure of the database.
• TRUNCATE: to remove all records from a table, including all spaces allocated for
the records are removed.
• COMMENT: to add comments to the data dictionary.
• RENAME: to rename an object existing in the database.

9/20/2023 SQL and Database - Introduction 18


DQL (Data Query Language)
DQL can be defined as follows: it is a component of SQL statement that allows
getting data from the database and imposing order upon it.
It includes the SELECT statement. This command allows getting the data out of the
database to perform operations with it.

List of DQL:
SELECT: to retrieve data from the database.

9/20/2023 SQL and Database - Introduction 19


DML (Data Manipulation Language)
The SQL commands that deal with the manipulation of data present in the database
belong to DML or Data Manipulation Language and this includes most of the SQL
statements. It is the component of the SQL statement that controls access to data
and to the database.

List of DML commands:


• INSERT: to insert data into a table.
• UPDATE: to update existing data within a table.
• DELETE: to delete records from a database table.
• LOCK: Table control concurrency.
• CALL: Call a PL/SQL or JAVA subprogram.

9/20/2023 SQL and Database - Introduction 20


DCL (Data Control Language)
DCL includes commands such as GRANT and REVOKE which mainly deal with the
rights, permissions, and other controls of the database system.
These commands are mainly used by the Database Admins who will have the full
control rights.

List of DCL commands:


• GRANT: This command gives users access privileges to the database.
• REVOKE: This command withdraws the user’s access privileges given by using the
GRANT command.

9/20/2023 SQL and Database - Introduction 21


TCL (Transaction Control Language)
Transactions group a set of tasks into a single execution unit. Each transaction
begins with a specific task and ends when all the tasks in the group are successfully
completed. If any of the tasks fail, the transaction fails. Therefore, a transaction has
only two results: success or failure.

List of TCL commands:


• BEGIN: Opens a Transaction.
• COMMIT: Commits a Transaction.
• ROLLBACK: Rollbacks a transaction in case of any error occurs.
• SAVEPOINT: Sets a save point within a transaction.

9/20/2023 SQL and Database - Introduction 22


Let’s look at few basic queries
To get the current version of MySQL and to know today’s date:

mysql> SELECT VERSION(), CURRENT_DATE;


+-----------+--------------+
| VERSION() | CURRENT_DATE |
+-----------+--------------+
| 8.0.34 | 2023-11-25 |
+-----------+--------------+
1 row in set (0.00 sec)

▪ Note that most MySQL commands end with a semicolon (;)


▪ MySQL returns the total number of rows found, and the total time to execute the query.
▪ MySQL commands/queries are case-insensitive.
▪ Above command can be written in below ways too:
mysql> select version(), current_date;
mysql> SeLeCt vErSiOn(), current_DATE;

9/20/2023 SQL and Database - Introduction 23


Let’s look at few basic queries
It demonstrates that mysql can be used as a simple calculator:

mysql> SELECT SIN(PI()/4), (4+1)*5;


+-------------+---------+
| SIN(PI()/4) | (4+1)*5 |
+-------------+---------+
| 0.707107 | 25 |
+-------------+---------+
1 row in set (0.00 sec)

9/20/2023 SQL and Database - Introduction 24


Multi-Line Commands
• mysql determines where your statement ends by looking for the terminating semicolon, not
by looking for the end of the input line.

Here's a simple multiple-line statement:

mysql> SELECT
-> USER()
-> ,
-> CURRENT_DATE;
+--------------------+--------------+
| USER() | CURRENT_DATE |
+--------------------+--------------+
| joesmith@localhost | 1999-03-18 |
+--------------------+--------------+

9/20/2023 SQL and Database - Introduction 25


Canceling a Command
• If you don't want to execute a command that you are in the process of entering, cancel it by typing \c

mysql> SELECT
-> USER()
-> \c
mysql>

9/20/2023 SQL and Database - Introduction 26


Using a Database
• To create a new database, issue the “create database” command:
mysql> create database webdb;
Note: Database names are case sensitive

• To the select a database, issue the “use” command:


mysql> use webdb;

• To see what database is selected


mysql> select database();

9/20/2023 SQL and Database - Introduction 27


Creating a Table
mysql> CREATE TABLE pet ( mysql> show tables;
-> name VARCHAR(20), +------------------+
-> owner VARCHAR(20), | Tables_in_test |
-> species VARCHAR(20), +------------------+
-> sex CHAR(1), | pet |
-> birth DATE, death DATE); +------------------+
Query OK, 0 rows affected (0.04 sec) 1 row in set (0.01 sec)

9/20/2023 SQL and Database - Introduction 28


Describing Tables
To view a table structure, use the DESCRIBE command:

9/20/2023 SQL and Database - Introduction 29


Loading Data
Use the INSERT statement to enter data into a table.

INSERT INTO pet VALUES


('Puffball','Diane','hamster','f',
'1999-03-30',NULL);

9/20/2023 SQL and Database - Introduction 30


Deleting a Table
To delete an entire table, use the DROP TABLE command:

mysql> drop table pet;


Query OK, 0 rows affected (0.02 sec)

9/20/2023 SQL and Database - Introduction 31


SSMS GUI
example
•In the screenshot, you can
see the Graphical User
Interface of SQL Server
Management Studio
(Microsoft’s free database
app).

9/20/2023 SQL and Database - Introduction 32


MySQL
Workbench
GUI example
•In the screenshot, you can
see the Graphical User
Interface of My SQL
Workbench.
•MySQL Workbench will be
used for this course.

9/20/2023 SQL and Database - Introduction 33


Summary
• Introduction to Database – Definition, types of Databases, information stored
• What is SQL, what can SQL do etc.
• Different SQL commands (DDL, DML, DQL, DCL & TCL)
• Few basic queries
• GUI interfaces of SSMS and MySQL Workbench

9/20/2023 SQL and Database - Introduction 34


Thank you
Praveen Kumar R
Industry Level Trainer

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy