SlideShare une entreprise Scribd logo
1  sur  108
DATABAS
EDatabase to be a collection of related data
An organized collection of related information
so that it can easily be accessed managed
and updated .
e.g :dictionary ,airline database ,library
database ,railway timetable.
DBMS
DATABASE MANAGEMENT SYSTEM
DBM
S
A software system that enables users to
define ,create, ,maintain and control accessed
to the database to the DBMS is
the software that intract with users application
program and the database
MAIN COMPONENT OF
DBMS
1 HARDWARE
2 SOFTWARE
3 DATA
4 PROCEDURES
5 DATA BASE ACCESS
LANGUAGE
HARDWAR
E
All the physical devices that are being used
in DBMS operations are called the hardware
For example : if we run MY SQL server then
the hard disk ram the key board comes under
hardware component
SOFTWAR
E
This is one of the most important component
as it contains all the program that will drive
the DBMS functionality .the job of the
software is to understand the data base
access language and interpret into actual
Database command to execute them
DATA
The DBMS system collect,store,process,and
read the data the DBMS contain actual
operation or the metadata
Metadata is "data that provides information
about other data". In short, it's data about data.
METADATA
PROCEDURE
S
Procedure is the general instructions and
rules that helps to use DBMS
DATABASE ACCESS
LANGUAGE
It is a query language which is use to write the commands to perform operations
like create,read ,update and delete
CHARACTERISTIC
S
It store any kind of data Automatically data
backup and support recovery .
it enable the sharing of the data much easy.
It support data security and prevent restrictions of
un authorized access
It also represent the complex relationship between data and
views.
APPLICATION
S
. Banking system
.Telecom
.Airline
.Educational & corporate
.manufacturing and industry
RELATIONAL DATABASE MANAGEMENT SYSTEM
RDBMS. Stands for "Relational Database
Management System." An RDBMS is a DBMS
designed specifically for relational databases.
Therefore, RDBMSes are a subset of DBMSes.
An RDBMS may also provide a visual representation of the
data. For example, it may display data in a tables like
a spreadsheet, allowing you to view and even edit individual
values in the table.
INSTALLATION OF ORACLE
DDL(Data definition language):
(Oprations on table)
A data definition language is a syntax for defining data
structures, especially database. Common DDL statements are
CREATE, ALTER, RANAME,DROP AND TRUNCATE.
• Must begin with a letter
• Can be 1-30 characters long
• Must contain only A-Z,a-z,0-9,_,$,and #
• Must not duplicate the name of another object owned by the
same user
• Must not be an oracle server reserved word
1:CREATE TABLE
2:ALTER TABLE
3:RENAME TABLE
4:DROP TABLE
5:TRUNCATE TABLE
The SQL CREATE TABLE Statement
 The CREATE TABLE statement is used to create a new table in
a database.
 Syntax
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
column3 datatype,
....
);
SQL ALTER TABLE Statement
 The ALTER TABLE statement is used to add, delete, or modify
columns in an existing table.
 ADD COLUMN
 Syntax
 ALTER TABLE table_name
ADD column_name datatype;
 DROP COLUMN
 The syntax to drop a column in an existing table in SQL.
 SYNTAX
ALTER TABLE table_name
DROP COLUMN column_name;
 RENAME COLUMN
 The syntax to rename a column in an existing table in SQL.
 SYNTAX
ALTER TABLE table_name
RENAME COLUMN column_name to new-name;
 MODIFY COLUMN
 You can use the ALTER TABLE statement in SQL Server to
modify a column in a table.
 BEFORE MODIFYING CHECK THAT YOUR COLUMN IS EMPTY.
 SYNTAX
ALTER TABLE table_name
MODIFY column_name datatype;
The SQL RENAME Statement
The RENAME statement is used to Rename TABLE
in a database.
 Syntax
RENAME table_name
TO NEW TABLE_NAME ;
 The SQL DROP TABLE Statement
 The DROP TABLE statement is used to drop an existing table
in a database.
 Syntax
 DROP TABLE table_name;
 SQL TRUNCATE TABLE
 The TRUNCATE TABLE statement is used to
Remove all rows from table but not table.
 Syntax
 TRUNCATE TABLE table_name;
