SlideShare a Scribd company logo
1 of 19
 ANY USEFUL INFORMATION IS A DATA
 IN SIMPLE WORDS DATA CAN BE FACTS RELATED TO ANY OBJECT IN CONSIDERATION
 FOR EXAMPLE YOUR NAME, AGE, HEIGHT, WEIGHT, ETC. ARE SOME DATA RELATED TO YOU.
A PICTURE , IMAGE , FILE , PDF ETC. CAN ALSO BE CONSIDERED DATA
What is Data?
What is Database?
 A database is a systematic collection of data.
Databases support storage and manipulation of data.
Databases make data management easy
 Ex: An online telephone directory
WHAT IS A DATABASE
MANAGEMENT SYSTEM (DBMS)?
• Database Management System (DBMS) is a collection of programs which
enables its users to access database, manipulate data, reporting /
representation of data . It also helps to control access to the database.
• Database Management Systems are not a new concept and as such had been
first implemented in 1960s. Charles Bachmen's Integrated Data Store(IDS) is
said to be the first DBMS in history
TYPES OF DBMS:
• Hierarchical - this type of DBMS employs the "parent-child"
relationship of storing data. The windows registry used in
Windows OS is an example of a hierarchical database.
• Network DBMS - this type of DBMS supports many-to many
relations. Ex: RDM Server
• Relational DBMS - this type of DBMS defines database
relationships in form of tables, also known as relations Ex:
MySQL, Oracle and Microsoft SQL Server
WHAT IS RELATIONAL
DATABASE?
It is the collection of relations or two dimensional tables
Dr E.F Codd proposed the relational model for database system in 1969
Relational Model Consists of following :
• Collections of Objects or Relations
• Set of Operators to act on the relations
• Data integrity for accuracy and consistency.
(Data integrity is the one which contains correct data in the database)
To Preserve data integrity we have two types:
1.DataType: Data Type is a type of data which you store in each column
2.Constraints
CONSTRAINTS:
A constraint is a condition which restricts the invalid data in the table.
A constraint can be provided for a column of a table.
Types of Constraints
1. NOT NULL
2. UNIQUE
3. Primary Key
4. Foreign Key
5. Check
NOT NULL -
• NULL is nothing, it is neither zero nor blank space. It will not occupy any space in the memory
• NOT NULL will ensure at least some value should be present in a column
UNIQUE -
• It will not allow any duplicates in a column
• UNIQUE column can take multiple NULL (s)
Primary Key
• It is the combination of NOT NULL and UNIQUE
• Only one PK is allowed in a table
• PK identifies a record uniquely in a table
Foreign Key
• FK creates relationship between any two tables
• FK is created on the child table
• FK can take both NULL and duplicate values
• We can have more than 1 FK in a given table
CHECK
• It is used to provide additional validations as per the customer requirements.
SQL:
• Developed by IBM SQL – Structured Query Language.
• SQL – it is a language to talk to the database / to access the database
• To work on SQL , a DB software (RDBMS) is required.
• SQL is not case sensitive
What is SQL?
Structured Query language (SQL) pronounced as "S-Q-L" or sometimes as
“See-Quel” is actually the standard language for dealing with Relational
Databases. SQL can be effectively used to insert, search, update, delete
database records.
SQL STATEMENTS:
SQL STATEMENTS:
SQL SELECT Statement
SELECT column1, column2....columnN FROM table_name;
SQL WHERE Clause
SELECT column1, column2....columnN FROM table_name WHERE
CONDITION;
SQL> SELECT ID, NAME, SALARY FROM CUSTOMERS;
SQL> SELECT ID, NAME, SALARY FROM CUSTOMERS WHERE SALARY > 2000;
SQL STATEMENTS:
SQL ORDER BY Clause
SELECT column1, column2....columnN FROM table_name WHERE
CONDITION ORDER BY column_name {ASC|DESC};
SQL GROUP BY Clause
SELECT SUM(column_name) FROM table_name WHERE CONDITION
GROUP BY column_name;
SQL> SELECT * FROM CUSTOMERS ORDER BY NAME, SALARY;
SQL> SELECT NAME, SUM(SALARY) FROM CUSTOMERS GROUP BY NAME;
SQL STATEMENTS:
SQL CREATE TABLE Statement
CREATE TABLE table_name( column1 datatype, column2
datatype, column3 datatype, ..... columnN datatype,
PRIMARY KEY( one or more columns ) );
SQL DROP TABLE Statement
DROP TABLE table_name;
SQL>
CREATE TABLE CUSTOMERS
(ID INT NOT NULL,
NAME VARCHAR (20) NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR (25),
SALARY DECIMAL (18, 2),
PRIMARY KEY (ID));
SQL> DROP TABLE CUSTOMERS;
SQL> DESC CUSTOMERS;
ERROR 1146 (42S02): Table 'TEST.CUSTOMERS' doesn't exist
SQL STATEMENTS:
SQL TRUNCATE TABLE Statement
TRUNCATE TABLE table_name;
SQL INSERT INTO Statement
INSERT INTO table_name( column1, column2....columnN)
VALUES ( value1, value2....valueN);
SQL > TRUNCATE TABLE CUSTOMERS;
SQL> SELECT * FROM CUSTOMERS;
Empty set (0.00 sec)
INSERT INTO CUSTOMERS VALUES (7, 'Muffy', 24, 'Indore', 10000.00 );
SQL STATEMENTS:
SQL UPDATE Statement
UPDATE table_name SET column1 = value1, column2 =
value2....columnN=valueN [ WHERE CONDITION ];
SQL DELETE Statement
DELETE FROM table_name WHERE {CONDITION};
SQL> UPDATE CUSTOMERS SET ADDRESS = 'Pune' WHERE ID = 6;
SQL> DELETE FROM CUSTOMERS WHERE ID = 6;
SQL JOINS
• The SQL Joins clause is used to combine records from two or more tables in a
database. A JOIN is a means for combining fields from two tables by using values
common to each.
There are different types of joins available in SQL −
•INNER JOIN − returns rows when there is a match in both
tables.
•LEFT JOIN − returns all rows from the left table, even if there are
no matches in the right table.
•RIGHT JOIN − returns all rows from the right table, even if there
are no matches in the left table.
•FULL JOIN − returns rows when there is a match in one of the
tables.
•SELF JOIN − is used to join a table to itself as if the table were
two tables, temporarily renaming at least one table in the SQL
statement.
INNER JOIN:
SELECT table1.column1, table2.column2... FROM table1
INNER JOIN table2 ON table1.common_field = table2.common_field;
SQL> SELECT ID, NAME, AMOUNT, DATE FROM CUSTOMERS
INNER JOIN ORDERS ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;
LEFT JOIN:
SELECT table1.column1, table2.column2... FROM table1
LEFT JOIN table2 ON table1.common_field = table2.common_field;
SQL> SELECT ID, NAME, AMOUNT, DATE FROM CUSTOMERS
LEFT JOIN ORDERS ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;
RIGHT JOIN:
SELECT table1.column1, table2.column2... FROM table1
RIGHT JOIN table2 ON table1.common_field = table2.common_field;
SQL> SELECT ID, NAME, AMOUNT, DATE FROM CUSTOMERS
RIGHT JOIN ORDERS ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;
FULL JOIN:
SELECT table1.column1, table2.column2... FROM table1
FULL JOIN table2 ON table1.common_field = table2.common_field;
SQL> SELECT ID, NAME, AMOUNT, DATE FROM CUSTOMERS
FULL JOIN ORDERS ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;

