SlideShare a Scribd company logo
1 of 38
KIRTIGUPTA,PGTCS,KVNTPCDADRI
RELATIONAL DATABASE CONCEPT
KIRTIGUPTA,PGTCS,KVNTPCDADRI
DATABASE
 May be defined as a collection of interrelated
data stored together to serve multiple application
 It is computer based record keeping system.
 It not only allows to store but also allows us
modification of data as per requirements.
Database: Database is a collection of inter-related data
which helps in efficient retrieval, insertion and deletion
of data from database and organizes the data in the form
of tables, views, schemas, reports etc. For Example,
university database organizes the data about students,
faculty, and admin staff etc. which helps in efficient
retrieval, insertion and deletion of data from it.
KIRTIGUPTA,PGTCS,KVNTPCDADRI
DATABASE CONCEPTS
 WHY DO WE NEED DATABASE
 To manage large chunks of data: if size of data increases
into thousands of records, it will simply create a problem
to manage.Database can manage large amount of data.
 Accuracy: Through validation rule in database ,data accuracy can
 be maintained.
 Ease of updating data: With the database, we can flexibly update
the data according to our convenience. Moreover, multiple
people can also edit data at same time.
 Security of data: With databases we have security groups
and
 privileges to restrict access.
 Data integrity: In databases, we can be assured of accuracy and
consistency of data due to the built in integrity checks and access
KIRTIGUPTA,PGTCS,KVNTPCDADRI
DBMS
 A DBMS refers to Database Management System
 It is a software that is responsible for storing,
manipulating, maintaining and utilizing database.
 A database along with the a DBMS is referred to
as a database system.
 There are various DBMS software available in the
market like :-
Oracle, MS SQL Server, MySQL, Sybase, PostgreSQL,
SQLite, MS Access, Paradox, DB2 and etc.
MySQL is open source and freeware DBMS.
KIRTIGUPTA,PGTCS,KVNTPCDADRI
PURPOSE OF DBMS
KIRTIGUPTA,PGTCS,KVNTPCDADRI
Data Model Way of data representation
Data model is a model or presentation which shows How data is organized or stored in
the database. The data is modeled by one of the following given models-
 Relational Data Model
In this model data is organized into Relations or Tables (i.e. Rows and Columns). A row
in a table represents a relationship of data to each other and also called a Tuple or
Record. A column is called Attribute or Field.
 Network Data Model
In this model, data is represented by collection of records and relationship among data
is shown by Links.
 Hierarchical Data Model
In this model, Records are organized as Trees. Records at top level is called Root record
and this may contains multiple directly linked children records.
 Object Oriented Data Model
 In this model, records are represented as a objects. The collection of similar types
of object is called class.
KIRTIGUPTA,PGTCS,KVNTPCDADRI
KIRTIGUPTA,PGTCS,KVNTPCDADRI
RELATIONAL DATABASE MODEL
 In relational database model data is organized
into table (i.e. rows and columns).
 These tables are also known as relations.
 A row in a table represent relationship among a set
of values.
 A column represent the field/attributes related to
relation under which information will be stored.
 For example if we want to store details of
students then : Roll, Name, Class, Section, etc. will
be the column/attributes and the collection of all the
column information will become a Row/Record
KIRTIGUPTA,PGTCS,KVNTPCDADRI
RELATIONAL DATABASE MODEL
 A Relational database use
Structured Query Language
(SQL), which is a standard
user application that provides
an easy programming interface
for database interaction.
KIRTIGUPTA,PGTCS,KVNTPCDADRI
SAMPLE TABLES
DEPARTMENT
EMPLOYEE
EMPNO ENAME GENDER DEPTNO SALARY COMM
1 ANKITA F 10 20000 1200
2 SUJEET M 20 24000
3 VIJAYA F 10 28000 2000
4 NITIN M 30 18000 3000
5 VIKRAM M 30 22000 1700
DEPTNO DNAME LOCATION
10 HR NEW YORK
20 ACCOUNTS BRAZIL
30 SALES CANADA
40 IT INDIA
KIRTIGUPTA,PGTCS,KVNTPCDADRI
COMPONENT OF A TABLE
 Byte : group of 8 bits and is used to store a
character.
 Data Item : smallest unit of named data. It
represent one type of information and often
referred to as a field or column information
 Record : collection of data items which
represent a complete unit of
information
: collection of all Rows and Columns. Table
KIRTIGUPTA,PGTCS,KVNTPCDADRI
Fields
Data Items (requires 5 bytes)
Records
Table
DEPTNO DNAME LOCATION
10 HR NEW YORK
20 ACCOUNTS BRAZIL
30 SALES CANADA
40 IT INDIA
KIRTIGUPTA,PGTCS,KVNTPCDADRI
COMMON RDBMS
 Oracle, MS SQL Server, MySQL, IBM DB2, IBM
Informix,
Enterprise,
SAP Sybase,
SAP
Sybas
e
Adaptive Server
IQ, Teradata,
PostgreSQL, SQLite, etc.
 Out of these MySQL, PostgreSQL and SQLite are