DML
DATA MANIPULATION
LANGUAGE
WHAT IS DML
• A data manipulation language (DML) is a family of computer
languages including commands permitting users to manipulate data
in a database. This manipulation involves
• Select To Retrieve Data.
• Inserting Data Into Database Tables.
• Deleting Data From Existing Tables.
• Updating Existing Data.
SELECT
• To Retrieve Data. Which Is Basically In Backend And Also In Database.
• 1) SELECT * FROM TAB;
• 2) SELECT * FROM EMP
• WHERE ENAME = ‘KING’;
WHAT IS INSERT
• Insert command Basically manipulates data in a
way/sense of adding/inserting rows into a table.
According To Rules Applied On Table Like Data Types
And Constraints.
Where we use Insert Command
• We Use Insert Command In SQL To Insert Rows.
• After We Created Table.
• When You Needed More Data To Be Saved In Backend.
Syntax And Query
• Syntax :
Insert Into
• Query :
INSERT INTO UCC
VALUES(1, ’NAME’ );
WHAT IS UPDATE
• Update command Basically manipulates data in a
way/sense of modifying or updating rows from existing
tables.
Where we use UPDATE Command
• We Use Update Command In SQL To Update Rows and
data.
• When there will be existing rows.
Syntax And Query
• Syntax :
update ucc
• Query :
update UCC
set Name=‘Ali’
where Name=‘Akram’;
WHAT IS Delete
• Delete command Basically manipulates data in a
way/sense of deleting rows from existing tables that
contain rows or records.
Where we use DELETE Command
• We Use delete Command In SQL To delete Rows or
records.
• When there will be existing rows or records.
Syntax And Query
• Syntax :
delete from
Query :
delete from UCC
where Name=‘Akram’;
SQL Functions
Function?
Stored piece of program that manipulates submitted
Data and return some value.
Types of Functions
o String Functions
o Numeric Functions
o Group Functions
o Date and Time Functions
Group Functions
Group functions are mathematical functions to operate on sets of rows to give
one result per set.
Types of Group functions
o AVG
o COUNT
o MAX
o MIN
o SUM
o TRUNC
o ROUND
1.AVG:
Returns the average value of an expression
Query:
SQL> select avg(sal) from employee;
2.COUNT:
Returns the number of records returned by a select query
Query:
SQL> select count (USERID) from employee;
3.MAX:
Returns the maximum value in a set of values
Query:
SQL> select max(sal) from employee;
4.MIN:
Returns the minimum value in a set of values
Query:
SQL> select min(sal) from employee;
5.SUM:
Calculates the sum of a set of values
Query:
SQL> select sum(sal) from employee;
6.TRUNC:
Trunc a value to a as it is
Query:
SQL> select trunc(avg(sal),2) from employee;
2073.2142
7.ROUND:
ROUND a value according to next one
Query:
SQL> select round(avg(sal),2) from employee;
2073.2143
AVG(SAL)
----------
2073.21429
DATA BASE
SQL HAVING CLAUSE
WHAT IS A HAVING CLAUSE?
 A HAVING clause in SQL specifies that an SQL SELECT statement should
only return rows where aggregate values meet the specified conditions.
Group By
Then
Having clause
WHY USE A HAVING CLAUSE?
 The HAVING CLAUSE is used in an SQL statement because the WHERE
KEYWORD cannot be used with aggregate functions.
WHERE TO USE A HAVING
CLAUSE?
 A HAVING CLAUSE is used where a where cannot be used because it
does not work with aggregate functions.
 In database management an aggregate function is a function where the
values of multiple rows are grouped together as input on certain criteria to
form a single value of more significant meaning.
Having Query
Select job, sum(sal) Sum
From emp
Group By job
Having sum(Sal) =4000
Order by job;
No row select because
Sum(sal) =4000
No ones sum = 4000
Sequence list of CLAUSE:
 SELECT column_name(s)
 FROM table_name
 WHERE condition
 GROUP BY column_name(s)
 HAVING condition
 ORDER BY column_name(s);
Constraints
Definition:
 Constraints are rules to limit data that can go into a table ,to maintain integrity and
accuracy of the data into table .
 Constraints are divided into following two types :
 1-table level constraints
 2-column level constraints
 Constraints are used to make sure integrity of data is maintained in database.
FOLLOWING ARE THE MOST USED
CONSTRAINTS :
 Not null
 Primary key
 Unique key
 Foreign key
NOT NULL:
 By applying not null constraint you are declaring that a not null value cannot be
added.
 Create table student (s-id int Not Null ,Name varchar (60),Age int);
The above query shows that s-id student table will not take any Null
value.
UNIQUE CONSTRAINT:
 A unique constraint that a field or column will only have unique values , no value
will repeat.
 There will not be any duplicate value , this constraint can be applied on column
level or table level.
 Create table student (s-id int NOT NULL UNIQUE, NAME varchar(60),Age int );
 The above query insures that a s-id of student table will only take unique value
,there also wont be a NULL value.
 Using UNIQUE constraint after table is created (column level):
 ALTER TABLE student ADD UNIQUE (s-id);
