0% found this document useful (0 votes)
58 views5 pages

Introduction Mysql, DDL, DML and Keys

Structured Query Language (SQL) is a standard language used for creating, accessing, and managing relational database systems. SQL commands are used to define database schemas, manipulate data, retrieve queries, and provide security. SQL has strong data processing capabilities and allows users to insert, update, delete, and retrieve multiple records with a single statement. It is a powerful yet easy to use language for interacting with relational database management systems.

Uploaded by

Evil Op
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
58 views5 pages

Introduction Mysql, DDL, DML and Keys

Structured Query Language (SQL) is a standard language used for creating, accessing, and managing relational database systems. SQL commands are used to define database schemas, manipulate data, retrieve queries, and provide security. SQL has strong data processing capabilities and allows users to insert, update, delete, and retrieve multiple records with a single statement. It is a powerful yet easy to use language for interacting with relational database management systems.

Uploaded by

Evil Op
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 5

Structured Query

10 Language (SQL)
10.1 INTRODUCTION

Management System (DBMS) is not a new


concept and was first implemented in the
ha nassage of time, database technologies evolved 1960s.
while usage and
Aatabases have increased immensely. There is expected functionalities
organization which is not managing its data
no
nd records using any type ot DBMS. An online
telephone directory would definitely use DBMS to
ctare data pertaining to people, phone numbers and other contact details.
plectricity service provider uses a DBMS to
Apart from this, your
manage billing,
client related issues, to handle fault
data, etc. Facebook needs to store,
manipulate and present data related to members, their friends,
member activities, messages, advertisements and a lot more. All these real-life
some DBMS to manipulate and handle this enormous data.
applications require
DBMS requires some
and manipulate its data which is known as Structured
language to handle
Query Language (SQL).

PaVANd

facebook 0g

Sign Up
IRs free and always will be.

Online Telephone Directory Electricity Billing System

In the previous chapter, you have learnt about database concepts related to SQL. This chapter
deals exclusively with relational databases, its tables and retrieving the data using Structured
Query Language (SQL.).

10.2 0VERVIEW OF SQL AND MySQL


SQL (Structured Query Language) is a standard language
1Or accessing and manipulating databases. SQL commands
dre used to create, transform and retrieve intormation

om Relational Database Management Systems


and also
SOL
Create an interface between the user and database.

By using SQL. commands, one can search any data in the


tables,
functions like create
dtabase and perform other Fig. 10.1: Structured Query Language (SQL)
rows, drop table, erc.
dud
records, modify data, remove
MysQL is an open source and freely available Relational Database
Management System (RDBMS) that uses Structured Query
Language (SQL). It provides excellent features for creating, storing,
maintaining and accessing data stored in the form of databases and
their
tables
respective tables.
at a
A single MySQL database
time and thousands of records in it.
can store several My5QL
Being an open source software, it can be downloaded freely and
easily from www.mysql.ora
MySQL is developed and supported by a Sweden-based
reliable and faster, and company, MysQL AB. It is fully secured,
possesses better functionalities than many other commercial
available in the market. RDBMSS

10.3 FEATURES OF SQL


SQL is the most common
language used to create, operate, update, manipulate and communicate
with a database.
SQL was developed in 1970 by Donald D. Chamberlin and Raymond F. Bovre
is
atIBM. T , SQL
a fourth generation non-procedural language that is used to create,
databases (relations). In other
m late and process
words, these languages describe what data be
inserted and trieved,
updated or deleted from a database.
It has the following salient features and strong processing capabilities:
It can retrieve data from database
a
through Query processing.
It can insert records in a database.
It can update records in a database.
It can create databases and
new
modify the existing ones.
It can create new tables in a database.
I t can create views in a database.
It can allow modifying security settings for the system.
CTM: SQL (Structured Query Language) is uniñed,
a
non-procedural language used for creating
accessing, handling and managing data in relational databases.

10.4 ADVANTAGES OF sQL


SQL has the following advantages
1. Ease of use: It is very easy to learn and use and does not require high-end professional
training to work upon it.

2 Large volume of databases can be handled quite easily.


3. No coding required: It is non-procedural and a unified language, i.e., we need not spg
the procedures to accomplish a task but only need to give a command to perforn
All SQL operations are performed at a prescribed and fixed
Powerta language: level, i.e.,
erful and can retrieve data from multiple rows and one MODIFY command
cslLECT co
S E L E C T c o m m a n d

neSE

