際際滷

際際滷Share a Scribd company logo
Database Management
CLASS-XII
 Database - Collected form of data
 Database (management) system - A computer based record
keeping system.
 Database softwares examples:
 MySQL (open Source)
 ORACLE Database
 MS SQL Server
 SQLite (open Source)
 MariaDB
 PostgreSQL (open Source)
INTRODUCTION
DBMS is a software whose purpose is to store
databases, maintaining databases and using
databases.
Its prime purpose is to perform operations on
databases and to provide data when required.
DBMS reduces Data Redundancy.
It improves data security.
-Inconsistency can be avoided.
 it stores data in organized and Integrated form.
Data remains error free.
Database follows a standard.
AIM OF DBMS
Data remains in the form of tables
Table : combination of rows and columns which
is also known as Relation .
Imagine a database has three tables- Suppliers,
Items and Shipments :
Suppliers (SuppNo., Supp_name, Status, City)
Items (ItemNo., Item_name, Price)
Shipments (SuppNo., ItemNo., Qty_Supplied
Relational Database Model
Components Of a Relation
Relational Model Terminology
Domain: The pool of values for a column
Tuple : Rows of a table
Attribute : Columns of a table
Degree : Number of attributes or columns
Cardinality : Number of tuples or rows
Keys
Primary Key.
Candidate Key :
Alternate Key
Foreign Key :
Referential Integrity
Referential Integrity: A system of rules which is used by a
DBMS to ensure that there is a valid relationship between
related tables or not.
The rules are:
1. You can't delete a record from a primary table if matching records
exist in a related table.
2. You can't change a primary key value in the primary table if that
record has related records.
3. You can't enter a value in the foreign key field of the related table
that doesn't exist in the primary key of the primary table.
4. However, you can enter a Null value in the foreign key, specifying
that the records are unrelated..
MySQL
MySQL is an open source RDBMS which makes use of
SQL for ADDING, DELETING and MODIFYING data from
data bases.
MySQL was developed by MySQL AB company which is
now a part of Sun Microsystems.
 SERVER : which responds to the requests of clients.
CLIENTS : these are the programs which are attached to
database server and send requests to server.
SQL(structured Query Language)
In order to access data within the MySQL database, all
programmers and users must use SQL.
SQL is the set of commands that is recognized by all
RDBMS.
All RDBMS like Mysql,Ms Access,Oracle,and SQL server
use sql as a standard database language
Classification of SQL statements
MySQL Data Types
Using Database
Following command is used to use a Database mysql>
USE <database name >;
For ex -
mysql> USE school;
A message will come saying- database changed
See the Commands
carefully
Table Creation
To create a table in Database, following command is used-
mysql> CREATE TABLE <Table Name> (<Col1> <DataType(Size)>,
<Col2><DataType(size)>, .
. . );
For ex-
mysql>create table student (Roll INT(4) Primary Key, Name CHAR(20),
(Age INT(2), City CHAR(10) ) ;
A message will come saying- Query OK
Primary key restrict a column to have unique values
only.
Insertion of a record in Table
Syntax to insert a record in a Table is-
mysql> INSERT INTO <TableName> (<Col1> <Col2> <Col3> <Col4>
VALUES (<val1>,<val2>,<val3>,<val4>,. . .);
We can change the order of columns as-
Here, we can insert values without specifying column names provided the order of
values for columns should be same as in table.
Dropping a Table
 To drop a table in Database, following command
is
mysql> DROP Table <Table Name>;
For ex -
mysql>drop table <Student>
A message will come saying- Query OK now if you want to
see the structure of the table you cant see because it has
already been deleted.
Modification in Table structure
 To modify structure of a table in Database,
following command is used-
mysql>ALTER TABLE <Table name> ADD/MODIFY(<Col>
<type(size)>, . . . .)
For ex-mysql> Alter Table Student Add (class INT(2));
A message comes saying Query OK .
Again run the DESC command-
 A new column has been add.
 Columns can be added.
 Column size can be changed.
Accessing a Table
Here * means all
columns and without
condition it will displays
all records.
Here only those records will
display where city is
Barabanki.
Syntax to access Data from a table is-
mysql> SELECT <Col Names> FROM <Table Name>
WHERE <Condition>
Here Name and class of only
those records are displayed
which are not from
Barabanki.
Here columns have been
rearranged.
Accessing a Table
Syntax to access Data from a table is-
mysql> SELECT <Col Names> FROM <Table Name>
WHERE <Condition>
Updating a record in Table
Syntax to update a record in a Table is-
mysql> UPDATE <TableName> SET <ColName>=<NewValue>
WHERE
<Condition>
In this table, age of
meera is to be set 6. and
city of roll 1004 and 1005
is to be set as Lucknow.
Deletion of a record from a Table
 Syntax to delete a record from a Table is-
mysql>DELETE FROM<TableName>WHERE <Condition>
To delete all records from a table, following command will be used-
Viewing records
after deletion.
Distinct keyword
l cities in the table.
Viewing Tables in a Database
Displays all tables in a Databse.
Table from another Table
See the example carefully
Syntax for creation of a table from another table is -
mysql>CREATE TABLE <TableName>
AS (SELECT <Cols> FROM <ExistingTable>
WHERE <Condition>);
Pattern Matching
With like two symbols are to
be used % and _.
%represent multiple
characters whereas _
represents one charachetr .
In above example all the names starting with S are
shown.
In example given below all the names having u as
second character are shown.
Other SQL Commands
 Select * from Student where city in (Jaipur,Ajmer);
 Select * from Student where city Not in(Jaipur,Ajmer);
 Select * from Student where age between 5 and 7;
 Select * from Student Order by name DESC ;
 Select 5 * 6 from DUAL ;
AGGREGATE FUNCTIONS
Aggregation is an operation that computes a single value
from all the values of an attribute.
SQL provides five functions that apply to an attribute of a
relation and produce some aggregatation of that column
-SUM: computes the sum of values in a column.
-AVG: Computes the average of value in an attribute.
-MIN/MAX: Computes the min/max value in an attribute.
-COUNT: Computes the number of values in an
attribute(including duplicates unless they are explicitly
eliminated with DISTINCT)
Example TABLE
SUM()
AVG()
MIN() & MAX()
COUNT()
0RDER BY()
JOINS
 Join is a query which combine rows of two or more
tables.
 In a join-query, we need to provide a list of tables in
FROM Clause.
 The process of combining multiple tables in order to
retrieve data is called joining. For ex-
SELECT * FROM emp1, dept;
 Unrestricted join or Cartesian product of both the
tables gives all possible concatenations of all the rows
of both the tables.
EQUI JOIN AND NATURAL JOIN
To get the details about the departments and their in- charges,
query will be-
mysql> SELECT name, deptname from emp1, dept
where emp1.empcode=dept.deptic;
When both the tables have same field name, then to show a
field from particular table, use the following pattern to access a
field- <Table name>.<Field Name>
Ex- emp1.empcode
This is an example of Equi-
Join, in which columns are
compared for equality and it
is also an example of
Natural- Join, in which only
one of the identical columns
exists.
INNER JOIN
Inner join only takes that rows
from Cartesian Product Table
that satisfy the join condition.
LEFT JOIN
 When we use LEFT-JOIN, it
returns all rows from first
table whether it has
matching rows in second
table or not.
 It shows NULL in columns
for the unmatched rows of
first table.
mysql>SELECT <Col List>
FROM <table1> LEFT JOIN
<table2>
ON <joining
RIGHT JOIN
 When we use RIGHT-JOIN, it
returns all rows from second
table whether it has matching
rows in first table or not.
 It shows NULL in columns for
the unmatched rows of second
table.
mysql>SELECT <Col List> FROM
<table1> RIGHT JOIN <table2>
ON <joining
Condition>
Data Base Management 1 Database Management.pptx

More Related Content

Similar to Data Base Management 1 Database Management.pptx (20)

PPTX
Getting Started with MySQL I
Sankhya_Analytics
PPT
MYSQL.ppt
webhostingguy
PDF
Chapter 6 SQL Lab Tutorial.pdf
TamiratDejene1
PPTX
Lab
neelam_rawat
PPTX
MySQL Essential Training
HudaRaghibKadhim
PPTX
SQl data base management and design
franckelsania20
PPTX
sql.pptx
slavskrillex
PDF
Php, mysq lpart5(mysql)
Subhasis Nayak
PDF
working with database using mysql
Subhasis Nayak
PPT
Module02
Sridhar P
PPTX
3-Chapter-Edit.pptx debre tabour university
alemunuruhak9
PPT
dbs class 7.ppt
MARasheed3
PPTX
DBMS and SQL(structured query language) .pptx
jainendraKUMAR55
PDF
Mysql cheatsheet
Adolfo Nasol
PPT
Mysql
TSUBHASHRI
PPT
Interactive SQL: SQL, Features of SQL, DDL & DML
IsakkiDeviP
PPTX
ADVANCE ITT BY PRASAD
PADYALAMAITHILINATHA
PPTX
Unit - II.pptx
MrsSavitaKumbhare
PPTX
MySQL.pptx comuterscience from kvsbbsrs.
sudhasuryasnata06
PPTX
DBMS UNIT-2.pptx ggggggggggggggggggggggg
Praveen Kumar
Getting Started with MySQL I
Sankhya_Analytics
MYSQL.ppt
webhostingguy
Chapter 6 SQL Lab Tutorial.pdf
TamiratDejene1
MySQL Essential Training
HudaRaghibKadhim
SQl data base management and design
franckelsania20
sql.pptx
slavskrillex
Php, mysq lpart5(mysql)
Subhasis Nayak
working with database using mysql
Subhasis Nayak
Module02
Sridhar P
3-Chapter-Edit.pptx debre tabour university
alemunuruhak9
dbs class 7.ppt
MARasheed3
DBMS and SQL(structured query language) .pptx
jainendraKUMAR55
Mysql cheatsheet
Adolfo Nasol
Mysql
TSUBHASHRI
Interactive SQL: SQL, Features of SQL, DDL & DML
IsakkiDeviP
ADVANCE ITT BY PRASAD
PADYALAMAITHILINATHA
Unit - II.pptx
MrsSavitaKumbhare
MySQL.pptx comuterscience from kvsbbsrs.
sudhasuryasnata06
DBMS UNIT-2.pptx ggggggggggggggggggggggg
Praveen Kumar

More from PreeTVithule1 (7)

PPTX
File handling for reference class 12.pptx
PreeTVithule1
PPTX
01 file handling for class use class pptx
PreeTVithule1
PPT
network protocols7 class 12 computer .ppt
PreeTVithule1
PPT
Network and network types6 class 12 computer.ppt
PreeTVithule1
PPTX
Exception handling with python class 12.pptx
PreeTVithule1
PPTX
CHAPTER 01 FUNCTION in python class 12th.pptx
PreeTVithule1
PPTX
7-2-data-structures-ii-stacks-queues.pptx
PreeTVithule1
File handling for reference class 12.pptx
PreeTVithule1
01 file handling for class use class pptx
PreeTVithule1
network protocols7 class 12 computer .ppt
PreeTVithule1
Network and network types6 class 12 computer.ppt
PreeTVithule1
Exception handling with python class 12.pptx
PreeTVithule1
CHAPTER 01 FUNCTION in python class 12th.pptx
PreeTVithule1
7-2-data-structures-ii-stacks-queues.pptx
PreeTVithule1
Ad

Recently uploaded (20)

PPTX
How to Setup Automatic Reordering Rule in Odoo 18 Inventory
Celine George
PDF
Cooperative wireless communications 1st Edition Yan Zhang
jsphyftmkb123
PDF
TechSoup Microsoft Copilot Nonprofit Use Cases and Live Demo - 2025.06.25.pdf
TechSoup
PPTX
Elo the Hero is an story about a young boy who became hero.
TeacherEmily1
PDF
Genomics Proteomics and Vaccines 1st Edition Guido Grandi (Editor)
kboqcyuw976
PPTX
ENGLISH 8 REVISED K-12 CURRICULUM QUARTER 1 WEEK 1
LeomarrYsraelArzadon
PPTX
How to Add a Custom Button in Odoo 18 POS Screen
Celine George
PDF
Lean IP - Lecture by Dr Oliver Baldus at the MIPLM 2025
MIPLM
PDF
Supply Chain Security A Comprehensive Approach 1st Edition Arthur G. Arway
rxgnika452
PDF
I3PM Industry Case Study Siemens on Strategic and Value-Oriented IP Management
MIPLM
PPTX
How to Create & Manage Stages in Odoo 18 Helpdesk
Celine George
PDF
Andreas Schleicher_Teaching Compass_Education 2040.pdf
EduSkills OECD
PPTX
Lesson 1 Cell (Structures, Functions, and Theory).pptx
marvinnbustamante1
PPTX
Connecting Linear and Angular Quantities in Human Movement.pptx
AngeliqueTolentinoDe
PPTX
PLANNING A HOSPITAL AND NURSING UNIT.pptx
PRADEEP ABOTHU
PPTX
Marketing Management PPT Unit 1 and Unit 2.pptx
Sri Ramakrishna College of Arts and science
PDF
Lesson 1 - Nature of Inquiry and Research.pdf
marvinnbustamante1
PPTX
Parsing HTML read and write operations and OS Module.pptx
Ramakrishna Reddy Bijjam
PDF
WATERSHED MANAGEMENT CASE STUDIES - ULUGURU MOUNTAINS AND ARVARI RIVERpdf
Ar.Asna
PPTX
Natural Language processing using nltk.pptx
Ramakrishna Reddy Bijjam
How to Setup Automatic Reordering Rule in Odoo 18 Inventory
Celine George
Cooperative wireless communications 1st Edition Yan Zhang
jsphyftmkb123
TechSoup Microsoft Copilot Nonprofit Use Cases and Live Demo - 2025.06.25.pdf
TechSoup
Elo the Hero is an story about a young boy who became hero.
TeacherEmily1
Genomics Proteomics and Vaccines 1st Edition Guido Grandi (Editor)
kboqcyuw976
ENGLISH 8 REVISED K-12 CURRICULUM QUARTER 1 WEEK 1
LeomarrYsraelArzadon
How to Add a Custom Button in Odoo 18 POS Screen
Celine George
Lean IP - Lecture by Dr Oliver Baldus at the MIPLM 2025
MIPLM
Supply Chain Security A Comprehensive Approach 1st Edition Arthur G. Arway
rxgnika452
I3PM Industry Case Study Siemens on Strategic and Value-Oriented IP Management
MIPLM
How to Create & Manage Stages in Odoo 18 Helpdesk
Celine George
Andreas Schleicher_Teaching Compass_Education 2040.pdf
EduSkills OECD
Lesson 1 Cell (Structures, Functions, and Theory).pptx
marvinnbustamante1
Connecting Linear and Angular Quantities in Human Movement.pptx
AngeliqueTolentinoDe
PLANNING A HOSPITAL AND NURSING UNIT.pptx
PRADEEP ABOTHU
Marketing Management PPT Unit 1 and Unit 2.pptx
Sri Ramakrishna College of Arts and science
Lesson 1 - Nature of Inquiry and Research.pdf
marvinnbustamante1
Parsing HTML read and write operations and OS Module.pptx
Ramakrishna Reddy Bijjam
WATERSHED MANAGEMENT CASE STUDIES - ULUGURU MOUNTAINS AND ARVARI RIVERpdf
Ar.Asna
Natural Language processing using nltk.pptx
Ramakrishna Reddy Bijjam
Ad

Data Base Management 1 Database Management.pptx

  • 2. Database - Collected form of data Database (management) system - A computer based record keeping system. Database softwares examples: MySQL (open Source) ORACLE Database MS SQL Server SQLite (open Source) MariaDB PostgreSQL (open Source) INTRODUCTION
  • 3. DBMS is a software whose purpose is to store databases, maintaining databases and using databases. Its prime purpose is to perform operations on databases and to provide data when required. DBMS reduces Data Redundancy. It improves data security. -Inconsistency can be avoided. it stores data in organized and Integrated form. Data remains error free. Database follows a standard. AIM OF DBMS
  • 4. Data remains in the form of tables Table : combination of rows and columns which is also known as Relation . Imagine a database has three tables- Suppliers, Items and Shipments : Suppliers (SuppNo., Supp_name, Status, City) Items (ItemNo., Item_name, Price) Shipments (SuppNo., ItemNo., Qty_Supplied Relational Database Model
  • 5. Components Of a Relation
  • 6. Relational Model Terminology Domain: The pool of values for a column Tuple : Rows of a table Attribute : Columns of a table Degree : Number of attributes or columns Cardinality : Number of tuples or rows
  • 11. Referential Integrity Referential Integrity: A system of rules which is used by a DBMS to ensure that there is a valid relationship between related tables or not. The rules are: 1. You can't delete a record from a primary table if matching records exist in a related table. 2. You can't change a primary key value in the primary table if that record has related records. 3. You can't enter a value in the foreign key field of the related table that doesn't exist in the primary key of the primary table. 4. However, you can enter a Null value in the foreign key, specifying that the records are unrelated..
  • 12. MySQL MySQL is an open source RDBMS which makes use of SQL for ADDING, DELETING and MODIFYING data from data bases. MySQL was developed by MySQL AB company which is now a part of Sun Microsystems. SERVER : which responds to the requests of clients. CLIENTS : these are the programs which are attached to database server and send requests to server.
  • 13. SQL(structured Query Language) In order to access data within the MySQL database, all programmers and users must use SQL. SQL is the set of commands that is recognized by all RDBMS. All RDBMS like Mysql,Ms Access,Oracle,and SQL server use sql as a standard database language
  • 14. Classification of SQL statements
  • 16. Using Database Following command is used to use a Database mysql> USE <database name >; For ex - mysql> USE school; A message will come saying- database changed See the Commands carefully
  • 17. Table Creation To create a table in Database, following command is used- mysql> CREATE TABLE <Table Name> (<Col1> <DataType(Size)>, <Col2><DataType(size)>, . . . ); For ex- mysql>create table student (Roll INT(4) Primary Key, Name CHAR(20), (Age INT(2), City CHAR(10) ) ; A message will come saying- Query OK Primary key restrict a column to have unique values only.
  • 18. Insertion of a record in Table Syntax to insert a record in a Table is- mysql> INSERT INTO <TableName> (<Col1> <Col2> <Col3> <Col4> VALUES (<val1>,<val2>,<val3>,<val4>,. . .); We can change the order of columns as- Here, we can insert values without specifying column names provided the order of values for columns should be same as in table.
  • 19. Dropping a Table To drop a table in Database, following command is mysql> DROP Table <Table Name>; For ex - mysql>drop table <Student> A message will come saying- Query OK now if you want to see the structure of the table you cant see because it has already been deleted.
  • 20. Modification in Table structure To modify structure of a table in Database, following command is used- mysql>ALTER TABLE <Table name> ADD/MODIFY(<Col> <type(size)>, . . . .) For ex-mysql> Alter Table Student Add (class INT(2)); A message comes saying Query OK . Again run the DESC command- A new column has been add. Columns can be added. Column size can be changed.
  • 21. Accessing a Table Here * means all columns and without condition it will displays all records. Here only those records will display where city is Barabanki. Syntax to access Data from a table is- mysql> SELECT <Col Names> FROM <Table Name> WHERE <Condition>
  • 22. Here Name and class of only those records are displayed which are not from Barabanki. Here columns have been rearranged. Accessing a Table Syntax to access Data from a table is- mysql> SELECT <Col Names> FROM <Table Name> WHERE <Condition>
  • 23. Updating a record in Table Syntax to update a record in a Table is- mysql> UPDATE <TableName> SET <ColName>=<NewValue> WHERE <Condition> In this table, age of meera is to be set 6. and city of roll 1004 and 1005 is to be set as Lucknow.
  • 24. Deletion of a record from a Table Syntax to delete a record from a Table is- mysql>DELETE FROM<TableName>WHERE <Condition> To delete all records from a table, following command will be used- Viewing records after deletion.
  • 25. Distinct keyword l cities in the table. Viewing Tables in a Database Displays all tables in a Databse.
  • 26. Table from another Table See the example carefully Syntax for creation of a table from another table is - mysql>CREATE TABLE <TableName> AS (SELECT <Cols> FROM <ExistingTable> WHERE <Condition>);
  • 27. Pattern Matching With like two symbols are to be used % and _. %represent multiple characters whereas _ represents one charachetr . In above example all the names starting with S are shown. In example given below all the names having u as second character are shown.
  • 28. Other SQL Commands Select * from Student where city in (Jaipur,Ajmer); Select * from Student where city Not in(Jaipur,Ajmer); Select * from Student where age between 5 and 7; Select * from Student Order by name DESC ; Select 5 * 6 from DUAL ;
  • 29. AGGREGATE FUNCTIONS Aggregation is an operation that computes a single value from all the values of an attribute. SQL provides five functions that apply to an attribute of a relation and produce some aggregatation of that column -SUM: computes the sum of values in a column. -AVG: Computes the average of value in an attribute. -MIN/MAX: Computes the min/max value in an attribute. -COUNT: Computes the number of values in an attribute(including duplicates unless they are explicitly eliminated with DISTINCT)
  • 31. SUM()
  • 32. AVG()
  • 36. JOINS Join is a query which combine rows of two or more tables. In a join-query, we need to provide a list of tables in FROM Clause. The process of combining multiple tables in order to retrieve data is called joining. For ex- SELECT * FROM emp1, dept; Unrestricted join or Cartesian product of both the tables gives all possible concatenations of all the rows of both the tables.
  • 37. EQUI JOIN AND NATURAL JOIN To get the details about the departments and their in- charges, query will be- mysql> SELECT name, deptname from emp1, dept where emp1.empcode=dept.deptic; When both the tables have same field name, then to show a field from particular table, use the following pattern to access a field- <Table name>.<Field Name> Ex- emp1.empcode This is an example of Equi- Join, in which columns are compared for equality and it is also an example of Natural- Join, in which only one of the identical columns exists.
  • 38. INNER JOIN Inner join only takes that rows from Cartesian Product Table that satisfy the join condition.
  • 39. LEFT JOIN When we use LEFT-JOIN, it returns all rows from first table whether it has matching rows in second table or not. It shows NULL in columns for the unmatched rows of first table. mysql>SELECT <Col List> FROM <table1> LEFT JOIN <table2> ON <joining
  • 40. RIGHT JOIN When we use RIGHT-JOIN, it returns all rows from second table whether it has matching rows in first table or not. It shows NULL in columns for the unmatched rows of second table. mysql>SELECT <Col List> FROM <table1> RIGHT JOIN <table2> ON <joining Condition>