PRIMARY KEY :
 Primary key constraint uniquely identifies each round in a database.
 A primary key must contain unique value and it must not contain null value.
 Usually primary key is used to index the data inside the table.
 Using primary key constraint at column level
 Create table student (s-id int primary key, Name varchar (60)NOT NULL , Age int)
 The above command will create a PRIMARY KEY on the s-id.
 Using PRIMARY KEY constraint at table level
 Alter table student add PRIMARY KEY (s-id);
 The above command will create a PRIMARY KEY on the s-id.
FOREIGN KEY:
 FOREIGN KEY is used to relate two tables.
 FOREIGN KEY constraint is also used to restrict actions that would destroy links
between two tables.
 To understand FOREIGN KEY, lets see its use, with help of below tables:
Customer-Detail table :
C-id Customer name Address
101 Adam England
102 Alex France
103 Stuart Germany
Order-Detail table :
Order-id Order-Name C-id
10 order1 101
11 order2 103
12 order3 102
 In customer- detail table c-id is a PRIMARY KEY which is set as FOREIGN KEY
in order- detail table .
 The value which is entered in c-id which is set as FOREIGN KEY in order-detail-
table must be present in customer -detail table ,where it is set as PRIMARY KEY.
USING FOREIGN KEY AT Column Level:
create table Order-Detail(
order-id int PRIMARY KEY,
order-name varchar(60) NOT NULL,
c-id FOREIGN KEY REFERENCES Customer-Detail(c-id)
);
In this query ,c-id in the table order-detail is made as FOREIGN KEY ,which is a
reference of c-id column in customer-detail table.
USING FOREIGN KEY CONSTRAINT AT
Table Level:
 ALTER table order-Detail
 ADD Constraint FK FOREIGN KEY (c-id)
 REFERENCES customer-Detail(c-id);
ADDING CONSTRAINT BY ALTER
DATA BASE
SQL SUBQUERIES
WHAT IS A SUBQUERY?
 In SQL a Subquery can be simply defined as a query within another query.
In other words we can say that a Subquery is a query that is embedded in
WHERE clause of another SQL query.
WHERE TO USE A SUBQUERY?
 A subquery is used to return data that will be used in the main query as a
condition to further restrict the data to be retrieved. Subqueries
can be used with the SELECT, INSERT, UPDATE, and DELETE
statements along with the operators like =, <, >, >=, <=, IN, BETWEEN,
etc.
INNER AND OUTER
QUERIES:
The MAIN QUERY is called
OUTER QUERY.
The SUBQUERY is called
INNER QUERY.
SYNTAX FOR A SUBQUERY:
SELECT column_name
FROM table_name
WHERE column_name expression operator
 ( SELECT COLUMN_NAME from TABLE_NAME
WHERE ... );
TWO CATAGORIES OF SUBQUERIS:
 1. Simple Subquery:
This is the kind we saw above. A simple subquery is evaluated
once only for each table.
 2. Correlated Subquery:
This is a type of nested subquery that uses columns from the
outer query in its WHERE clause. A correlated subquery is
evaluated once for each row.
TYPES OF SUBQUERIES:
 Single Row Sub Query:
Return the outer query one row of results that consists of one column
 Multiple Row Sub Query:
Return to the outer query more then one row of the results it Require use of IN,
ANY, ALL, or EXISTS operators
 Multiple Column Sub Query:
 Return to the outer query more then one row of the results in this type of
query Column list on the left side of operator must be in parentheses it use the
IN operator for WHERE and HAVING clauses
SINGLE ROW SUBQUERY:
 SELECT NAME, SAL, JOB
 FROM EMP
 WHERE SAL>( SELECT SAL
FROM EMP
WHERE EMP NO =1);
MULTIPLE ROW SUBQUERY:
 SELECT NAME, SAL, JOB
 FROM EMP
 WHERE SAL IN ( SELECT SAL
FROM EMP
WHERE EMPNO <1)
MULTIPLE COLUMN SUBQUERY:
 SELECT NAME, SAL, JOB
 FROM EMP
 WHERE SAL IN( SELECT SAL, JOB
FROM EMP
WHERE EMP NO < 10
GROUP BY JOB )
 AND JOB = ‘MANAGER’
JOIN
WHAT IS A JOIN?
 A join is an SQL operation performed to
establish a connection between two or
more database tables based on matching
columns.
WHERE TO USE SQL JOIN ?
 SQL JOIN is used when the data from two
tables is to be compared.
 Where clause used in joining.
