SlideShare a Scribd company logo
Someshwar M. Moholkar
WCBT, Solapur
(Dept.of Bioinformatics)
What is SQL
 Structured Query Language
 Communicate with databases
 Used to created and edit databases
 Also used to create queries ,forms and reports
History of SQL
 SQL: Structured Query Language
 SQL is based on the relational tuple calculus
 SEQUEL: Structured English Query Language; part of
SYSTEM R, 1974
 SQL/86: ANSI & ISO standard
 SQL/89: ANSI & ISO standard
 SQL/92 or SQL2: ANSI & ISO standard
 SQL3: in the works...
 SQL2 supported by ORACLE, SYBASE, INFORMIX,
IBM DB2, SQL SERVER, OPENINGRES,...
SQL
SQL consists of the following parts:
 Data Definition Language (DDL)
 Interactive Data Manipulation Language (Interactive
DML)
 Embedded Data Manipulation Language (Embedded
DML)
 Views
 Integrity
SQL Commands
The standard SQL COMMANDS are CREATE ,SELECT,
INSERT,UPDATE,DELETE and DROP.
DDL
Command Description
CREATE creates a new table or other object in database
ALTER Modifying an existing database object
DROP Deletes an entire table
DML (Data Manipulation Language)
Command Description
INSERT Creates a record
UPDATE Modifies records
DELETE Deletes records
DCL(Data Control Language)
Commands Description
GRANT Gives a privilege to user
REVOKE Takes back privilege granted from user
SQL
 Data Definition Language (DDL)
 Create/alter/delete tables and their attributes
 Following lectures...
 Data Manipulation Language (DML)
 Query one or more tables – discussed next !
 Insert/delete/modify tuples in tables
PRIMARY Key:
A Primary key is a field in a table uniquely
Identifies each row/record in a database table. Primary
Keys must contains unique values.
A table can have only
one primary key, which may consist of single or multiple
fields. When multiple fields are used as a primary key,
they are called a ‘composite key’.
sql>create table customers
2(
id int(12)
3 name varchar (20) ,
4 age int(2),
5 address char (25) ,
6 salary decimal (18, 2),
7 primary key (id, name)
);
FOREIGN Key:
A foreign key is a key used to link two
tables together. This is sometimes called a
referencing key.
Foreign Key is a column or
a combination of columns whose values
match a Primary Key in a different table.
Data
Integrity
Data Integrity
Data Integrity:
 Entity Integrity : There are no duplicate rows in a
table.
Domain Integrity : Enforces valid entries for a
given column by restricting the type, the format,
or the range of values.
Referential Integrity : Rows cannot be deleted
which are used by other records.
User-Defined Integrity : Enforces some specific
business rules that do not fall into entity, domain,
or referential integrity.
Database Normalization
Database Normalization
Database Normalization
Database normalization is the process of
efficiently organizing data in a database. There are
two reasons of the normalization process:
 Eliminating redundant data, for example, storing
the same data in more than one table.
 Ensuring data dependencies make sense.
Types of Normalization
 First Normal Form (1NF)
 Second Normal Form (2NF)
 Third Normal Form (3NF)
First Normal Form:
 Define the data items required, because
they become the columns in a table. Place
related data items in a table.
 Ensure that there are no repeating groups
of data.
 Ensure that there is a primary key.
Second Normal Form:
Second normal form states that it should meet
all the rules for 1NF and there must be no partial
dependences of any of the columns on the primary key.
Third Normal Form:
A table is in third normal form when the following
conditions are met:
 It is in second normal form.
 All nonprimary fields are dependent on the primary key.
SQL Data types
 String types
 CHAR(n) – fixed-length character data, n characters long
Maximum length = 2000 bytes
 VARCHAR2(n) – variable length character data, maximum
4000 bytes
 LONG – variable-length character data, up to 4GB. Maximum
1 per table
 Numeric types
 NUMBER(p,q) – general purpose numeric data type
 INTEGER(p) – signed integer, p digits wide
 FLOAT(p) – floating point in scientific notation with p binary
digits precision
 Date/time type
 DATE – fixed-length date/time in dd-mm-yy form
