SlideShare a Scribd company logo
Er. Nawaraj Bhandari
Topic 7
SQL 1
Objectives of SQL
 Create the database and relation structures
 Perform basic tasks such as inserts, updates and deletes
 Simple and complex queries
Structured Query Language
Data Definition Language: DDL
 For defining database structures and controlling access to data
 CREATE TABLE, CREATE INDEX , CREATE SEQUENCE , GRANT ACCESS
etc.
Data Manipulation Language: DML
 For retrieving and updating data
 SELECT, INSERT, UPDATE, DELETE
History of SQL - 1
 Developed from IBM’s SYSTEM R
 The database standard language by 1970s...
 First standard published in 1987 by ISO
History of SQL - 2
 Addition to standard published 1989
 SQL 1992 – Major revision ‘SQL-92’
 SQL: 1999 - with object-relational features
 SQL: 2003 - introduced concept of ‘core SQL’
 SQL: 2006 – user of SQL with XML
 SQL: 2008 minor revisions.
Data Manipulation Language: DML
 For retrieving and updating data
 SELECT – retrieving
 INSERT, UPDATE, DELETE – updating
Difference between INSERT and UPDATE?
Literals
 Insert into Student (Stu_id, First_name, Last_name)
 Values (1,’Satpal’,’Singh’);
- Non-numeric in single quotes
- Numeric NOT in quotes
Select branchID, Count(staff_id)
From workers
Where branchType = ‘Main’
Group by branchID
Having Count (staff_id) > 1
Order by branchID
Select branchID, Count(staff_id)
From workers
Where branchType = ‘Main’
Group by branchID
Having Count (staff_id) > 1
Order by branchID
Which columns will appear?
Which table?
Condition
Groups by some column
Value
Restricts what will
Be grouped
Specifies the order of the result
Database Update
 Insert
 Update
 Delete
Insert
 Insert into students (Student_id, first_name, last_name)
 Values (1,’Satpal’,’Singh’);
 Insert into students
 Values (1,’Satpal’,’Singh’,’Overseas’,’Undergrad’);
Update
 Update Students
 Set Student_type = ‘Undergrad’;
 Update Students
 Set student_type = ‘Undergrad’
 Where student_id = 1;
Delete
 Delete from Students;
 Delete from Students
 Where student_id = 1;
Activity
 Departments
 Department_Id Integer
 Department_Name varchar 30
 Location varchar 30
 Departments
 Department_Id Integer
 Department_Name varchar 30
 Location varchar 30
• Insert into Departments
• Values (8,’Complaints’,’Glasgow’):
Commit;
Rollback;
Datatypes
 What is a datatype?
 What is a domain?
String Datatypes
 Character or Char
 Varying Character of Varchar
 Bit (N)
 Bit varying
Char or Varchar
 ‘Gary__’ a 6 long Char
 ‘Gary’ a 6 long varchar
Numeric Datatypes
 Numeric or Decimal, e.g. 8.23 with point set
 Integer, e.g. 8
 Float, e.g. 8.23 but could also be changed so that point moves when
needed
Datetime Types
 Date
 Time
 Timestamp
 Interval
Advantages of SQL
 Universal
 Easy to use
 Fits (more or less) with relational model
Disadvantages of SQL
 Does not support all features of relational model
 No one standard
 Has had to be extended
 Much redundancy – possible to do the same thing many ways
Learning Outcomes – Have We Met Them?
 By the end of this topic, students will be able to:
 Explain the purpose of SQL
 Outline the basic concepts of SQL
 Understand that there are different ‘flavours’ of SQL
References
 Benyon-Davis, P. (2003). Database Systems, 3rd edition. Palgrave Macmillan.
Chapters 11, 12 & 13.
 Connolly, T. & Begg, C. (2004). Database Systems: A Practical Approach to
Design, Implementation, and Management, 4th Edition. Addison Wesley.
Chapters 5, 6 & 7.
 Dietrich, S. W. (2001). Understanding Relational Database Query Languages, 1st
edition. Prentice Hall. Chapter 5.
ANY QUESTIONS?

More Related Content

What's hot

2 database system concepts and architecture
2 database system concepts and architecture2 database system concepts and architecture
2 database system concepts and architectureKumar
 
DDL And DML
DDL And DMLDDL And DML
DDL And DML
pnp @in
 
Object oriented database model
Object oriented database modelObject oriented database model
Object oriented database modelPAQUIAAIZEL
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
Ehsan Hamzei
 
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
 