Open source implementation.
KIRTIGUPTA,PGTCS,KVNTPCDADRI
COMMON RDBMS
 MySQL
 Runs on virtually all platforms including Linux, Unix and
Windows. Popular for web based application and online
publishing. It is a part of LAMP (Linux, Apache, MySQL,
PHP) stack
 SQLite
 Relational DBMS but it is not client-server database engine
rather, it is embedded into end program. Arguably the most
widely deployed database engine as it is used by several browsers,
OS and embedded systems(Mobiles).
 PostgreSQL
 General purpose object-relational DBMS. It is the most
advanced open source database system. It is free and open source
i.e. source code is available under PostgreSQL license, a
liberal open source license.
KIRTIGUPTA,PGTCS,KVNTPCDADRI
COMMON DBMS TOOLS FOR
MOBILE DEVICES
 SQL Anywhere, DB2 Everywhere, IBM Mobile
Database, SQL Server Compact, SQL Server
Express, Oracle DatabaseLite, SQLite, SQLBase etc.
 Out of these SQLite is public domain open source
implementation
KIRTIGUPTA,PGTCS,KVNTPCDADRI
KIRTIGUPTA,PGTCS,KVNTPCDADRI
DATABASE CONCEPTS
RELATIONAL DATABASE TERMS
KIRTIGUPTA,PGTCS,KVNTPCDADRI
JUST A MINUTE…
Identify the following in the above table
1) Degree of Table
2) Cardinality of Table
3) Attributes of Table
4) Tuple
5) Data types of Book Code and Price (as studied in Python)
BOOKCODE BOOKNAME PUB PRICE
B001 LET US C BPB 400
B002 VISUAL BASIC EEE 350
B003 JAVA PHI 550
B004 VC++ BPB 750
KIRTIGUPTA,PGTCS,KVNTPCDADRI
CONCEPT OF KEYS
In relation each record must be unique i.e. no two
identical records are allowed in the Database. A
key attribute identifies the record and must have
unique values. There are various types of Keys:
Primary Key, Candidate Key, Alternate Key
and Foreign Key.
EMPNO ENAME GENDER DEPTNO SALARY COMM
1 ANKITA F 10 20000 1200
2 SUJEET M 20 24000
3 VIJAYA F 10 28000 2000
4 NITIN M 30 18000 3000
5 VIKRAM M 30 22000 1700
KIRTIGUPTA,PGTCS,KVNTPCDADRI
KEYS
 Primary Key
 A set of one or more attribute that can identify a record
uniquely in the relation is called Primary Key.
 There can be only 1 primary key in a table
 Allows only distinct (no duplicate) values and also forces
mandatory entry (NOT NULL) i.e. we cannot left it blank.
 Candidate Key
 In a table there can be more than one attribute which
contains unique values. These columns are known as
candidate key as they are the candidate for primary key.
 Among these database analyst select one as a primary key
based on requirement like must contain unique value,
compulsory entry and where maximum searching is done
etc.
KIRTIGUPTA,PGTCS,KVNTPCDADRI
KEYS
 Alternate Key
 In case of multiple candidate keys, one of them will
be selected as Primary Key and rest of the column
will serve as Alternate Key
 A Candidate Key which is not a primary key is an
Alternate Key.
 Foreign key
 Used to create relationship between two tables.
 It is a non-key attribute whose value is derived from
the Primary key of another table.
 Foreign key column will for the value in Primary key of
another table, if present then entry will be allowed
otherwise data will be rejected.
 Primary Key column table from where values will be
derived is known as Primary Table or Master Table
or Parent Table and Foreign key column table will be
Foreign Table or Detail Table or Child table
KIRTIGUPTA,PGTCS,KVNTPCDADRI
CONCEPT OF KEYS
KIRTIGUPTA,PGTCS,KVNTPCDADRI
DEPARTMENT
Parent
Table
EMPLOYEE
From the Above table definition we can observe that the
DEPTNO column of EMPLOYEE table is deriving its value from
DEPTNO of table DEPARTMENT. So we can say that the DEPTNO of
EMPLOYEE table is a foreign key whose value is dependent upon the
Primary key column DEPTNO of table DEPARTMENT.
Child
Table
EMPNO ENAME GENDER DEPTNO SALARY COMM
1 ANKITA F 10 20000 1200
2 SUJEET M 20 24000
3 VIJAYA F 10 28000 2000
4 NITIN M 30 18000 3000
5 VIKRAM M 30 22000 1700
DEPTNO DNAME LOCATION
10 HR NEW YORK
20 ACCOUNTS BRAZIL
30 SALES CANADA
40 IT INDIA
Parent
Table
KIRTIGUPTA,PGTCS,KVNTPCDADRI
REFERENTIAL INTEGRITY
 Used to ensure relationship between records in
related tables are valid and user don’t
accidentally delete or change the related data.
 Referential integrity can be applied when:
 The master table’s column is a Primary Key or has a