Available statements
SQL (1/2)
Giacomo.Govi@cern.ch 20
Statement Description
SELECT Data retrieval
INSERT
UPDATE
DELETE
Data Manipulation Language (DML)
CREATE
ALTER
DROP
RENAME
TRUNCATE
Data Definition Language (DDL)
COMMIT
ROLLBACK
SAVEPOINT
Transaction Control
GRANT
REVOKE
Data Control Language (DCL)
Rows
Tables/Objects
Manages
DML
SQL & Tools
 SQL statements can be submitted via:
 DB API’s for programming languages (C, C++, Java,
Python, PHP, …)
 GUI applications (Excel, Access)
 stored procedures (PL/SQL, Java)
 Oracle tools (Reports, Forms, Designer…)
 SQL*Plus (Oracle!) is the basic tool to submit
SQL commands (available on all CERN
platforms).
Summary
What is SQL
History of SQL
SQL Commands
PRIMARY Key
Data Integrity
Database Normalization
SQL Data types
References
Go to http://sqlcourse.com/drop.html
http://sqlcourse.com/insert.html
 http://www.benthicsoftware.com/
 Sprouse, W. and Anderson, A. B. Land Condition Trend
Analysis (LCTA)
 Simply Easy Learning by tutorialspoint.com
 Basic SQL and History
Ad

More Related Content

What's hot (20)

Structured query language(sql)ppt
Structured query language(sql)pptStructured query language(sql)ppt
Structured query language(sql)ppt
Gowarthini
 
Sql(structured query language)
Sql(structured query language)Sql(structured query language)
Sql(structured query language)
Ishucs
 
Structured Query Language (SQL)
Structured Query Language (SQL)Structured Query Language (SQL)
Structured Query Language (SQL)
Syed Hassan Ali
 
SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
Smriti Jain
 
SQL Basics
SQL BasicsSQL Basics
SQL Basics
Hammad Rasheed
 
SQL Queries
SQL QueriesSQL Queries
SQL Queries
Nilt1234
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
SQL commands
SQL commandsSQL commands
SQL commands
GirdharRatne
 
Sql Tutorials
Sql TutorialsSql Tutorials
Sql Tutorials
Priyabrat Kar
 
SQL Queries Information
SQL Queries InformationSQL Queries Information
SQL Queries Information
Nishant Munjal
 
Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)
Punjab University
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
Sachidananda M H
 
What is SQL Server?
What is SQL Server?What is SQL Server?
What is SQL Server?
CPD INDIA
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
Ram Kedem
 
Sql - Structured Query Language
Sql - Structured Query LanguageSql - Structured Query Language
Sql - Structured Query Language
Wan Hussain Wan Ishak
 
SQL : introduction
SQL : introductionSQL : introduction
SQL : introduction
Shakila Mahjabin
 
MYSQL.ppt
MYSQL.pptMYSQL.ppt
MYSQL.ppt
webhostingguy
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
Rumman Ansari
 
Types Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql ServerTypes Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql Server
programmings guru
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
Shrija Madhu
 
Structured query language(sql)ppt
Structured query language(sql)pptStructured query language(sql)ppt
Structured query language(sql)ppt
Gowarthini
 
Sql(structured query language)
Sql(structured query language)Sql(structured query language)
Sql(structured query language)
Ishucs
 
Structured Query Language (SQL)
Structured Query Language (SQL)Structured Query Language (SQL)
Structured Query Language (SQL)
Syed Hassan Ali
 
SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
Smriti Jain
 
SQL Queries
SQL QueriesSQL Queries
SQL Queries
Nilt1234
 
SQL Queries Information
SQL Queries InformationSQL Queries Information
SQL Queries Information
Nishant Munjal
 
Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)
Punjab University
 
What is SQL Server?
What is SQL Server?What is SQL Server?
What is SQL Server?
CPD INDIA
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
Ram Kedem
 
Types Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql ServerTypes Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql Server
programmings guru
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
Shrija Madhu
 

Similar to Basic SQL and History (20)

12 SQL
12 SQL12 SQL
12 SQL
Praveen M Jigajinni
 
12 SQL
12 SQL12 SQL
12 SQL
Praveen M Jigajinni
 