Dbms
DbmsDbms
SQL Tutorial - Basic Commands
SQL Tutorial - Basic CommandsSQL Tutorial - Basic Commands
SQL Tutorial - Basic Commands
1keydata
 
Sql Server Basics
Sql Server BasicsSql Server Basics
Sql Server Basics
rainynovember12
 
Object relational database management system
Object relational database management systemObject relational database management system
Object relational database management system
Saibee Alam
 
database language ppt.pptx
database language ppt.pptxdatabase language ppt.pptx
database language ppt.pptx
Anusha sivakumar
 
Structured query language(sql)ppt
Structured query language(sql)pptStructured query language(sql)ppt
Structured query language(sql)ppt
Gowarthini
 
8. sql
8. sql8. sql
8. sql
khoahuy82
 
Basic oracle-database-administration
Basic oracle-database-administrationBasic oracle-database-administration
Basic oracle-database-administration
sreehari orienit
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
Basic sql Commands
Basic sql CommandsBasic sql Commands
Basic sql Commands
MUHAMMED MASHAHIL PUKKUNNUMMAL
 
SQL Basics
SQL BasicsSQL Basics
SQL Basics
Hammad Rasheed
 
SQL
SQLSQL
Introduction to Oracle Database
Introduction to Oracle DatabaseIntroduction to Oracle Database
Introduction to Oracle Database
puja_dhar
 
MS-SQL SERVER ARCHITECTURE
MS-SQL SERVER ARCHITECTUREMS-SQL SERVER ARCHITECTURE
MS-SQL SERVER ARCHITECTURE
Douglas Bernardini
 

What's hot (20)

2 database system concepts and architecture
2 database system concepts and architecture2 database system concepts and architecture
2 database system concepts and architecture
 
DDL And DML
DDL And DMLDDL And DML
DDL And DML
 
Object oriented database model
Object oriented database modelObject oriented database model
Object oriented database model
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Dbms
DbmsDbms
Dbms
 
SQL Tutorial - Basic Commands
SQL Tutorial - Basic CommandsSQL Tutorial - Basic Commands
SQL Tutorial - Basic Commands
 
Sql Server Basics
Sql Server BasicsSql Server Basics
Sql Server Basics
 
Object relational database management system
Object relational database management systemObject relational database management system
Object relational database management system
 
database language ppt.pptx
database language ppt.pptxdatabase language ppt.pptx
database language ppt.pptx
 
Structured query language(sql)ppt
Structured query language(sql)pptStructured query language(sql)ppt
Structured query language(sql)ppt
 
8. sql
8. sql8. sql
8. sql
 
Sql ppt
Sql pptSql ppt
Sql ppt
 
Basic oracle-database-administration
Basic oracle-database-administrationBasic oracle-database-administration
Basic oracle-database-administration
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
 
Basic sql Commands
Basic sql CommandsBasic sql Commands
Basic sql Commands
 
SQL Basics
SQL BasicsSQL Basics
SQL Basics
 
SQL
SQLSQL
SQL
 
Introduction to Oracle Database
Introduction to Oracle DatabaseIntroduction to Oracle Database
Introduction to Oracle Database
 
MS-SQL SERVER ARCHITECTURE
MS-SQL SERVER ARCHITECTUREMS-SQL SERVER ARCHITECTURE
MS-SQL SERVER ARCHITECTURE
 

Viewers also liked

Database
DatabaseDatabase
Crosstab query techniques
Crosstab query techniquesCrosstab query techniques
Crosstab query techniquesaabaap
 
computer software
computer softwarecomputer software
computer softwareRiya Gupta
 
Microsoft access 2007_tutorial
Microsoft access 2007_tutorialMicrosoft access 2007_tutorial
Microsoft access 2007_tutorialAchemm Net
 
MS Access 2007 in ITT
MS Access 2007 in ITTMS Access 2007 in ITT
MS Access 2007 in ITT
pillai college
 
Users Guide To Microsoft Word Tables
Users Guide To Microsoft Word TablesUsers Guide To Microsoft Word Tables
Users Guide To Microsoft Word Tables
Madhubanti Dasgupta
 
Ch03 cmpt110
Ch03 cmpt110Ch03 cmpt110
Ch03 cmpt110
smccblackboard
 
Database Relationships
Database RelationshipsDatabase Relationships
Database Relationshipswmassie
 
Creating relationships with tables
Creating relationships with tablesCreating relationships with tables
Creating relationships with tablesJhen Articona
 