unique index
 The related fields have the same data type
 Both tables must belong to same database.
KIRTIGUPTA,PGTCS,KVNTPCDADRI
REFERENTIAL INTEGRITY
 When referential integrity is enforced using
Foreign Key you must observe the following
rules:
You cannot enter a value in Child Table which is not
available in Master Table’s Primary key column.
However you can enter NULL values in foreign key
You cannot delete a record from Master Table if
matching record exists in related table
You cannot modify or change the Primary Key value in
Master table if its matching record is present in related
table.
KIRTIGUPTA,PGTCS,KVNTPCDADRI
BRIEF HISTORY OF MYSQL
 MySQL is freely available open source RDBMS
 Can be downloaded from www.mysql.org
 In MySQL information is stored in Tables.
 Provides features that support secure environment for
storing, maintaining and accessing data.
 It is fast, reliable, scalable alternative to many of the
commercial RDBMS today.
 Create and supported by MySQL AB, a company
based in Sweden. This company is now subsidiary
of Sun Microsystems. On April 2009 Oracle
Corp. acquires Sun Microsystems.
 The chief inventor of MySQL was Michael
Widenius(a.k.a Monty). MySQL has been named after
Monty’s daughter My. The logo of MySQL is dolphin
and name of that dolphin is ‘Sakila’
KIRTIGUPTA,PGTCS,KVNTPCDADRI
MYSQL DATABASE SYSTEM
 MySQL database system refers to the
andcombination of a MySQL server instance
MySQL database.
It operates using Client/Server architecture in
which the server runs on the machine containing the
database and client connects to server over a
network
MySQL is a multiuser database system, meaning
several users can access the
database simultaneously
KIRTIGUPTA,PGTCS,KVNTPCDADRI
MYSQL DATABASE SYSTEM
 The Server
requirements and provide the requested information to the Client
 The Client
 Are the programs that connect to MySQL server and sends
requests to the server and receives the response of
Server. Client may be the MySQL prompt or it may be
Front-end programming which connect to server
programmatically like connecting to MySQL using Python
Language or Java or any other language
 Listens for client requests coming in over the
network and access the database as per the
KIRTIGUPTA,PGTCS,KVNTPCDADRI
FEATURES OF MYSQL
 Speed
 MySQL runs very fast.
 Ease of Use
 Can be managed from command line or GUI
 Cost
 Is available free of cost. It is Open Source
 Query language Support
 Supports SQL
 Portability
 Can be run on any platform and supported by various
compilers
 Data Types
 Supports various data types like Numbers, Char etc.
KIRTIGUPTA,PGTCS,KVNTPCDADRI
FEATURES OF MYSQL
 Security
 Offers privileges and password systems that is very flexible and
secure.
 Scalability and Limits
 Can handle large databases. Some of real life MySQL databases
contains millions of records.
 Connectivity
 Clients can connect to MySQL using drivers
 Localization
 The server can provide error message to client in many language
 Client and Tools
 Provides several client and utility programs. Like mysqldump and
mysqladmin. GUI tools like MySQL Administration and Query
Browser
KIRTIGUPTA,PGTCS,KVNTPCDADRI
STARTING MYSQL
Click on Start  All Programs  MySQL 
MySQL Server  MySQL Command Line Client
Enter the
password
given
during
installation
KIRTIGUPTA,PGTCS,KVNTPCDADRI
mysql> prompt means
now MySQL is ready
to take your command
and execute
To exit from MySQL type exit or quit in front of
mysql prompt
KIRTIGUPTA,PGTCS,KVNTPCDADRI
SQL AND MYSQL
 SQL stands for Structured Query Language.
 Is a language that enables you to create and
operate on relational databases.
 MySQL uses SQL in order to access databases.
 It is the standard language used by almost all the
database s/w vendors.
 Pronounced as SEQUEL
 Original versionwas developed by IBM’s
Almanden Research Center
 Latest ISO standard of SQL was released in 2008 and
named as SQL:2008
KIRTIGUPTA,PGTCS,KVNTPCDADRI
PROCESSING CAPABILITIES OF
SQL
 DDL (Data Definition Language)
 DML (Data Manipulation Language)
 Embedded DML
 View
 Authorization
 Integrity
 Transaction Control
KIRTIGUPTA,PGTCS,KVNTPCDADRI
DATA DEFINITION LANGUAGE
 It allows to create database objects like creating
a table, view or any other database objects.
 The information about created objects are stored in
special file called DATA DICTIONARY
 DATA DICTIONARY contains metadata i.e. data
about data.
 While creating a table DDL allows
to specify–
name of table, attributes, data types of
attribute, may define range of values
each
that
attributes can store, etc
 Major commands of DDL
ALTER, DROP
are – CREATE,
KIRTIGUPTA,PGTCS,KVNTPCDADRI
DATA MANIPULATION
LANGUAGE
 It allows to perform following operation on
