SlideShare a Scribd company logo
1 of 28
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

Relational Database Fundamentals
Relational Database FundamentalsRelational Database Fundamentals
Relational Database FundamentalsKHALID C
 
9. Object Relational Databases in DBMS
9. Object Relational Databases in DBMS9. Object Relational Databases in DBMS
9. Object Relational Databases in DBMSkoolkampus
 
08. Object Oriented Database in DBMS
08. Object Oriented Database in DBMS08. Object Oriented Database in DBMS
08. Object Oriented Database in DBMSkoolkampus
 
Relational database- Fundamentals
Relational database- FundamentalsRelational database- Fundamentals
Relational database- FundamentalsMohammed El Hedhly
 
Logical Design and Conceptual Database Design
Logical Design and Conceptual Database DesignLogical Design and Conceptual Database Design
Logical Design and Conceptual Database DesignEr. Nawaraj Bhandari
 
Introduction to Data Science With R Notes
Introduction to Data Science With R NotesIntroduction to Data Science With R Notes
Introduction to Data Science With R NotesLakshmiSarvani6
 
Database Design and Normalization Techniques
Database Design and Normalization TechniquesDatabase Design and Normalization Techniques
Database Design and Normalization TechniquesNishant Munjal
 
Overview of Object-Oriented Concepts Characteristics by vikas jagtap
Overview of Object-Oriented Concepts Characteristics by vikas jagtapOverview of Object-Oriented Concepts Characteristics by vikas jagtap
Overview of Object-Oriented Concepts Characteristics by vikas jagtapVikas Jagtap
 
Dbms interview questions
Dbms interview questionsDbms interview questions
Dbms interview questionsambika93
 
Dbms important questions and answers
Dbms important questions and answersDbms important questions and answers
Dbms important questions and answersLakshmiSarvani6
 
Bca examination 2017 dbms
Bca examination 2017 dbmsBca examination 2017 dbms
Bca examination 2017 dbmsAnjaan Gajendra
 

What's hot (19)

Relational Database Fundamentals
Relational Database FundamentalsRelational Database Fundamentals
Relational Database Fundamentals
 
9. Object Relational Databases in DBMS
9. Object Relational Databases in DBMS9. Object Relational Databases in DBMS
9. Object Relational Databases in DBMS
 
08. Object Oriented Database in DBMS
08. Object Oriented Database in DBMS08. Object Oriented Database in DBMS
08. Object Oriented Database in DBMS
 
Rdbms concepts
Rdbms conceptsRdbms concepts
Rdbms concepts
 
Object oriented data model
Object oriented data modelObject oriented data model
Object oriented data model
 
Relational database- Fundamentals
Relational database- FundamentalsRelational database- Fundamentals
Relational database- Fundamentals
 
The Smartpath Information Systems | BASIC RDBMS CONCEPTS
The Smartpath Information Systems | BASIC RDBMS CONCEPTSThe Smartpath Information Systems | BASIC RDBMS CONCEPTS
The Smartpath Information Systems | BASIC RDBMS CONCEPTS
 
Logical Design and Conceptual Database Design
Logical Design and Conceptual Database DesignLogical Design and Conceptual Database Design
Logical Design and Conceptual Database Design
 
Chapt 1 odbms
Chapt 1 odbmsChapt 1 odbms
Chapt 1 odbms
 
Introduction to Data Science With R Notes
Introduction to Data Science With R NotesIntroduction to Data Science With R Notes
Introduction to Data Science With R Notes
 
Database Design and Normalization Techniques
Database Design and Normalization TechniquesDatabase Design and Normalization Techniques
Database Design and Normalization Techniques
 
Overview of Object-Oriented Concepts Characteristics by vikas jagtap
Overview of Object-Oriented Concepts Characteristics by vikas jagtapOverview of Object-Oriented Concepts Characteristics by vikas jagtap
Overview of Object-Oriented Concepts Characteristics by vikas jagtap
 
Dbms interview questions
Dbms interview questionsDbms interview questions
Dbms interview questions
 
12 SQL
12 SQL12 SQL
12 SQL
 
Dbms important questions and answers
Dbms important questions and answersDbms important questions and answers
Dbms important questions and answers
 
Bca examination 2017 dbms
Bca examination 2017 dbmsBca examination 2017 dbms
Bca examination 2017 dbms
 
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
 
DBMS CS 4-5
DBMS CS 4-5DBMS CS 4-5
DBMS CS 4-5
 

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-
 
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?
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
 
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 Er. Nawaraj Bhandari

Data mining approaches and methods
Data mining approaches and methodsData mining approaches and methods
Data mining approaches and methodsEr. Nawaraj Bhandari
 
Research trends in data warehousing and data mining
Research trends in data warehousing and data miningResearch trends in data warehousing and data mining
Research trends in data warehousing and data miningEr. Nawaraj Bhandari
 
Mining Association Rules in Large Database
Mining Association Rules in Large DatabaseMining Association Rules in Large Database
Mining Association Rules in Large DatabaseEr. Nawaraj Bhandari
 
Introduction to data mining and data warehousing
Introduction to data mining and data warehousingIntroduction to data mining and data warehousing
Introduction to data mining and data warehousingEr. Nawaraj Bhandari
 
Classification and prediction in data mining
Classification and prediction in data miningClassification and prediction in data mining
Classification and prediction in data miningEr. Nawaraj Bhandari
 
Chapter 3: Simplification of Boolean Function
Chapter 3: Simplification of Boolean FunctionChapter 3: Simplification of Boolean Function
Chapter 3: Simplification of Boolean FunctionEr. Nawaraj Bhandari
 