Basic Access Notes
Basic Access NotesBasic Access Notes
Basic Access Notes
Pyi Soe
 
MS Word 2007 insert tables
MS Word 2007 insert tablesMS Word 2007 insert tables
MS Word 2007 insert tablesVTC
 
Access 2007
Access 2007Access 2007
Access 2007
rupalidhir
 
The Power Of Mail Merge!
The Power Of Mail Merge!The Power Of Mail Merge!
The Power Of Mail Merge!
Rina Banerjee
 
Mail merge made easy
Mail merge made easyMail merge made easy
Mail merge made easy
Roel Palmaers
 
Basic introduction to ms access
Basic introduction to ms accessBasic introduction to ms access
Basic introduction to ms access
jigeno
 
Online Shopping Cart Business Requirement Dcoument
Online Shopping Cart Business Requirement DcoumentOnline Shopping Cart Business Requirement Dcoument
Online Shopping Cart Business Requirement DcoumentH2Kinfosys
 
Mail Merge in Microsoft Word
Mail Merge in Microsoft WordMail Merge in Microsoft Word
Mail Merge in Microsoft Word
Neelanjan Bhattacharyya
 
Ms access 2007
Ms access 2007Ms access 2007
Ms access 2007
Ramesh Pant
 

Viewers also liked (20)

Database
DatabaseDatabase
Database
 
Software
SoftwareSoftware
Software
 
Crosstab query techniques
Crosstab query techniquesCrosstab query techniques
Crosstab query techniques
 
computer software
computer softwarecomputer software
computer software
 
Microsoft access 2007_tutorial
Microsoft access 2007_tutorialMicrosoft access 2007_tutorial
Microsoft access 2007_tutorial
 
MS Access 2007 in ITT
MS Access 2007 in ITTMS Access 2007 in ITT
MS Access 2007 in ITT
 
Tables
TablesTables
Tables
 
Users Guide To Microsoft Word Tables
Users Guide To Microsoft Word TablesUsers Guide To Microsoft Word Tables
Users Guide To Microsoft Word Tables
 
Ch03 cmpt110
Ch03 cmpt110Ch03 cmpt110
Ch03 cmpt110
 
Database Relationships
Database RelationshipsDatabase Relationships
Database Relationships
 
Creating relationships with tables
Creating relationships with tablesCreating relationships with tables
Creating relationships with tables
 
Basic Access Notes
Basic Access NotesBasic Access Notes
Basic Access Notes
 
MS Word 2007 insert tables
MS Word 2007 insert tablesMS Word 2007 insert tables
MS Word 2007 insert tables
 
Access 2007
Access 2007Access 2007
Access 2007
 
The Power Of Mail Merge!
The Power Of Mail Merge!The Power Of Mail Merge!
The Power Of Mail Merge!
 
Mail merge made easy
Mail merge made easyMail merge made easy
Mail merge made easy
 
Basic introduction to ms access
Basic introduction to ms accessBasic introduction to ms access
Basic introduction to ms access
 
Online Shopping Cart Business Requirement Dcoument
Online Shopping Cart Business Requirement DcoumentOnline Shopping Cart Business Requirement Dcoument
Online Shopping Cart Business Requirement Dcoument
 
Mail Merge in Microsoft Word
Mail Merge in Microsoft WordMail Merge in Microsoft Word
Mail Merge in Microsoft Word
 
Ms access 2007
Ms access 2007Ms access 2007
Ms access 2007
 

Similar to SQL

Database Management Lab -SQL Queries
Database Management Lab -SQL Queries Database Management Lab -SQL Queries
Database Management Lab -SQL Queries
shamim hossain
 
Adv DB - Full Handout.pdf
Adv DB - Full Handout.pdfAdv DB - Full Handout.pdf
Adv DB - Full Handout.pdf
3BRBoruMedia
 
U-SQL Intro (SQLBits 2016)
U-SQL Intro (SQLBits 2016)U-SQL Intro (SQLBits 2016)
U-SQL Intro (SQLBits 2016)
Michael Rys
 
Unit 3 rdbms study_materials-converted
Unit 3  rdbms study_materials-convertedUnit 3  rdbms study_materials-converted
Unit 3 rdbms study_materials-converted
gayaramesh
 
Introduction to Database SQL & PL/SQL
Introduction to Database SQL & PL/SQLIntroduction to Database SQL & PL/SQL
Introduction to Database SQL & PL/SQL
Collaboration Technologies
 