table
 Retrieval of information stored in table
 Insertion of new data in table
 Modification of existing data in table
 Deletion of existing data from table
 DML is of 2 type
 Procedural DML (in this we specify what data is needed
and how to get it)
 Non-Procedural DML (in this we
specify what data is needed without specifying how to
get it)
 Main DML commands are –
SELECT, INSERT, UPDATE AND DELETE
KIRTIGUPTA,PGTCS,KVNTPCDADRI
JUST A MINUTE…
 What is Database? What are the advantages of
Database System?
 What is DDL and DML? Give examples of command
belonging to each category
 What is the difference between Primary key and
Candidate key
 What is Primary Key? What are the restriction
imposed by Primary Key? How many primary key
can be applied on a Table?
 What is Degree and Cardinality of table?
KIRTIGUPTA,PGTCS,KVNTPCDADRI

More Related Content

What's hot

ความรู้เบื้องต้นฐานข้อมูล 1
ความรู้เบื้องต้นฐานข้อมูล 1ความรู้เบื้องต้นฐานข้อมูล 1
ความรู้เบื้องต้นฐานข้อมูล 1Witoon Thammatuch-aree
 
Introduction to Database Concepts
Introduction to Database ConceptsIntroduction to Database Concepts
Introduction to Database ConceptsRosalyn Lemieux
 
Lecture 07 relational database management system
Lecture 07 relational database management systemLecture 07 relational database management system
Lecture 07 relational database management systememailharmeet
 
Database Concepts and Terminologies
Database Concepts and TerminologiesDatabase Concepts and Terminologies
Database Concepts and TerminologiesOusman Faal
 
L4 working with tables and data
L4 working with tables and dataL4 working with tables and data
L4 working with tables and dataBryan Corpuz
 
Sql interview q&a
Sql interview q&aSql interview q&a
Sql interview q&aSyed Shah
 
DATABASE CONCEPTS AND PRACTICAL EXAMPLES
DATABASE CONCEPTS AND PRACTICAL EXAMPLESDATABASE CONCEPTS AND PRACTICAL EXAMPLES
DATABASE CONCEPTS AND PRACTICAL EXAMPLESNathRam2
 
A short introduction to database systems.ppt
A short introduction to  database systems.pptA short introduction to  database systems.ppt
A short introduction to database systems.pptMuruly Krishan
 
Chapter 7 relation database language
Chapter 7 relation database languageChapter 7 relation database language
Chapter 7 relation database languageJafar Nesargi
 
COMPUTERS Database
COMPUTERS Database COMPUTERS Database
COMPUTERS Database Rc Os
 
08. Object Oriented Database in DBMS
08. Object Oriented Database in DBMS08. Object Oriented Database in DBMS
08. Object Oriented Database in DBMSkoolkampus
 
The three level of data modeling
The three level of data modelingThe three level of data modeling
The three level of data modelingsharmila_yusof
 
Data Models & Introduction to UML
Data Models & Introduction to UML Data Models & Introduction to UML
Data Models & Introduction to UML نبيله نواز
 

What's hot (20)

ความรู้เบื้องต้นฐานข้อมูล 1
ความรู้เบื้องต้นฐานข้อมูล 1ความรู้เบื้องต้นฐานข้อมูล 1
ความรู้เบื้องต้นฐานข้อมูล 1
 
Introduction to Database Concepts
Introduction to Database ConceptsIntroduction to Database Concepts
Introduction to Database Concepts
 
Lecture 07 relational database management system
Lecture 07 relational database management systemLecture 07 relational database management system
Lecture 07 relational database management system
 
RDBMS_Unit 01
RDBMS_Unit 01RDBMS_Unit 01
RDBMS_Unit 01
 
Database Concepts and Terminologies
Database Concepts and TerminologiesDatabase Concepts and Terminologies
Database Concepts and Terminologies
 
Database structure
Database structureDatabase structure
Database structure
 
L4 working with tables and data
L4 working with tables and dataL4 working with tables and data
L4 working with tables and data
 
Ch1- Introduction to dbms
Ch1- Introduction to dbmsCh1- Introduction to dbms
Ch1- Introduction to dbms
 
Sql interview q&a
Sql interview q&aSql interview q&a
Sql interview q&a
 
Rdbms
RdbmsRdbms
Rdbms
 
DATABASE CONCEPTS AND PRACTICAL EXAMPLES
DATABASE CONCEPTS AND PRACTICAL EXAMPLESDATABASE CONCEPTS AND PRACTICAL EXAMPLES
DATABASE CONCEPTS AND PRACTICAL EXAMPLES
 
A short introduction to database systems.ppt
A short introduction to  database systems.pptA short introduction to  database systems.ppt
A short introduction to database systems.ppt
 
Relational model
Relational modelRelational model
Relational model
 
Normalization
NormalizationNormalization
Normalization
 
Data Dictionary
Data DictionaryData Dictionary
Data Dictionary
 
Chapter 7 relation database language
Chapter 7 relation database languageChapter 7 relation database language
Chapter 7 relation database language
 
COMPUTERS Database
COMPUTERS Database COMPUTERS Database
COMPUTERS Database
 