TYPES OF JOINS:
EQUI JOIN
NON EQUI JOIN
OUTER JOIN
EQUI JOIN
An equijoin returns only the rows
that have equivalent values for the
specified columns.
EQUI JOIN QUERY:
 SELECT m.no , g.no
 From games g , movies m
 Where m.no = g.no;
NON EQUI JOIN
A non-equi join doesn't use the equals
operator in all of it's join conditions.
NOT EQUI JOIN QUERY:
 SELECT m.no , g.no
 From games g , movies m
 Where m.no <> g.no;
OUTER JOIN
 Outer Join is basically used for the deficiency column so that it
can show the other table data fully.
 Sign
 (+)
OUTER JOIN QUERY:
 SELECT m.no , g.no
 From games g , movies m
 Where m.no(+) = g.no;
SELF JOIN:
 A self JOIN is a regular join, but the table is joined with itself.
SELF JOIN QUERY:
 SELECT c.comm, s.sal
 From emp c , emp s
 Where c.comm <> s.sal;

Contenu connexe

Tendances

Tendances (20)

Sql commands
Sql commandsSql commands
Sql commands
 
Adbms
AdbmsAdbms
Adbms
 
Using T-SQL
Using T-SQL Using T-SQL
Using T-SQL
 
Ms sql-server
Ms sql-serverMs sql-server
Ms sql-server
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Sql commands
Sql commandsSql commands
Sql commands
 
SQL Tutorial - Basic Commands
SQL Tutorial - Basic CommandsSQL Tutorial - Basic Commands
SQL Tutorial - Basic Commands
 
Sql intro & ddl 1
Sql intro & ddl 1Sql intro & ddl 1
Sql intro & ddl 1
 
SQL Overview
SQL OverviewSQL Overview
SQL Overview
 
DDL(Data defination Language ) Using Oracle
DDL(Data defination Language ) Using OracleDDL(Data defination Language ) Using Oracle
DDL(Data defination Language ) Using Oracle
 
SQL commands
SQL commandsSQL commands
SQL commands
 
MySql slides (ppt)
MySql slides (ppt)MySql slides (ppt)
MySql slides (ppt)
 
Sql server T-sql basics ppt-3
Sql server T-sql basics  ppt-3Sql server T-sql basics  ppt-3
Sql server T-sql basics ppt-3
 
Oracle Database DML DDL and TCL
Oracle Database DML DDL and TCL Oracle Database DML DDL and TCL
Oracle Database DML DDL and TCL
 
Create table
Create tableCreate table
Create table
 
SQL
SQLSQL
SQL
 
lovely
lovelylovely
lovely
 
Oracle SQL DML Statements
Oracle SQL DML StatementsOracle SQL DML Statements
Oracle SQL DML Statements
 
SQL for interview
SQL for interviewSQL for interview
SQL for interview
 
Introduction to-sql
Introduction to-sqlIntroduction to-sql
Introduction to-sql
 

Similaire à Database COMPLETE

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
PavithSingh
 
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptxMy lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
EliasPetros
 
Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql new
SANTOSH RATH
 
Lecture on DBMS & MySQL.pdf v. C. .
Lecture on DBMS & MySQL.pdf v.  C.     .Lecture on DBMS & MySQL.pdf v.  C.     .
Lecture on DBMS & MySQL.pdf v. C. .
MayankSinghRawat6
 

Similaire à Database COMPLETE (20)

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
 
Relational Database Language.pptx
Relational Database Language.pptxRelational Database Language.pptx
Relational Database Language.pptx
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
 
Module02
Module02Module02
Module02
 
Lab
LabLab
Lab
 
SQL Query
SQL QuerySQL Query
SQL Query
 
DATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQLDATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQL
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
 
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptxMy lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
 
DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptx
 
Sq lite
Sq liteSq lite
Sq lite
 
Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql new
 
Lecture on DBMS & MySQL.pdf v. C. .
Lecture on DBMS & MySQL.pdf v.  C.     .Lecture on DBMS & MySQL.pdf v.  C.     .
Lecture on DBMS & MySQL.pdf v. C. .
 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
 
Unit - II.pptx
Unit - II.pptxUnit - II.pptx
Unit - II.pptx
 
Chapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdfChapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdf
 
Mysql
MysqlMysql
Mysql
 
dbs class 7.ppt
dbs class 7.pptdbs class 7.ppt
dbs class 7.ppt
 

Plus de Abrar ali

Plus de Abrar ali (17)

SOFTWARE TESTING CHAPTER 8 SE
SOFTWARE TESTING CHAPTER 8 SESOFTWARE TESTING CHAPTER 8 SE
SOFTWARE TESTING CHAPTER 8 SE
 
SOFTWRE REQUIREMNETS SE
 SOFTWRE REQUIREMNETS SE SOFTWRE REQUIREMNETS SE