Chapter 5: Cominational Logic with MSI and LSI
Chapter 5: Cominational Logic with MSI and LSIChapter 5: Cominational Logic with MSI and LSI
Chapter 5: Cominational Logic with MSI and LSIEr. Nawaraj Bhandari
 
Chapter 2: Boolean Algebra and Logic Gates
Chapter 2: Boolean Algebra and Logic GatesChapter 2: Boolean Algebra and Logic Gates
Chapter 2: Boolean Algebra and Logic GatesEr. Nawaraj Bhandari
 
Introduction to Electronic Commerce
Introduction to Electronic CommerceIntroduction to Electronic Commerce
Introduction to Electronic CommerceEr. Nawaraj Bhandari
 
Using macros in microsoft excel part 2
Using macros in microsoft excel   part 2Using macros in microsoft excel   part 2
Using macros in microsoft excel part 2Er. Nawaraj Bhandari
 
Using macros in microsoft excel part 1
Using macros in microsoft excel   part 1Using macros in microsoft excel   part 1
Using macros in microsoft excel part 1Er. Nawaraj Bhandari
 

More from Er. Nawaraj Bhandari (20)

Data mining approaches and methods
Data mining approaches and methodsData mining approaches and methods
Data mining approaches and methods
 
Research trends in data warehousing and data mining
Research trends in data warehousing and data miningResearch trends in data warehousing and data mining
Research trends in data warehousing and data mining
 
Mining Association Rules in Large Database
Mining Association Rules in Large DatabaseMining Association Rules in Large Database
Mining Association Rules in Large Database
 
Introduction to data mining and data warehousing
Introduction to data mining and data warehousingIntroduction to data mining and data warehousing
Introduction to data mining and data warehousing
 
Data warehouse testing
Data warehouse testingData warehouse testing
Data warehouse testing
 
Data warehouse physical design
Data warehouse physical designData warehouse physical design
Data warehouse physical design
 
Data warehouse logical design
Data warehouse logical designData warehouse logical design
Data warehouse logical design
 
Classification and prediction in data mining
Classification and prediction in data miningClassification and prediction in data mining
Classification and prediction in data mining
 
Chapter 3: Simplification of Boolean Function
Chapter 3: Simplification of Boolean FunctionChapter 3: Simplification of Boolean Function
Chapter 3: Simplification of Boolean Function
 
Chapter 6: Sequential Logic
Chapter 6: Sequential LogicChapter 6: Sequential Logic
Chapter 6: Sequential Logic
 
Chapter 5: Cominational Logic with MSI and LSI
Chapter 5: Cominational Logic with MSI and LSIChapter 5: Cominational Logic with MSI and LSI
Chapter 5: Cominational Logic with MSI and LSI
 
Chapter 4: Combinational Logic
Chapter 4: Combinational LogicChapter 4: Combinational Logic
Chapter 4: Combinational Logic
 
Chapter 2: Boolean Algebra and Logic Gates
Chapter 2: Boolean Algebra and Logic GatesChapter 2: Boolean Algebra and Logic Gates
Chapter 2: Boolean Algebra and Logic Gates
 
Chapter 1: Binary System
 Chapter 1: Binary System Chapter 1: Binary System
Chapter 1: Binary System
 
Introduction to Electronic Commerce
Introduction to Electronic CommerceIntroduction to Electronic Commerce
Introduction to Electronic Commerce
 
Evaluating software development
Evaluating software developmentEvaluating software development
Evaluating software development
 
Using macros in microsoft excel part 2
Using macros in microsoft excel   part 2Using macros in microsoft excel   part 2
Using macros in microsoft excel part 2
 
Using macros in microsoft excel part 1
Using macros in microsoft excel   part 1Using macros in microsoft excel   part 1
Using macros in microsoft excel part 1
 
Using macros in microsoft access
Using macros in microsoft accessUsing macros in microsoft access
Using macros in microsoft access
 
Testing software development
Testing software developmentTesting software development
Testing software development
 

Recently uploaded

Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionfulawalesam
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts ServiceSapana Sha
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubaihf8803863
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998YohFuh
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxolyaivanovalion
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxolyaivanovalion
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSAishani27
 
Unveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystUnveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystSamantha Rae Coolbeth
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxolyaivanovalion
 
(ISHITA) Call Girls Service Hyderabad Call Now 8617697112 Hyderabad Escorts
(ISHITA) Call Girls Service Hyderabad Call Now 8617697112 Hyderabad Escorts(ISHITA) Call Girls Service Hyderabad Call Now 8617697112 Hyderabad Escorts
(ISHITA) Call Girls Service Hyderabad Call Now 8617697112 Hyderabad EscortsCall girls in Ahmedabad High profile
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...Suhani Kapoor
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAroojKhan71
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptxAnupama Kate
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130Suhani Kapoor
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxStephen266013
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxolyaivanovalion
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptSonatrach
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFxolyaivanovalion
 

Recently uploaded (20)

Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts Service
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptx
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptx
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICS
 
Unveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystUnveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data Analyst
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
(ISHITA) Call Girls Service Hyderabad Call Now 8617697112 Hyderabad Escorts
(ISHITA) Call Girls Service Hyderabad Call Now 8617697112 Hyderabad Escorts(ISHITA) Call Girls Service Hyderabad Call Now 8617697112 Hyderabad Escorts
(ISHITA) Call Girls Service Hyderabad Call Now 8617697112 Hyderabad Escorts
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
 
E-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptxE-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptx
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docx
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptx
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFx
 

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.