chapter-14-sql-commands.pdf
chapter-14-sql-commands.pdfchapter-14-sql-commands.pdf
chapter-14-sql-commands.pdf
study material
 
Database Management Lab -SQL Queries
Database Management Lab -SQL Queries Database Management Lab -SQL Queries
Database Management Lab -SQL Queries
shamim hossain
 
PO WER - Piotr Mariat - Sql
PO WER - Piotr Mariat - SqlPO WER - Piotr Mariat - Sql
PO WER - Piotr Mariat - Sql
Zespół Szkół nr 26
 
Ankit
AnkitAnkit
Ankit
Ankit Dubey
 
SQL commands powerpoint presentation. Ppt
SQL commands powerpoint presentation. PptSQL commands powerpoint presentation. Ppt
SQL commands powerpoint presentation. Ppt
umadevikakarlapudi
 
sql-commands.pdf
sql-commands.pdfsql-commands.pdf
sql-commands.pdf
Prof. Dr. K. Adisesha
 
Sql commands
Sql commandsSql commands
Sql commands
Prof. Dr. K. Adisesha
 
Sql commands
Sql commandsSql commands
Sql commands
Prof. Dr. K. Adisesha
 
SQL2.pptx
SQL2.pptxSQL2.pptx
SQL2.pptx
RareDeath
 
DBMS Part-3.pptx
DBMS Part-3.pptxDBMS Part-3.pptx
DBMS Part-3.pptx
Prof. Dr. K. Adisesha
 
Assignment#01
Assignment#01Assignment#01
Assignment#01
Sunita Milind Dol
 
Rdbms day3
Rdbms day3Rdbms day3
Rdbms day3
Nitesh Singh
 
T-SQL Overview
T-SQL OverviewT-SQL Overview
T-SQL Overview
Ahmed Elbaz
 
HPD SQL Training - Beginner - 20220916.pptx
HPD SQL Training - Beginner - 20220916.pptxHPD SQL Training - Beginner - 20220916.pptx
HPD SQL Training - Beginner - 20220916.pptx
PatriceRochon1
 
DATA MANAGEMENT computer science class 12 unit - 3 notes.pdf
DATA MANAGEMENT computer science class 12 unit - 3 notes.pdfDATA MANAGEMENT computer science class 12 unit - 3 notes.pdf
DATA MANAGEMENT computer science class 12 unit - 3 notes.pdf
NeetuPrasad16
 
Introduction to SQL..pdf
Introduction to SQL..pdfIntroduction to SQL..pdf
Introduction to SQL..pdf
mayurisonawane29
 
lovely
lovelylovely
lovely
love0323
 
Introduction to sql
Introduction to sqlIntroduction to sql
Introduction to sql
VARSHAKUMARI49
 
Ad

Recently uploaded (20)

SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
SPRING FESTIVITIES - UK AND USA -
SPRING FESTIVITIES - UK AND USA            -SPRING FESTIVITIES - UK AND USA            -
SPRING FESTIVITIES - UK AND USA -
Colégio Santa Teresinha
 
Political History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptxPolitical History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
LDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini UpdatesLDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini Updates
LDM Mia eStudios
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...
Sandeep Swamy
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
LDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini UpdatesLDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini Updates
LDM Mia eStudios
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...
Sandeep Swamy
 
Ad