Introduction to SQL, SQL*Plus
Introduction to SQL, SQL*PlusIntroduction to SQL, SQL*Plus
Introduction to SQL, SQL*Plus
Chhom Karath
 
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
 
SQL for interview
SQL for interviewSQL for interview
SQL for interview
Aditya Kumar Tripathy
 
Pl sql content
Pl sql contentPl sql content
Pl sql content
MargaretMaryT
 
oodb.ppt
oodb.pptoodb.ppt
oodb.ppt
ISHAAGARWAL75
 
Database part2-
Database part2-Database part2-
Database part2-
Taymoor Nazmy
 
Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)
Rakibul Hasan Pranto
 
NUS Hackers Club Mar 21 - Whats New in JavaSE 8?
NUS Hackers Club Mar 21 - Whats New in JavaSE 8?NUS Hackers Club Mar 21 - Whats New in JavaSE 8?
NUS Hackers Club Mar 21 - Whats New in JavaSE 8?
Chuk-Munn Lee
 
Student handbook xii
Student handbook xiiStudent handbook xii
Student handbook xii
geetu84
 
DATABASE MANAGEMENT SYSTEM
DATABASE MANAGEMENT SYSTEMDATABASE MANAGEMENT SYSTEM
DATABASE MANAGEMENT SYSTEM
Sonia Pahuja
 
PO WER - Piotr Mariat - Sql
PO WER - Piotr Mariat - SqlPO WER - Piotr Mariat - Sql
PO WER - Piotr Mariat - Sql
Zespół Szkół nr 26
 

Similar to SQL (20)

Database Management Lab -SQL Queries
Database Management Lab -SQL Queries Database Management Lab -SQL Queries
Database Management Lab -SQL Queries
 
Adv DB - Full Handout.pdf
Adv DB - Full Handout.pdfAdv DB - Full Handout.pdf
Adv DB - Full Handout.pdf
 
U-SQL Intro (SQLBits 2016)
U-SQL Intro (SQLBits 2016)U-SQL Intro (SQLBits 2016)
U-SQL Intro (SQLBits 2016)
 
Unit 3 rdbms study_materials-converted
Unit 3  rdbms study_materials-convertedUnit 3  rdbms study_materials-converted
Unit 3 rdbms study_materials-converted
 
Module02
Module02Module02
Module02
 
Introduction to Database SQL & PL/SQL
Introduction to Database SQL & PL/SQLIntroduction to Database SQL & PL/SQL
Introduction to Database SQL & PL/SQL
 
Introduction to SQL, SQL*Plus
Introduction to SQL, SQL*PlusIntroduction to SQL, SQL*Plus
Introduction to SQL, SQL*Plus
 
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
 
SQL for interview
SQL for interviewSQL for interview
SQL for interview
 
Pl sql content
Pl sql contentPl sql content
Pl sql content
 
oodb.ppt
oodb.pptoodb.ppt
oodb.ppt
 
Database part2-
Database part2-Database part2-
Database part2-
 
Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)
 
NUS Hackers Club Mar 21 - Whats New in JavaSE 8?
NUS Hackers Club Mar 21 - Whats New in JavaSE 8?NUS Hackers Club Mar 21 - Whats New in JavaSE 8?
NUS Hackers Club Mar 21 - Whats New in JavaSE 8?
 
Student handbook xii
Student handbook xiiStudent handbook xii
Student handbook xii
 
DATABASE MANAGEMENT SYSTEM
DATABASE MANAGEMENT SYSTEMDATABASE MANAGEMENT SYSTEM
DATABASE MANAGEMENT SYSTEM
 
PO WER - Piotr Mariat - Sql
PO WER - Piotr Mariat - SqlPO WER - Piotr Mariat - Sql
PO WER - Piotr Mariat - Sql
 
PT- Oracle session01
PT- Oracle session01 PT- Oracle session01
PT- Oracle session01
 

More from Bhandari Nawaraj

Implementation
ImplementationImplementation
Implementation
Bhandari Nawaraj
 
Supporting Transactions
Supporting TransactionsSupporting Transactions
Supporting Transactions
Bhandari Nawaraj
 
Database Design
Database DesignDatabase Design
Database Design
Bhandari Nawaraj
 
The Relational Model
The Relational ModelThe Relational Model
The Relational Model
Bhandari Nawaraj
 
Entity Relationship Modelling
Entity Relationship ModellingEntity Relationship Modelling
Entity Relationship Modelling
Bhandari Nawaraj
 
Dbms
DbmsDbms

More from Bhandari Nawaraj (7)

Implementation
ImplementationImplementation
Implementation
 