SOFTWRE REQUIREMNETS SE
 
SE CHAPTER 2 PROCESS MODELS
SE CHAPTER 2 PROCESS MODELSSE CHAPTER 2 PROCESS MODELS
SE CHAPTER 2 PROCESS MODELS
 
AGILE VS Scrum
AGILE VS ScrumAGILE VS Scrum
AGILE VS Scrum
 
SE CHAPTER 1 SOFTWARE ENGINEERING
SE CHAPTER 1 SOFTWARE ENGINEERINGSE CHAPTER 1 SOFTWARE ENGINEERING
SE CHAPTER 1 SOFTWARE ENGINEERING
 
Sql FUNCTIONS
Sql FUNCTIONSSql FUNCTIONS
Sql FUNCTIONS
 
Dbms oracle
Dbms oracle Dbms oracle
Dbms oracle
 
Quicksort ALGORITHM
Quicksort ALGORITHMQuicksort ALGORITHM
Quicksort ALGORITHM
 
Joining
JoiningJoining
Joining
 
Greedy algorithm
Greedy algorithmGreedy algorithm
Greedy algorithm
 
Date and Time FUNCTIONS
Date and Time FUNCTIONSDate and Time FUNCTIONS
Date and Time FUNCTIONS
 
Constraints
ConstraintsConstraints
Constraints
 
DML DATA MAINUPULATION LANGUAGE
DML DATA MAINUPULATION LANGUAGEDML DATA MAINUPULATION LANGUAGE
DML DATA MAINUPULATION LANGUAGE
 
DDL DATA DEFINATION LANGUAGE
DDL DATA DEFINATION LANGUAGEDDL DATA DEFINATION LANGUAGE
DDL DATA DEFINATION LANGUAGE
 
Java
JavaJava
Java
 
Weka presentation
Weka presentationWeka presentation
Weka presentation
 
Machine learning
Machine learningMachine learning
Machine learning
 

Dernier

Uncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoUncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac Folorunso
Kayode Fayemi
 
If this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaIf this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New Nigeria
Kayode Fayemi
 
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptxChiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
raffaeleoman
 
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
amilabibi1
 

Dernier (18)

AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdfAWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
 
Thirunelveli call girls Tamil escorts 7877702510
Thirunelveli call girls Tamil escorts 7877702510Thirunelveli call girls Tamil escorts 7877702510
Thirunelveli call girls Tamil escorts 7877702510
 
Aesthetic Colaba Mumbai Cst Call girls 📞 7738631006 Grant road Call Girls ❤️-...
Aesthetic Colaba Mumbai Cst Call girls 📞 7738631006 Grant road Call Girls ❤️-...Aesthetic Colaba Mumbai Cst Call girls 📞 7738631006 Grant road Call Girls ❤️-...
Aesthetic Colaba Mumbai Cst Call girls 📞 7738631006 Grant road Call Girls ❤️-...
 
ICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdfICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdf
 
Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...
Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...
Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...
 
Uncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoUncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac Folorunso
 
Dreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIIDreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio III
 
If this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaIf this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New Nigeria
 
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptxChiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
 
Dreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video TreatmentDreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video Treatment
 
Digital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of DrupalDigital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of Drupal
 
Causes of poverty in France presentation.pptx
Causes of poverty in France presentation.pptxCauses of poverty in France presentation.pptx
Causes of poverty in France presentation.pptx
 
lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.
 
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdfThe workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
 
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
 
Report Writing Webinar Training
Report Writing Webinar TrainingReport Writing Webinar Training
Report Writing Webinar Training
 
My Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle BaileyMy Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle Bailey
 
Sector 62, Noida Call girls :8448380779 Noida Escorts | 100% verified
Sector 62, Noida Call girls :8448380779 Noida Escorts | 100% verifiedSector 62, Noida Call girls :8448380779 Noida Escorts | 100% verified
Sector 62, Noida Call girls :8448380779 Noida Escorts | 100% verified
 