08. Object Oriented Database in DBMS
08. Object Oriented Database in DBMS08. Object Oriented Database in DBMS
08. Object Oriented Database in DBMS
 
The three level of data modeling
The three level of data modelingThe three level of data modeling
The three level of data modeling
 
Data Models & Introduction to UML
Data Models & Introduction to UML Data Models & Introduction to UML
Data Models & Introduction to UML
 

Similar to Keerty rdbms sql

Database Concepts.pptx
Database Concepts.pptxDatabase Concepts.pptx
Database Concepts.pptxDhruvSavaliya9
 
MIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome MeasuresMIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome MeasuresSteven Johnson
 
Physical elements of data
Physical elements of dataPhysical elements of data
Physical elements of dataDimara Hakim
 
Dbms relational model
Dbms relational modelDbms relational model
Dbms relational modelChirag vasava
 
DEE 431 Database keys and Normalisation Slide 2
DEE 431 Database keys and Normalisation Slide 2DEE 431 Database keys and Normalisation Slide 2
DEE 431 Database keys and Normalisation Slide 2YOGESH SINGH
 
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 interview question part 12
Sql interview question part 12Sql interview question part 12
Sql interview question part 12kaashiv1
 
Sql interview question part 12
Sql interview question part 12Sql interview question part 12
Sql interview question part 12kaashiv1
 
Understanding about relational database m-square systems inc
Understanding about relational database m-square systems incUnderstanding about relational database m-square systems inc
Understanding about relational database m-square systems incMuthu Natarajan
 

Similar to Keerty rdbms sql (20)

DATABASE-1.pptx
DATABASE-1.pptxDATABASE-1.pptx
DATABASE-1.pptx
 
Database Concepts.pptx
Database Concepts.pptxDatabase Concepts.pptx
Database Concepts.pptx
 
MIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome MeasuresMIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome Measures
 
T-SQL Overview
T-SQL OverviewT-SQL Overview
T-SQL Overview
 
Physical elements of data
Physical elements of dataPhysical elements of data
Physical elements of data
 
Dbms relational model
Dbms relational modelDbms relational model
Dbms relational model
 
unit 1.pptx
unit 1.pptxunit 1.pptx
unit 1.pptx
 
PPT_DBMS.pptx
PPT_DBMS.pptxPPT_DBMS.pptx
PPT_DBMS.pptx
 
DBMS-Unit-2.pptx
DBMS-Unit-2.pptxDBMS-Unit-2.pptx
DBMS-Unit-2.pptx
 
Codds rules & keys
Codds rules & keysCodds rules & keys
Codds rules & keys
 
Unit 2 DBMS.pptx
Unit 2 DBMS.pptxUnit 2 DBMS.pptx
Unit 2 DBMS.pptx
 
Fg d
Fg dFg d
Fg d
 
DEE 431 Database keys and Normalisation Slide 2
DEE 431 Database keys and Normalisation Slide 2DEE 431 Database keys and Normalisation Slide 2
DEE 431 Database keys and Normalisation Slide 2
 
SQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics CoveredSQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics Covered
 
Sql interview question part 12
Sql interview question part 12Sql interview question part 12
Sql interview question part 12
 
Ebook12
Ebook12Ebook12
Ebook12
 
Sql interview question part 12
Sql interview question part 12Sql interview question part 12
Sql interview question part 12
 
NMEC RD_UNIT 1.ppt
NMEC RD_UNIT 1.pptNMEC RD_UNIT 1.ppt
NMEC RD_UNIT 1.ppt
 
rdbms8.pdf
rdbms8.pdfrdbms8.pdf
rdbms8.pdf
 
Understanding about relational database m-square systems inc
Understanding about relational database m-square systems incUnderstanding about relational database m-square systems inc
Understanding about relational database m-square systems inc
 

More from Keerty Smile

Insight into progam execution ppt
Insight into progam execution pptInsight into progam execution ppt
Insight into progam execution pptKeerty Smile
 
Data file handling in python binary & csv files
Data file handling in python binary & csv filesData file handling in python binary & csv files
Data file handling in python binary & csv filesKeerty Smile
 
Data file handling in python reading & writing methods
Data file handling in python reading & writing methodsData file handling in python reading & writing methods
Data file handling in python reading & writing methodsKeerty Smile
 
Data file handling in python introduction,opening & closing files
Data file handling in python introduction,opening & closing filesData file handling in python introduction,opening & closing files
Data file handling in python introduction,opening & closing filesKeerty Smile
 

More from Keerty Smile (7)

Insight into progam execution ppt
Insight into progam execution pptInsight into progam execution ppt
Insight into progam execution ppt
 
Data file handling in python binary & csv files
Data file handling in python binary & csv filesData file handling in python binary & csv files
Data file handling in python binary & csv files
 
Data file handling in python reading & writing methods
Data file handling in python reading & writing methodsData file handling in python reading & writing methods
Data file handling in python reading & writing methods
 
