SlideShare uma empresa Scribd logo
1 de 24
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

Mais conteúdo relacionado

Mais procurados

Constraints In Sql
Constraints In SqlConstraints In Sql
Constraints In Sql
Anurag
 

Mais procurados (20)

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)
 
Structured query language(sql)ppt
Structured query language(sql)pptStructured query language(sql)ppt
Structured query language(sql)ppt
 
Oracle SQL Basics
Oracle SQL BasicsOracle SQL Basics
Oracle SQL Basics
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
 
Constraints In Sql
Constraints In SqlConstraints In Sql
Constraints In Sql
 
Create table
Create tableCreate table
Create table
 
SQL for interview
SQL for interviewSQL for interview
SQL for interview
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
 
PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts
 
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
 
Sql subquery
Sql  subquerySql  subquery
Sql subquery
 
SQL JOINS
SQL JOINSSQL JOINS
SQL JOINS
 
Sql ppt
Sql pptSql ppt
Sql ppt
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
 
SQL Queries
SQL QueriesSQL Queries
SQL Queries
 
MYSQL.ppt
MYSQL.pptMYSQL.ppt
MYSQL.ppt
 
Introduction to sql
Introduction to sqlIntroduction to sql
Introduction to sql
 
Sql(structured query language)
Sql(structured query language)Sql(structured query language)
Sql(structured query language)
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
 
PL/SQL TRIGGERS
PL/SQL TRIGGERSPL/SQL TRIGGERS
PL/SQL TRIGGERS
 

Semelhante a Basic SQL and History

Semelhante a Basic SQL and History (20)

12 SQL
12 SQL12 SQL
12 SQL
 
12 SQL
12 SQL12 SQL
12 SQL
 
chapter-14-sql-commands.pdf
chapter-14-sql-commands.pdfchapter-14-sql-commands.pdf
chapter-14-sql-commands.pdf
 
Database Management Lab -SQL Queries
Database Management Lab -SQL Queries Database Management Lab -SQL Queries
Database Management Lab -SQL Queries
 
PO WER - Piotr Mariat - Sql
PO WER - Piotr Mariat - SqlPO WER - Piotr Mariat - Sql
PO WER - Piotr Mariat - Sql
 
Ankit
AnkitAnkit
Ankit
 
sql-commands.pdf
sql-commands.pdfsql-commands.pdf
sql-commands.pdf
 
Sql commands
Sql commandsSql commands
Sql commands
 
Sql commands
Sql commandsSql commands
Sql commands
 
SQL2.pptx
SQL2.pptxSQL2.pptx
SQL2.pptx
 
DBMS Part-3.pptx
DBMS Part-3.pptxDBMS Part-3.pptx
DBMS Part-3.pptx
 
Assignment#01
Assignment#01Assignment#01
Assignment#01
 
Rdbms day3
Rdbms day3Rdbms day3
Rdbms day3
 
T-SQL Overview
T-SQL OverviewT-SQL Overview
T-SQL Overview
 
Introduction to SQL..pdf
Introduction to SQL..pdfIntroduction to SQL..pdf
Introduction to SQL..pdf
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
 
lovely
lovelylovely
lovely
 
4.Database Management System.pdf
4.Database Management System.pdf4.Database Management System.pdf
4.Database Management System.pdf
 
Bank mangement system
Bank mangement systemBank mangement system
Bank mangement system
 
Sql ppt
Sql pptSql ppt
Sql ppt
 

Último

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 

Último (20)

SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 

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) 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
  • 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