multiple
rows at a time. These features
make SQL a very
powerful language as
edit other languages where one command can
process a single record at a time.
compared
rovides aa high
high l.level of well-defined set of commands that provides desirable
Reliable:SsQL provides
any ambiguity.
results
with
cdata abstraction: SQL provides a greater degree of freedom of abstraction
Freedon

compared to any other


procedural language.
lete language for a database: Apart from being a strong query-processing language,
I0 Comp.

also be used to create, insert, delete and control access to data in databases.
i tcan

10.5
CLASSIFICATION OF SQL STATEMENTS
nguage that is used
that is us to interact with the database. The SQL statements or commands
language
is a
are the
statement that are regarded as instructions to the database.
thatwe type
erent
SQL provides differe types of statements or commands for different purposes. These

statements
are classified into the !following categories:
sQL Statements

Data Definition Data Manipulation Data Contro Transaction Control


Language (TCL)
Language (DDL) Language (DML) Language (DCL)
Fig. 10.2: Classification of SQL Statements

We shall now discuss DDL and DML commands in detail.

Commands
0.5.1 Data Definition Language (DDL) sQL
database tables
The DDL part of SQL permits
defines indices
to be created or deleted. It also
DML
links between tables and imposes
DDL
(keys), specifies
tables. It contains necessary
constraints on INSERT
DROP CREATE
statements for creating, manipulating,
altering and
ALTER UPDATE
deleting the table.
DELETE
Examples of DDL commands in SQL are:
DATABASE-creates a new
database. Fig.10.3: Most Commonly-used SQL Commands
CREATE
an already existing database.
USE command-to select and open

CREATE TABLE-creates a new table.


a table.
ALTER TABLE-modifies
a table.
DROP TABLE-deletes structure and its related operations.
database
define the
lets you
CTM: The DDL command
tne
structure and access d hu
methods used by
definitions to specily soage
DDL provides a set of a n d relevant data types.
defines proper
and also
ne database system
10.3
10.5.2 Data Manipulation Language (DML) Commands
Data Manipulation Language (DM)
data. DML statements are
is a part of sQI. that helps a user to
access a
orr manipulate
executed in the torm o (querioCs Which are
handled hy. the DMI.
compiler. It contains a set of statements to
retrieve data fronm the tables ofthe database.
insert data into the tables otf the datalbase.
3. delete data from the tables of the database.
update data among the rows/records in the tables of the database.
DML commands carry out query processing operations and manipulate data in the datat
objects. Several DML commands available are: abase
1. SELECT statementTo extract information fron the table. It may or
of certain conditions/criteria. may not be on the hasies
2. INSERT INTO statement-To insert new data
(record) into a table.
3. UPDATE statementTo modify or
change the data
(tuple) in a table (not modifying the data type of Learning Tip: The query and
column). update commands form the DML
4. DELETETo delete data (tuple) from a table part of SQL. It enables the user to
a column).
(not deleting access or
manipulate data stored
in a database.

Note: DCL and TCL commands are


beyond the scope of this book.

Table 10.1: Difference between DDL and DML


Commands
DDL Commands
1. DDL stands for Data
DML Commands
Definition Language. 1. DML stands for Data Manipulation
2 These commands allow us to perform tasks
Language
2. These commands are used to
related to data definition, i.e., related to the manipulate
data, i.e., records or rows in a table or
structure of the database objects
(relations/ relation.
databases).
3. Examples of DDL commands are Create, 3. Examples of DML commands are
Alter, Drop, Grant, Revoke, etc. Insert
into, Update, Delete, Select, etc.
4 DDL is not further classified. 4. DML is further classified into two
types
(a) Procedural DMLs
(b) Non-procedural DMLs
et us start implementing SQL using My$QL as the nlatform
9.5 DATABASE KEYS
Keys are a very important part of Relational database. They allow us to identify
attribute an
or a set of attributes on the basis of which a table is identified.
They are used to establish and
uentify relation between two or more tables. They also ensure that each record within
a table
can be uniquely identified
by combination of one or more fields within a table.
a

The different types of keys in an RDBMS are as follows:

KEY
DESCRIPTION
Primary Key A primary key an attribute or a group of attributes that can
is
uniquely identify tuples within the relation.
Candidate Key A candidate key is one that is
capable of becoming the primary key
(i.e., candidate for primary key
position).
Alternate Key A candidate key that is not the
primary key is called an alternate key
Foreign Key A non-key attribute whose
value(s) are derived from the primary key
of some other table is known
as foreign key in its current table.
Let us discuss these kevs in detail

You might also like