Data file handling in python introduction,opening & closing files
Data file handling in python introduction,opening & closing filesData file handling in python introduction,opening & closing files
Data file handling in python introduction,opening & closing files
 
Computer networks
Computer networksComputer networks
Computer networks
 
Recursion part 2
Recursion part 2Recursion part 2
Recursion part 2
 
Recursion part 1
Recursion part 1Recursion part 1
Recursion part 1
 

Recently uploaded

Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
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)

TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
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
 

Keerty rdbms sql

  • 2. KIRTIGUPTA,PGTCS,KVNTPCDADRI DATABASE  May be defined as a collection of interrelated data stored together to serve multiple application  It is computer based record keeping system.  It not only allows to store but also allows us modification of data as per requirements. Database: Database is a collection of inter-related data which helps in efficient retrieval, insertion and deletion of data from database and organizes the data in the form of tables, views, schemas, reports etc. For Example, university database organizes the data about students, faculty, and admin staff etc. which helps in efficient retrieval, insertion and deletion of data from it.
  • 3. KIRTIGUPTA,PGTCS,KVNTPCDADRI DATABASE CONCEPTS  WHY DO WE NEED DATABASE  To manage large chunks of data: if size of data increases into thousands of records, it will simply create a problem to manage.Database can manage large amount of data.  Accuracy: Through validation rule in database ,data accuracy can  be maintained.  Ease of updating data: With the database, we can flexibly update the data according to our convenience. Moreover, multiple people can also edit data at same time.  Security of data: With databases we have security groups and  privileges to restrict access.  Data integrity: In databases, we can be assured of accuracy and consistency of data due to the built in integrity checks and access
  • 4. KIRTIGUPTA,PGTCS,KVNTPCDADRI DBMS  A DBMS refers to Database Management System  It is a software that is responsible for storing, manipulating, maintaining and utilizing database.  A database along with the a DBMS is referred to as a database system.  There are various DBMS software available in the market like :- Oracle, MS SQL Server, MySQL, Sybase, PostgreSQL, SQLite, MS Access, Paradox, DB2 and etc. MySQL is open source and freeware DBMS.
  • 6. KIRTIGUPTA,PGTCS,KVNTPCDADRI Data Model Way of data representation Data model is a model or presentation which shows How data is organized or stored in the database. The data is modeled by one of the following given models-  Relational Data Model In this model data is organized into Relations or Tables (i.e. Rows and Columns). A row in a table represents a relationship of data to each other and also called a Tuple or Record. A column is called Attribute or Field.  Network Data Model In this model, data is represented by collection of records and relationship among data is shown by Links.  Hierarchical Data Model In this model, Records are organized as Trees. Records at top level is called Root record and this may contains multiple directly linked children records.  Object Oriented Data Model  In this model, records are represented as a objects. The collection of similar types of object is called class.
  • 8. KIRTIGUPTA,PGTCS,KVNTPCDADRI RELATIONAL DATABASE MODEL  In relational database model data is organized into table (i.e. rows and columns).  These tables are also known as relations.  A row in a table represent relationship among a set of values.  A column represent the field/attributes related to relation under which information will be stored.  For example if we want to store details of students then : Roll, Name, Class, Section, etc. will be the column/attributes and the collection of all the column information will become a Row/Record
  • 9. KIRTIGUPTA,PGTCS,KVNTPCDADRI RELATIONAL DATABASE MODEL  A Relational database use Structured Query Language (SQL), which is a standard user application that provides an easy programming interface for database interaction.
  • 10. KIRTIGUPTA,PGTCS,KVNTPCDADRI SAMPLE TABLES DEPARTMENT EMPLOYEE EMPNO ENAME GENDER DEPTNO SALARY COMM 1 ANKITA F 10 20000 1200 2 SUJEET M 20 24000 3 VIJAYA F 10 28000 2000 4 NITIN M 30 18000 3000 5 VIKRAM M 30 22000 1700 DEPTNO DNAME LOCATION 10 HR NEW YORK 20 ACCOUNTS BRAZIL 30 SALES CANADA 40 IT INDIA
  • 11. KIRTIGUPTA,PGTCS,KVNTPCDADRI COMPONENT OF A TABLE  Byte : group of 8 bits and is used to store a character.  Data Item : smallest unit of named data. It represent one type of information and often referred to as a field or column information  Record : collection of data items which represent a complete unit of information : collection of all Rows and Columns. Table
  • 12. KIRTIGUPTA,PGTCS,KVNTPCDADRI Fields Data Items (requires 5 bytes) Records Table DEPTNO DNAME LOCATION 10 HR NEW YORK 20 ACCOUNTS BRAZIL 30 SALES CANADA 40 IT INDIA
  • 13. KIRTIGUPTA,PGTCS,KVNTPCDADRI COMMON RDBMS  Oracle, MS SQL Server, MySQL, IBM DB2, IBM Informix, Enterprise, SAP Sybase, SAP Sybas e Adaptive Server IQ, Teradata, PostgreSQL, SQLite, etc.  Out of these MySQL, PostgreSQL and SQLite are Open source implementation.
  • 14. KIRTIGUPTA,PGTCS,KVNTPCDADRI COMMON RDBMS  MySQL  Runs on virtually all platforms including Linux, Unix and Windows. Popular for web based application and online publishing. It is a part of LAMP (Linux, Apache, MySQL, PHP) stack  SQLite  Relational DBMS but it is not client-server database engine rather, it is embedded into end program. Arguably the most widely deployed database engine as it is used by several browsers, OS and embedded systems(Mobiles).  PostgreSQL  General purpose object-relational DBMS. It is the most advanced open source database system. It is free and open source i.e. source code is available under PostgreSQL license, a liberal open source license.
  • 15. KIRTIGUPTA,PGTCS,KVNTPCDADRI COMMON DBMS TOOLS FOR MOBILE DEVICES  SQL Anywhere, DB2 Everywhere, IBM Mobile Database, SQL Server Compact, SQL Server Express, Oracle DatabaseLite, SQLite, SQLBase etc.  Out of these SQLite is public domain open source implementation
  • 18. KIRTIGUPTA,PGTCS,KVNTPCDADRI JUST A MINUTE… Identify the following in the above table 1) Degree of Table 2) Cardinality of Table 3) Attributes of Table 4) Tuple 5) Data types of Book Code and Price (as studied in Python) BOOKCODE BOOKNAME PUB PRICE B001 LET US C BPB 400 B002 VISUAL BASIC EEE 350 B003 JAVA PHI 550 B004 VC++ BPB 750
  • 19. KIRTIGUPTA,PGTCS,KVNTPCDADRI CONCEPT OF KEYS In relation each record must be unique i.e. no two identical records are allowed in the Database. A key attribute identifies the record and must have unique values. There are various types of Keys: Primary Key, Candidate Key, Alternate Key and Foreign Key. EMPNO ENAME GENDER DEPTNO SALARY COMM 1 ANKITA F 10 20000 1200 2 SUJEET M 20 24000 3 VIJAYA F 10 28000 2000 4 NITIN M 30 18000 3000 5 VIKRAM M 30 22000 1700
  • 20. KIRTIGUPTA,PGTCS,KVNTPCDADRI KEYS  Primary Key  A set of one or more attribute that can identify a record uniquely in the relation is called Primary Key.  There can be only 1 primary key in a table  Allows only distinct (no duplicate) values and also forces mandatory entry (NOT NULL) i.e. we cannot left it blank.  Candidate Key  In a table there can be more than one attribute which contains unique values. These columns are known as candidate key as they are the candidate for primary key.  Among these database analyst select one as a primary key based on requirement like must contain unique value, compulsory entry and where maximum searching is done etc.
  • 21. KIRTIGUPTA,PGTCS,KVNTPCDADRI KEYS  Alternate Key  In case of multiple candidate keys, one of them will be selected as Primary Key and rest of the column will serve as Alternate Key  A Candidate Key which is not a primary key is an Alternate Key.  Foreign key  Used to create relationship between two tables.  It is a non-key attribute whose value is derived from the Primary key of another table.  Foreign key column will for the value in Primary key of another table, if present then entry will be allowed otherwise data will be rejected.  Primary Key column table from where values will be derived is known as Primary Table or Master Table or Parent Table and Foreign key column table will be Foreign Table or Detail Table or Child table
  • 23. KIRTIGUPTA,PGTCS,KVNTPCDADRI DEPARTMENT Parent Table EMPLOYEE From the Above table definition we can observe that the DEPTNO column of EMPLOYEE table is deriving its value from DEPTNO of table DEPARTMENT. So we can say that the DEPTNO of EMPLOYEE table is a foreign key whose value is dependent upon the Primary key column DEPTNO of table DEPARTMENT. Child Table EMPNO ENAME GENDER DEPTNO SALARY COMM 1 ANKITA F 10 20000 1200 2 SUJEET M 20 24000 3 VIJAYA F 10 28000 2000 4 NITIN M 30 18000 3000 5 VIKRAM M 30 22000 1700 DEPTNO DNAME LOCATION 10 HR NEW YORK 20 ACCOUNTS BRAZIL 30 SALES CANADA 40 IT INDIA Parent Table
  • 24. KIRTIGUPTA,PGTCS,KVNTPCDADRI REFERENTIAL INTEGRITY  Used to ensure relationship between records in related tables are valid and user don’t accidentally delete or change the related data.  Referential integrity can be applied when:  The master table’s column is a Primary Key or has a unique index  The related fields have the same data type  Both tables must belong to same database.
  • 25. KIRTIGUPTA,PGTCS,KVNTPCDADRI REFERENTIAL INTEGRITY  When referential integrity is enforced using Foreign Key you must observe the following rules: You cannot enter a value in Child Table which is not available in Master Table’s Primary key column. However you can enter NULL values in foreign key You cannot delete a record from Master Table if matching record exists in related table You cannot modify or change the Primary Key value in Master table if its matching record is present in related table.
  • 26. KIRTIGUPTA,PGTCS,KVNTPCDADRI BRIEF HISTORY OF MYSQL  MySQL is freely available open source RDBMS  Can be downloaded from www.mysql.org  In MySQL information is stored in Tables.  Provides features that support secure environment for storing, maintaining and accessing data.  It is fast, reliable, scalable alternative to many of the commercial RDBMS today.  Create and supported by MySQL AB, a company based in Sweden. This company is now subsidiary of Sun Microsystems. On April 2009 Oracle Corp. acquires Sun Microsystems.  The chief inventor of MySQL was Michael Widenius(a.k.a Monty). MySQL has been named after Monty’s daughter My. The logo of MySQL is dolphin and name of that dolphin is ‘Sakila’
  • 27. KIRTIGUPTA,PGTCS,KVNTPCDADRI MYSQL DATABASE SYSTEM  MySQL database system refers to the andcombination of a MySQL server instance MySQL database. It operates using Client/Server architecture in which the server runs on the machine containing the database and client connects to server over a network MySQL is a multiuser database system, meaning several users can access the database simultaneously
  • 28. KIRTIGUPTA,PGTCS,KVNTPCDADRI MYSQL DATABASE SYSTEM  The Server requirements and provide the requested information to the Client  The Client  Are the programs that connect to MySQL server and sends requests to the server and receives the response of Server. Client may be the MySQL prompt or it may be Front-end programming which connect to server programmatically like connecting to MySQL using Python Language or Java or any other language  Listens for client requests coming in over the network and access the database as per the
  • 29. KIRTIGUPTA,PGTCS,KVNTPCDADRI FEATURES OF MYSQL  Speed  MySQL runs very fast.  Ease of Use  Can be managed from command line or GUI  Cost  Is available free of cost. It is Open Source  Query language Support  Supports SQL  Portability  Can be run on any platform and supported by various compilers  Data Types  Supports various data types like Numbers, Char etc.
  • 30. KIRTIGUPTA,PGTCS,KVNTPCDADRI FEATURES OF MYSQL  Security  Offers privileges and password systems that is very flexible and secure.  Scalability and Limits  Can handle large databases. Some of real life MySQL databases contains millions of records.  Connectivity  Clients can connect to MySQL using drivers  Localization  The server can provide error message to client in many language  Client and Tools  Provides several client and utility programs. Like mysqldump and mysqladmin. GUI tools like MySQL Administration and Query Browser
  • 31. KIRTIGUPTA,PGTCS,KVNTPCDADRI STARTING MYSQL Click on Start  All Programs  MySQL  MySQL Server  MySQL Command Line Client Enter the password given during installation
  • 32. KIRTIGUPTA,PGTCS,KVNTPCDADRI mysql> prompt means now MySQL is ready to take your command and execute To exit from MySQL type exit or quit in front of mysql prompt
  • 33. KIRTIGUPTA,PGTCS,KVNTPCDADRI SQL AND MYSQL  SQL stands for Structured Query Language.  Is a language that enables you to create and operate on relational databases.  MySQL uses SQL in order to access databases.  It is the standard language used by almost all the database s/w vendors.  Pronounced as SEQUEL  Original versionwas developed by IBM’s Almanden Research Center  Latest ISO standard of SQL was released in 2008 and named as SQL:2008
  • 34. KIRTIGUPTA,PGTCS,KVNTPCDADRI PROCESSING CAPABILITIES OF SQL  DDL (Data Definition Language)  DML (Data Manipulation Language)  Embedded DML  View  Authorization  Integrity  Transaction Control
  • 35. KIRTIGUPTA,PGTCS,KVNTPCDADRI DATA DEFINITION LANGUAGE  It allows to create database objects like creating a table, view or any other database objects.  The information about created objects are stored in special file called DATA DICTIONARY  DATA DICTIONARY contains metadata i.e. data about data.  While creating a table DDL allows to specify– name of table, attributes, data types of attribute, may define range of values each that attributes can store, etc  Major commands of DDL ALTER, DROP are – CREATE,
  • 36. KIRTIGUPTA,PGTCS,KVNTPCDADRI DATA MANIPULATION LANGUAGE  It allows to perform following operation on table  Retrieval of information stored in table  Insertion of new data in table  Modification of existing data in table  Deletion of existing data from table  DML is of 2 type  Procedural DML (in this we specify what data is needed and how to get it)  Non-Procedural DML (in this we specify what data is needed without specifying how to get it)  Main DML commands are – SELECT, INSERT, UPDATE AND DELETE
  • 37. KIRTIGUPTA,PGTCS,KVNTPCDADRI JUST A MINUTE…  What is Database? What are the advantages of Database System?  What is DDL and DML? Give examples of command belonging to each category  What is the difference between Primary key and Candidate key  What is Primary Key? What are the restriction imposed by Primary Key? How many primary key can be applied on a Table?  What is Degree and Cardinality of table?