More Related Content

What's hot (18)

DBMS-Quick Reference
DBMS-Quick ReferenceDBMS-Quick Reference
DBMS-Quick Reference
 
Introduction to Database Concepts
Introduction to Database ConceptsIntroduction to Database Concepts
Introduction to Database Concepts
 
Relational Database Fundamentals
Relational Database FundamentalsRelational Database Fundamentals
Relational Database Fundamentals
 
SQL for interview
SQL for interviewSQL for interview
SQL for interview
 
RDBMS concepts
RDBMS conceptsRDBMS concepts
RDBMS concepts
 
Relational data model
Relational data modelRelational data model
Relational data model
 
Database Indexes
Database IndexesDatabase Indexes
Database Indexes
 
Indexes
IndexesIndexes
Indexes
 
An hour with Database and SQL
An hour with Database and SQLAn hour with Database and SQL
An hour with Database and SQL
 
Sql basics
Sql basicsSql basics
Sql basics
 
Index in sql server
Index in sql serverIndex in sql server
Index in sql server
 
Mdst 3559-02-24-sql2
Mdst 3559-02-24-sql2Mdst 3559-02-24-sql2
Mdst 3559-02-24-sql2
 
demo2.ppt
demo2.pptdemo2.ppt
demo2.ppt
 
Database Languges
Database LangugesDatabase Languges
Database Languges
 