Database COMPLETE

  • 1.
  • 2. DATABAS EDatabase to be a collection of related data An organized collection of related information so that it can easily be accessed managed and updated . e.g :dictionary ,airline database ,library database ,railway timetable.
  • 4. DBM S A software system that enables users to define ,create, ,maintain and control accessed to the database to the DBMS is the software that intract with users application program and the database
  • 5. MAIN COMPONENT OF DBMS 1 HARDWARE 2 SOFTWARE 3 DATA 4 PROCEDURES 5 DATA BASE ACCESS LANGUAGE
  • 6. HARDWAR E All the physical devices that are being used in DBMS operations are called the hardware For example : if we run MY SQL server then the hard disk ram the key board comes under hardware component
  • 7. SOFTWAR E This is one of the most important component as it contains all the program that will drive the DBMS functionality .the job of the software is to understand the data base access language and interpret into actual Database command to execute them
  • 8. DATA The DBMS system collect,store,process,and read the data the DBMS contain actual operation or the metadata Metadata is "data that provides information about other data". In short, it's data about data. METADATA
  • 9. PROCEDURE S Procedure is the general instructions and rules that helps to use DBMS
  • 10. DATABASE ACCESS LANGUAGE It is a query language which is use to write the commands to perform operations like create,read ,update and delete
  • 11. CHARACTERISTIC S It store any kind of data Automatically data backup and support recovery . it enable the sharing of the data much easy. It support data security and prevent restrictions of un authorized access It also represent the complex relationship between data and views.
  • 12. APPLICATION S . Banking system .Telecom .Airline .Educational & corporate .manufacturing and industry
  • 14. RDBMS. Stands for "Relational Database Management System." An RDBMS is a DBMS designed specifically for relational databases. Therefore, RDBMSes are a subset of DBMSes.
  • 15. An RDBMS may also provide a visual representation of the data. For example, it may display data in a tables like a spreadsheet, allowing you to view and even edit individual values in the table.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36. DDL(Data definition language): (Oprations on table) A data definition language is a syntax for defining data structures, especially database. Common DDL statements are CREATE, ALTER, RANAME,DROP AND TRUNCATE.
  • 37. • Must begin with a letter • Can be 1-30 characters long • Must contain only A-Z,a-z,0-9,_,$,and # • Must not duplicate the name of another object owned by the same user • Must not be an oracle server reserved word
  • 38. 1:CREATE TABLE 2:ALTER TABLE 3:RENAME TABLE 4:DROP TABLE 5:TRUNCATE TABLE
  • 39. The SQL CREATE TABLE Statement  The CREATE TABLE statement is used to create a new table in a database.  Syntax CREATE TABLE table_name ( column1 datatype, column2 datatype, column3 datatype, .... );
  • 40. SQL ALTER TABLE Statement  The ALTER TABLE statement is used to add, delete, or modify columns in an existing table.  ADD COLUMN  Syntax  ALTER TABLE table_name ADD column_name datatype;
  • 41.  DROP COLUMN  The syntax to drop a column in an existing table in SQL.  SYNTAX ALTER TABLE table_name DROP COLUMN column_name;
  • 42.  RENAME COLUMN  The syntax to rename a column in an existing table in SQL.  SYNTAX ALTER TABLE table_name RENAME COLUMN column_name to new-name;
  • 43.  MODIFY COLUMN  You can use the ALTER TABLE statement in SQL Server to modify a column in a table.  BEFORE MODIFYING CHECK THAT YOUR COLUMN IS EMPTY.  SYNTAX ALTER TABLE table_name MODIFY column_name datatype;
  • 44. The SQL RENAME Statement The RENAME statement is used to Rename TABLE in a database.  Syntax RENAME table_name TO NEW TABLE_NAME ;
  • 45.  The SQL DROP TABLE Statement  The DROP TABLE statement is used to drop an existing table in a database.  Syntax  DROP TABLE table_name;
  • 46.  SQL TRUNCATE TABLE  The TRUNCATE TABLE statement is used to Remove all rows from table but not table.  Syntax  TRUNCATE TABLE table_name;
  • 48. WHAT IS DML • A data manipulation language (DML) is a family of computer languages including commands permitting users to manipulate data in a database. This manipulation involves • Select To Retrieve Data. • Inserting Data Into Database Tables. • Deleting Data From Existing Tables. • Updating Existing Data.
  • 49. SELECT • To Retrieve Data. Which Is Basically In Backend And Also In Database. • 1) SELECT * FROM TAB; • 2) SELECT * FROM EMP • WHERE ENAME = ‘KING’;
  • 50. WHAT IS INSERT • Insert command Basically manipulates data in a way/sense of adding/inserting rows into a table. According To Rules Applied On Table Like Data Types And Constraints.
  • 51. Where we use Insert Command • We Use Insert Command In SQL To Insert Rows. • After We Created Table. • When You Needed More Data To Be Saved In Backend.
  • 52. Syntax And Query • Syntax : Insert Into • Query : INSERT INTO UCC VALUES(1, ’NAME’ );
  • 53. WHAT IS UPDATE • Update command Basically manipulates data in a way/sense of modifying or updating rows from existing tables.
  • 54. Where we use UPDATE Command • We Use Update Command In SQL To Update Rows and data. • When there will be existing rows.
  • 55. Syntax And Query • Syntax : update ucc • Query : update UCC set Name=‘Ali’ where Name=‘Akram’;
  • 56. WHAT IS Delete • Delete command Basically manipulates data in a way/sense of deleting rows from existing tables that contain rows or records.
  • 57. Where we use DELETE Command • We Use delete Command In SQL To delete Rows or records. • When there will be existing rows or records.
  • 58. Syntax And Query • Syntax : delete from Query : delete from UCC where Name=‘Akram’;
  • 60. Function? Stored piece of program that manipulates submitted Data and return some value.
  • 61. Types of Functions o String Functions o Numeric Functions o Group Functions o Date and Time Functions
  • 62. Group Functions Group functions are mathematical functions to operate on sets of rows to give one result per set.
  • 63. Types of Group functions o AVG o COUNT o MAX o MIN o SUM o TRUNC o ROUND
  • 64. 1.AVG: Returns the average value of an expression Query: SQL> select avg(sal) from employee; 2.COUNT: Returns the number of records returned by a select query Query: SQL> select count (USERID) from employee;
  • 65. 3.MAX: Returns the maximum value in a set of values Query: SQL> select max(sal) from employee; 4.MIN: Returns the minimum value in a set of values Query: SQL> select min(sal) from employee;
  • 66. 5.SUM: Calculates the sum of a set of values Query: SQL> select sum(sal) from employee; 6.TRUNC: Trunc a value to a as it is Query: SQL> select trunc(avg(sal),2) from employee; 2073.2142 7.ROUND: ROUND a value according to next one Query: SQL> select round(avg(sal),2) from employee; 2073.2143 AVG(SAL) ---------- 2073.21429
  • 68. WHAT IS A HAVING CLAUSE?  A HAVING clause in SQL specifies that an SQL SELECT statement should only return rows where aggregate values meet the specified conditions. Group By Then Having clause
  • 69. WHY USE A HAVING CLAUSE?  The HAVING CLAUSE is used in an SQL statement because the WHERE KEYWORD cannot be used with aggregate functions.
  • 70. WHERE TO USE A HAVING CLAUSE?  A HAVING CLAUSE is used where a where cannot be used because it does not work with aggregate functions.  In database management an aggregate function is a function where the values of multiple rows are grouped together as input on certain criteria to form a single value of more significant meaning.
  • 71. Having Query Select job, sum(sal) Sum From emp Group By job Having sum(Sal) =4000 Order by job; No row select because Sum(sal) =4000 No ones sum = 4000
  • 72. Sequence list of CLAUSE:  SELECT column_name(s)  FROM table_name  WHERE condition  GROUP BY column_name(s)  HAVING condition  ORDER BY column_name(s);
  • 74. Definition:  Constraints are rules to limit data that can go into a table ,to maintain integrity and accuracy of the data into table .  Constraints are divided into following two types :  1-table level constraints  2-column level constraints  Constraints are used to make sure integrity of data is maintained in database.
  • 75. FOLLOWING ARE THE MOST USED CONSTRAINTS :  Not null  Primary key  Unique key  Foreign key
  • 76. NOT NULL:  By applying not null constraint you are declaring that a not null value cannot be added.  Create table student (s-id int Not Null ,Name varchar (60),Age int); The above query shows that s-id student table will not take any Null value.
  • 77. UNIQUE CONSTRAINT:  A unique constraint that a field or column will only have unique values , no value will repeat.  There will not be any duplicate value , this constraint can be applied on column level or table level.  Create table student (s-id int NOT NULL UNIQUE, NAME varchar(60),Age int );  The above query insures that a s-id of student table will only take unique value ,there also wont be a NULL value.  Using UNIQUE constraint after table is created (column level):  ALTER TABLE student ADD UNIQUE (s-id);
  • 78. PRIMARY KEY :  Primary key constraint uniquely identifies each round in a database.  A primary key must contain unique value and it must not contain null value.  Usually primary key is used to index the data inside the table.  Using primary key constraint at column level  Create table student (s-id int primary key, Name varchar (60)NOT NULL , Age int)  The above command will create a PRIMARY KEY on the s-id.
  • 79.  Using PRIMARY KEY constraint at table level  Alter table student add PRIMARY KEY (s-id);  The above command will create a PRIMARY KEY on the s-id.
  • 80. FOREIGN KEY:  FOREIGN KEY is used to relate two tables.  FOREIGN KEY constraint is also used to restrict actions that would destroy links between two tables.  To understand FOREIGN KEY, lets see its use, with help of below tables:
  • 81. Customer-Detail table : C-id Customer name Address 101 Adam England 102 Alex France 103 Stuart Germany
  • 82. Order-Detail table : Order-id Order-Name C-id 10 order1 101 11 order2 103 12 order3 102
  • 83.  In customer- detail table c-id is a PRIMARY KEY which is set as FOREIGN KEY in order- detail table .  The value which is entered in c-id which is set as FOREIGN KEY in order-detail- table must be present in customer -detail table ,where it is set as PRIMARY KEY.
  • 84. USING FOREIGN KEY AT Column Level: create table Order-Detail( order-id int PRIMARY KEY, order-name varchar(60) NOT NULL, c-id FOREIGN KEY REFERENCES Customer-Detail(c-id) ); In this query ,c-id in the table order-detail is made as FOREIGN KEY ,which is a reference of c-id column in customer-detail table.
  • 85. USING FOREIGN KEY CONSTRAINT AT Table Level:  ALTER table order-Detail  ADD Constraint FK FOREIGN KEY (c-id)  REFERENCES customer-Detail(c-id);
  • 88. WHAT IS A SUBQUERY?  In SQL a Subquery can be simply defined as a query within another query. In other words we can say that a Subquery is a query that is embedded in WHERE clause of another SQL query.
  • 89. WHERE TO USE A SUBQUERY?  A subquery is used to return data that will be used in the main query as a condition to further restrict the data to be retrieved. Subqueries can be used with the SELECT, INSERT, UPDATE, and DELETE statements along with the operators like =, <, >, >=, <=, IN, BETWEEN, etc.
  • 90. INNER AND OUTER QUERIES: The MAIN QUERY is called OUTER QUERY. The SUBQUERY is called INNER QUERY.
  • 91. SYNTAX FOR A SUBQUERY: SELECT column_name FROM table_name WHERE column_name expression operator  ( SELECT COLUMN_NAME from TABLE_NAME WHERE ... );
  • 92. TWO CATAGORIES OF SUBQUERIS:  1. Simple Subquery: This is the kind we saw above. A simple subquery is evaluated once only for each table.  2. Correlated Subquery: This is a type of nested subquery that uses columns from the outer query in its WHERE clause. A correlated subquery is evaluated once for each row.
  • 93. TYPES OF SUBQUERIES:  Single Row Sub Query: Return the outer query one row of results that consists of one column  Multiple Row Sub Query: Return to the outer query more then one row of the results it Require use of IN, ANY, ALL, or EXISTS operators  Multiple Column Sub Query:  Return to the outer query more then one row of the results in this type of query Column list on the left side of operator must be in parentheses it use the IN operator for WHERE and HAVING clauses
  • 94. SINGLE ROW SUBQUERY:  SELECT NAME, SAL, JOB  FROM EMP  WHERE SAL>( SELECT SAL FROM EMP WHERE EMP NO =1);
  • 95. MULTIPLE ROW SUBQUERY:  SELECT NAME, SAL, JOB  FROM EMP  WHERE SAL IN ( SELECT SAL FROM EMP WHERE EMPNO <1)
  • 96. MULTIPLE COLUMN SUBQUERY:  SELECT NAME, SAL, JOB  FROM EMP  WHERE SAL IN( SELECT SAL, JOB FROM EMP WHERE EMP NO < 10 GROUP BY JOB )  AND JOB = ‘MANAGER’
  • 97. JOIN
  • 98. WHAT IS A JOIN?  A join is an SQL operation performed to establish a connection between two or more database tables based on matching columns.
  • 99. WHERE TO USE SQL JOIN ?  SQL JOIN is used when the data from two tables is to be compared.  Where clause used in joining.
  • 100. TYPES OF JOINS: EQUI JOIN NON EQUI JOIN OUTER JOIN
  • 101. EQUI JOIN An equijoin returns only the rows that have equivalent values for the specified columns.
  • 102. EQUI JOIN QUERY:  SELECT m.no , g.no  From games g , movies m  Where m.no = g.no;
  • 103. NON EQUI JOIN A non-equi join doesn't use the equals operator in all of it's join conditions.
  • 104. NOT EQUI JOIN QUERY:  SELECT m.no , g.no  From games g , movies m  Where m.no <> g.no;
  • 105. OUTER JOIN  Outer Join is basically used for the deficiency column so that it can show the other table data fully.  Sign  (+)
  • 106. OUTER JOIN QUERY:  SELECT m.no , g.no  From games g , movies m  Where m.no(+) = g.no;
  • 107. SELF JOIN:  A self JOIN is a regular join, but the table is joined with itself.
  • 108. SELF JOIN QUERY:  SELECT c.comm, s.sal  From emp c , emp s  Where c.comm <> s.sal;