Basic SQL and History

  • 1. Someshwar M. Moholkar WCBT, Solapur (Dept.of Bioinformatics)
  • 2. What is SQL  Structured Query Language  Communicate with databases  Used to created and edit databases  Also used to create queries ,forms and reports
  • 3. History of SQL  SQL: Structured Query Language  SQL is based on the relational tuple calculus  SEQUEL: Structured English Query Language; part of SYSTEM R, 1974  SQL/86: ANSI & ISO standard  SQL/89: ANSI & ISO standard  SQL/92 or SQL2: ANSI & ISO standard  SQL3: in the works...  SQL2 supported by ORACLE, SYBASE, INFORMIX, IBM DB2, SQL SERVER, OPENINGRES,...
  • 4. SQL SQL consists of the following parts:  Data Definition Language (DDL)  Interactive Data Manipulation Language (Interactive DML)  Embedded Data Manipulation Language (Embedded DML)  Views  Integrity
  • 5. SQL Commands The standard SQL COMMANDS are CREATE ,SELECT, INSERT,UPDATE,DELETE and DROP. DDL Command Description CREATE creates a new table or other object in database ALTER Modifying an existing database object DROP Deletes an entire table
  • 6. DML (Data Manipulation Language) Command Description INSERT Creates a record UPDATE Modifies records DELETE Deletes records
  • 7. DCL(Data Control Language) Commands Description GRANT Gives a privilege to user REVOKE Takes back privilege granted from user
  • 8. SQL  Data Definition Language (DDL)  Create/alter/delete tables and their attributes  Following lectures...  Data Manipulation Language (DML)  Query one or more tables – discussed next !  Insert/delete/modify tuples in tables
  • 9. PRIMARY Key: A Primary key is a field in a table uniquely Identifies each row/record in a database table. Primary Keys must contains unique values. A table can have only one primary key, which may consist of single or multiple fields. When multiple fields are used as a primary key, they are called a ‘composite key’.
  • 10. sql>create table customers 2( id int(12) 3 name varchar (20) , 4 age int(2), 5 address char (25) , 6 salary decimal (18, 2), 7 primary key (id, name) );
  • 11. FOREIGN Key: A foreign key is a key used to link two tables together. This is sometimes called a referencing key. Foreign Key is a column or a combination of columns whose values match a Primary Key in a different table.
  • 13. Data Integrity:  Entity Integrity : There are no duplicate rows in a table. Domain Integrity : Enforces valid entries for a given column by restricting the type, the format, or the range of values. Referential Integrity : Rows cannot be deleted which are used by other records. User-Defined Integrity : Enforces some specific business rules that do not fall into entity, domain, or referential integrity.
  • 15. Database Normalization Database normalization is the process of efficiently organizing data in a database. There are two reasons of the normalization process:  Eliminating redundant data, for example, storing the same data in more than one table.  Ensuring data dependencies make sense.
  • 16. Types of Normalization  First Normal Form (1NF)  Second Normal Form (2NF)  Third Normal Form (3NF)
  • 17. First Normal Form:  Define the data items required, because they become the columns in a table. Place related data items in a table.  Ensure that there are no repeating groups of data.  Ensure that there is a primary key.
  • 18. Second Normal Form: Second normal form states that it should meet all the rules for 1NF and there must be no partial dependences of any of the columns on the primary key. Third Normal Form: A table is in third normal form when the following conditions are met:  It is in second normal form.  All nonprimary fields are dependent on the primary key.
  • 19. SQL Data types  String types  CHAR(n) – fixed-length character data, n characters long Maximum length = 2000 bytes  VARCHAR2(n) – variable length character data, maximum 4000 bytes  LONG – variable-length character data, up to 4GB. Maximum 1 per table  Numeric types  NUMBER(p,q) – general purpose numeric data type  INTEGER(p) – signed integer, p digits wide  FLOAT(p) – floating point in scientific notation with p binary digits precision  Date/time type  DATE – fixed-length date/time in dd-mm-yy form
  • 20. Available statements SQL (1/2) [email protected] 20 Statement Description SELECT Data retrieval INSERT UPDATE DELETE Data Manipulation Language (DML) CREATE ALTER DROP RENAME TRUNCATE Data Definition Language (DDL) COMMIT ROLLBACK SAVEPOINT Transaction Control GRANT REVOKE Data Control Language (DCL) Rows Tables/Objects Manages DML
  • 21. SQL & Tools  SQL statements can be submitted via:  DB API’s for programming languages (C, C++, Java, Python, PHP, …)  GUI applications (Excel, Access)  stored procedures (PL/SQL, Java)  Oracle tools (Reports, Forms, Designer…)  SQL*Plus (Oracle!) is the basic tool to submit SQL commands (available on all CERN platforms).
  • 22. Summary What is SQL History of SQL SQL Commands PRIMARY Key Data Integrity Database Normalization SQL Data types
  • 23. References Go to http://sqlcourse.com/drop.html http://sqlcourse.com/insert.html  http://www.benthicsoftware.com/  Sprouse, W. and Anderson, A. B. Land Condition Trend Analysis (LCTA)  Simply Easy Learning by tutorialspoint.com