Data Dictionary
Data DictionaryData Dictionary
Data Dictionary
 
Introduction - Database (MS Access)
Introduction - Database (MS Access)Introduction - Database (MS Access)
Introduction - Database (MS Access)
 
SQL_Part1
SQL_Part1SQL_Part1
SQL_Part1
 
Rdbms terminology
Rdbms terminologyRdbms terminology
Rdbms terminology
 

Similar to Sql introduction

Relational Database Management System
Relational Database Management SystemRelational Database Management System
Relational Database Management SystemMian Abdul Raheem
 
SQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfSQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfDraguClaudiu
 
SQL.pptx for the begineers and good know
SQL.pptx for the begineers and good knowSQL.pptx for the begineers and good know
SQL.pptx for the begineers and good knowPavithSingh
 
Data Base Management System.pdf
Data Base Management System.pdfData Base Management System.pdf
Data Base Management System.pdfTENZING LHADON
 
SQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics CoveredSQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics CoveredDanish Mehraj
 
SQL Joins Basic and Fundamentals
SQL Joins Basic and FundamentalsSQL Joins Basic and Fundamentals
SQL Joins Basic and FundamentalsPratikKhodwe1
 
Relational database management system
Relational database management systemRelational database management system
Relational database management systemPraveen Soni
 
SQL SERVER Training in Pune Slides
SQL SERVER Training in Pune SlidesSQL SERVER Training in Pune Slides
SQL SERVER Training in Pune Slidesenosislearningcom
 
Relational Database Language.pptx
Relational Database Language.pptxRelational Database Language.pptx
Relational Database Language.pptxSheethal Aji Mani
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETEAbrar ali
 
Data_base.pptx
Data_base.pptxData_base.pptx
Data_base.pptxMohit89650
 
05 Create and Maintain Databases and Tables.pptx
05 Create and Maintain Databases and Tables.pptx05 Create and Maintain Databases and Tables.pptx
05 Create and Maintain Databases and Tables.pptxMohamedNowfeek1
 
SQL interview questions by jeetendra mandal - part 3
SQL interview questions by jeetendra mandal - part 3SQL interview questions by jeetendra mandal - part 3
SQL interview questions by jeetendra mandal - part 3jeetendra mandal
 
SQL interview questions by Jeetendra Mandal - part 2
SQL interview questions by Jeetendra Mandal - part 2SQL interview questions by Jeetendra Mandal - part 2
SQL interview questions by Jeetendra Mandal - part 2jeetendra mandal
 

Similar to Sql introduction (20)

Relational Database Management System
Relational Database Management SystemRelational Database Management System
Relational Database Management System
 
SQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfSQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdf
 