Supporting Transactions
Supporting TransactionsSupporting Transactions
Supporting Transactions
 
Database Design
Database DesignDatabase Design
Database Design
 
SQL
SQL SQL
SQL
 
The Relational Model
The Relational ModelThe Relational Model
The Relational Model
 
Entity Relationship Modelling
Entity Relationship ModellingEntity Relationship Modelling
Entity Relationship Modelling
 
Dbms
DbmsDbms
Dbms
 

Recently uploaded

Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 

Recently uploaded (20)

Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 

SQL

  • 2. Objectives of SQL  Create the database and relation structures  Perform basic tasks such as inserts, updates and deletes  Simple and complex queries Structured Query Language
  • 3. Data Definition Language: DDL  For defining database structures and controlling access to data  CREATE TABLE, CREATE INDEX , CREATE SEQUENCE , GRANT ACCESS etc.
  • 4. Data Manipulation Language: DML  For retrieving and updating data  SELECT, INSERT, UPDATE, DELETE
  • 5. History of SQL - 1  Developed from IBM’s SYSTEM R  The database standard language by 1970s...  First standard published in 1987 by ISO
  • 6. History of SQL - 2  Addition to standard published 1989  SQL 1992 – Major revision ‘SQL-92’  SQL: 1999 - with object-relational features  SQL: 2003 - introduced concept of ‘core SQL’  SQL: 2006 – user of SQL with XML  SQL: 2008 minor revisions.
  • 7. Data Manipulation Language: DML  For retrieving and updating data  SELECT – retrieving  INSERT, UPDATE, DELETE – updating Difference between INSERT and UPDATE?
  • 8. Literals  Insert into Student (Stu_id, First_name, Last_name)  Values (1,’Satpal’,’Singh’); - Non-numeric in single quotes - Numeric NOT in quotes
  • 9. Select branchID, Count(staff_id) From workers Where branchType = ‘Main’ Group by branchID Having Count (staff_id) > 1 Order by branchID
  • 10. Select branchID, Count(staff_id) From workers Where branchType = ‘Main’ Group by branchID Having Count (staff_id) > 1 Order by branchID Which columns will appear? Which table? Condition Groups by some column Value Restricts what will Be grouped Specifies the order of the result
  • 11. Database Update  Insert  Update  Delete
  • 12. Insert  Insert into students (Student_id, first_name, last_name)  Values (1,’Satpal’,’Singh’);  Insert into students  Values (1,’Satpal’,’Singh’,’Overseas’,’Undergrad’);
  • 13. Update  Update Students  Set Student_type = ‘Undergrad’;  Update Students  Set student_type = ‘Undergrad’  Where student_id = 1;
  • 14. Delete  Delete from Students;  Delete from Students  Where student_id = 1;
  • 15. Activity  Departments  Department_Id Integer  Department_Name varchar 30  Location varchar 30
  • 16.  Departments  Department_Id Integer  Department_Name varchar 30  Location varchar 30 • Insert into Departments • Values (8,’Complaints’,’Glasgow’):
  • 19. Datatypes  What is a datatype?  What is a domain?
  • 20. String Datatypes  Character or Char  Varying Character of Varchar  Bit (N)  Bit varying
  • 21. Char or Varchar  ‘Gary__’ a 6 long Char  ‘Gary’ a 6 long varchar
  • 22. Numeric Datatypes  Numeric or Decimal, e.g. 8.23 with point set  Integer, e.g. 8  Float, e.g. 8.23 but could also be changed so that point moves when needed
  • 23. Datetime Types  Date  Time  Timestamp  Interval
  • 24. Advantages of SQL  Universal  Easy to use  Fits (more or less) with relational model
  • 25. Disadvantages of SQL  Does not support all features of relational model  No one standard  Has had to be extended  Much redundancy – possible to do the same thing many ways
  • 26. Learning Outcomes – Have We Met Them?  By the end of this topic, students will be able to:  Explain the purpose of SQL  Outline the basic concepts of SQL  Understand that there are different ‘flavours’ of SQL
  • 27. References  Benyon-Davis, P. (2003). Database Systems, 3rd edition. Palgrave Macmillan. Chapters 11, 12 & 13.  Connolly, T. & Begg, C. (2004). Database Systems: A Practical Approach to Design, Implementation, and Management, 4th Edition. Addison Wesley. Chapters 5, 6 & 7.  Dietrich, S. W. (2001). Understanding Relational Database Query Languages, 1st edition. Prentice Hall. Chapter 5.