SQL.pptx for the begineers and good know
SQL.pptx for the begineers and good knowSQL.pptx for the begineers and good know
SQL.pptx for the begineers and good know
 
SQL
SQLSQL
SQL
 
SQL | DML
SQL | DMLSQL | DML
SQL | DML
 
DATABASE-1.pptx
DATABASE-1.pptxDATABASE-1.pptx
DATABASE-1.pptx
 
Data Base Management System.pdf
Data Base Management System.pdfData Base Management System.pdf
Data Base Management System.pdf
 
ORACLE PL SQL
ORACLE PL SQLORACLE PL SQL
ORACLE PL SQL
 
SQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics CoveredSQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics Covered
 
SQL Joins Basic and Fundamentals
SQL Joins Basic and FundamentalsSQL Joins Basic and Fundamentals
SQL Joins Basic and Fundamentals
 
Relational database management system
Relational database management systemRelational database management system
Relational database management system
 
SQL SERVER Training in Pune Slides
SQL SERVER Training in Pune SlidesSQL SERVER Training in Pune Slides
SQL SERVER Training in Pune Slides
 
Relational Database Language.pptx
Relational Database Language.pptxRelational Database Language.pptx
Relational Database Language.pptx
 
Introduction to SQL..pdf
Introduction to SQL..pdfIntroduction to SQL..pdf
Introduction to SQL..pdf
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETE
 
Data_base.pptx
Data_base.pptxData_base.pptx
Data_base.pptx
 
RDMS AND SQL
RDMS AND SQLRDMS AND SQL
RDMS AND SQL
 
05 Create and Maintain Databases and Tables.pptx
05 Create and Maintain Databases and Tables.pptx05 Create and Maintain Databases and Tables.pptx
05 Create and Maintain Databases and Tables.pptx
 
SQL interview questions by jeetendra mandal - part 3
SQL interview questions by jeetendra mandal - part 3SQL interview questions by jeetendra mandal - part 3
SQL interview questions by jeetendra mandal - part 3
 
SQL interview questions by Jeetendra Mandal - part 2
SQL interview questions by Jeetendra Mandal - part 2SQL interview questions by Jeetendra Mandal - part 2
SQL interview questions by Jeetendra Mandal - part 2
 

More from Bhavya Chawla

Version Control System - for Agile Software Project Management.
Version Control System - for Agile Software Project Management.Version Control System - for Agile Software Project Management.
Version Control System - for Agile Software Project Management.Bhavya Chawla
 
computer graphics-C/C++-dancingdollcode
computer graphics-C/C++-dancingdollcodecomputer graphics-C/C++-dancingdollcode
computer graphics-C/C++-dancingdollcodeBhavya Chawla
 
Natural Language Processing
Natural Language ProcessingNatural Language Processing
Natural Language ProcessingBhavya Chawla
 
Ethical Hacking - sniffing
Ethical Hacking - sniffingEthical Hacking - sniffing
Ethical Hacking - sniffingBhavya Chawla
 
Employee Management System
Employee Management SystemEmployee Management System
Employee Management SystemBhavya Chawla
 
evolution of computers
 evolution of computers evolution of computers
evolution of computersBhavya Chawla
 
the generation of computers
the generation of computersthe generation of computers
the generation of computersBhavya Chawla
 

More from Bhavya Chawla (7)

Version Control System - for Agile Software Project Management.
Version Control System - for Agile Software Project Management.Version Control System - for Agile Software Project Management.
Version Control System - for Agile Software Project Management.
 
computer graphics-C/C++-dancingdollcode
computer graphics-C/C++-dancingdollcodecomputer graphics-C/C++-dancingdollcode
computer graphics-C/C++-dancingdollcode
 
Natural Language Processing
Natural Language ProcessingNatural Language Processing
Natural Language Processing
 
Ethical Hacking - sniffing
Ethical Hacking - sniffingEthical Hacking - sniffing
Ethical Hacking - sniffing
 
Employee Management System
Employee Management SystemEmployee Management System
Employee Management System
 
evolution of computers
 evolution of computers evolution of computers
evolution of computers
 
the generation of computers
the generation of computersthe generation of computers
the generation of computers
 

Recently uploaded

Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxabhijeetpadhi001
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 

Recently uploaded (20)

Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptx
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 

Sql introduction

  • 1.  ANY USEFUL INFORMATION IS A DATA  IN SIMPLE WORDS DATA CAN BE FACTS RELATED TO ANY OBJECT IN CONSIDERATION  FOR EXAMPLE YOUR NAME, AGE, HEIGHT, WEIGHT, ETC. ARE SOME DATA RELATED TO YOU. A PICTURE , IMAGE , FILE , PDF ETC. CAN ALSO BE CONSIDERED DATA What is Data? What is Database?  A database is a systematic collection of data. Databases support storage and manipulation of data. Databases make data management easy  Ex: An online telephone directory
  • 2. WHAT IS A DATABASE MANAGEMENT SYSTEM (DBMS)? • Database Management System (DBMS) is a collection of programs which enables its users to access database, manipulate data, reporting / representation of data . It also helps to control access to the database. • Database Management Systems are not a new concept and as such had been first implemented in 1960s. Charles Bachmen's Integrated Data Store(IDS) is said to be the first DBMS in history
  • 3. TYPES OF DBMS: • Hierarchical - this type of DBMS employs the "parent-child" relationship of storing data. The windows registry used in Windows OS is an example of a hierarchical database. • Network DBMS - this type of DBMS supports many-to many relations. Ex: RDM Server • Relational DBMS - this type of DBMS defines database relationships in form of tables, also known as relations Ex: MySQL, Oracle and Microsoft SQL Server
  • 4. WHAT IS RELATIONAL DATABASE? It is the collection of relations or two dimensional tables Dr E.F Codd proposed the relational model for database system in 1969 Relational Model Consists of following : • Collections of Objects or Relations • Set of Operators to act on the relations • Data integrity for accuracy and consistency. (Data integrity is the one which contains correct data in the database) To Preserve data integrity we have two types: 1.DataType: Data Type is a type of data which you store in each column 2.Constraints
  • 5. CONSTRAINTS: A constraint is a condition which restricts the invalid data in the table. A constraint can be provided for a column of a table. Types of Constraints 1. NOT NULL 2. UNIQUE 3. Primary Key 4. Foreign Key 5. Check
  • 6. NOT NULL - • NULL is nothing, it is neither zero nor blank space. It will not occupy any space in the memory • NOT NULL will ensure at least some value should be present in a column UNIQUE - • It will not allow any duplicates in a column • UNIQUE column can take multiple NULL (s) Primary Key • It is the combination of NOT NULL and UNIQUE • Only one PK is allowed in a table • PK identifies a record uniquely in a table
  • 7. Foreign Key • FK creates relationship between any two tables • FK is created on the child table • FK can take both NULL and duplicate values • We can have more than 1 FK in a given table CHECK • It is used to provide additional validations as per the customer requirements.
  • 8. SQL: • Developed by IBM SQL – Structured Query Language. • SQL – it is a language to talk to the database / to access the database • To work on SQL , a DB software (RDBMS) is required. • SQL is not case sensitive What is SQL? Structured Query language (SQL) pronounced as "S-Q-L" or sometimes as “See-Quel” is actually the standard language for dealing with Relational Databases. SQL can be effectively used to insert, search, update, delete database records.
  • 10. SQL STATEMENTS: SQL SELECT Statement SELECT column1, column2....columnN FROM table_name; SQL WHERE Clause SELECT column1, column2....columnN FROM table_name WHERE CONDITION; SQL> SELECT ID, NAME, SALARY FROM CUSTOMERS; SQL> SELECT ID, NAME, SALARY FROM CUSTOMERS WHERE SALARY > 2000;
  • 11. SQL STATEMENTS: SQL ORDER BY Clause SELECT column1, column2....columnN FROM table_name WHERE CONDITION ORDER BY column_name {ASC|DESC}; SQL GROUP BY Clause SELECT SUM(column_name) FROM table_name WHERE CONDITION GROUP BY column_name; SQL> SELECT * FROM CUSTOMERS ORDER BY NAME, SALARY; SQL> SELECT NAME, SUM(SALARY) FROM CUSTOMERS GROUP BY NAME;
  • 12. SQL STATEMENTS: SQL CREATE TABLE Statement CREATE TABLE table_name( column1 datatype, column2 datatype, column3 datatype, ..... columnN datatype, PRIMARY KEY( one or more columns ) ); SQL DROP TABLE Statement DROP TABLE table_name; SQL> CREATE TABLE CUSTOMERS (ID INT NOT NULL, NAME VARCHAR (20) NOT NULL, AGE INT NOT NULL, ADDRESS CHAR (25), SALARY DECIMAL (18, 2), PRIMARY KEY (ID)); SQL> DROP TABLE CUSTOMERS; SQL> DESC CUSTOMERS; ERROR 1146 (42S02): Table 'TEST.CUSTOMERS' doesn't exist
  • 13. SQL STATEMENTS: SQL TRUNCATE TABLE Statement TRUNCATE TABLE table_name; SQL INSERT INTO Statement INSERT INTO table_name( column1, column2....columnN) VALUES ( value1, value2....valueN); SQL > TRUNCATE TABLE CUSTOMERS; SQL> SELECT * FROM CUSTOMERS; Empty set (0.00 sec) INSERT INTO CUSTOMERS VALUES (7, 'Muffy', 24, 'Indore', 10000.00 );
  • 14. SQL STATEMENTS: SQL UPDATE Statement UPDATE table_name SET column1 = value1, column2 = value2....columnN=valueN [ WHERE CONDITION ]; SQL DELETE Statement DELETE FROM table_name WHERE {CONDITION}; SQL> UPDATE CUSTOMERS SET ADDRESS = 'Pune' WHERE ID = 6; SQL> DELETE FROM CUSTOMERS WHERE ID = 6;
  • 15. SQL JOINS • The SQL Joins clause is used to combine records from two or more tables in a database. A JOIN is a means for combining fields from two tables by using values common to each. There are different types of joins available in SQL − •INNER JOIN − returns rows when there is a match in both tables. •LEFT JOIN − returns all rows from the left table, even if there are no matches in the right table. •RIGHT JOIN − returns all rows from the right table, even if there are no matches in the left table. •FULL JOIN − returns rows when there is a match in one of the tables. •SELF JOIN − is used to join a table to itself as if the table were two tables, temporarily renaming at least one table in the SQL statement.
  • 16. INNER JOIN: SELECT table1.column1, table2.column2... FROM table1 INNER JOIN table2 ON table1.common_field = table2.common_field; SQL> SELECT ID, NAME, AMOUNT, DATE FROM CUSTOMERS INNER JOIN ORDERS ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;
  • 17. LEFT JOIN: SELECT table1.column1, table2.column2... FROM table1 LEFT JOIN table2 ON table1.common_field = table2.common_field; SQL> SELECT ID, NAME, AMOUNT, DATE FROM CUSTOMERS LEFT JOIN ORDERS ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;
  • 18. RIGHT JOIN: SELECT table1.column1, table2.column2... FROM table1 RIGHT JOIN table2 ON table1.common_field = table2.common_field; SQL> SELECT ID, NAME, AMOUNT, DATE FROM CUSTOMERS RIGHT JOIN ORDERS ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;
  • 19. FULL JOIN: SELECT table1.column1, table2.column2... FROM table1 FULL JOIN table2 ON table1.common_field = table2.common_field; SQL> SELECT ID, NAME, AMOUNT, DATE FROM CUSTOMERS FULL JOIN ORDERS ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;