DBMS
DBMS
BHOPAL
DBMS MCA-201
Unit-1
By
Prof. Amit Rajpurohit
Basic of DBMS ⮚ Why we need Information:
Definition:
A database is a collection of interrelated data. By data, we mean known facts that can be recorded and
that have implicit meaning.
• Data can be store in form of table.
• Database can be of any size & varying complexity .
• A database may be generated & manipulated manually or computerized.
Example:
Ename Salary Age
Database Management System Application of DBMS
Definition: • Banking
• Finance
A database management system is a collection of programs that enables • HR Management
users to create and maintain a database. The database management system • Manufacturing
or dbms is a general-purpose software system that facilitates the processes • Universities
of defining, constructing, manipulating, and sharing databases among • Airlines
various users and applications. • Railway System
DBMS Software
• MySQL
User DBMS • Microsoft Access
Database • Oracle
• PostgreSQL
• FoxPro
• SQLite
• IBM DB2
Operation Perform on Database: Types of file systems
• Insertion ❑ File allocation table (FAT)
• Updation is supported by the Microsoft Windows OS. FAT is
• Deletion considered simple and reliable, and it is modeled after legacy file
• Retrieve systems. FAT was designed in 1977 for floppy disks, but was
• Sorting later adapted for hard disks.
• Min ❑ Global file system (GFS):
• Max is a file system for the Linux OS, and it is a shared disk file
etc... system. GFS offers direct access to shared block storage and can
be used as a local file system.
File System
❑ Hierarchical file system (HFS)
• Before DBMS invented, information was stored in file was developed for use with Mac operating systems. HFS can
processing system. also be referred to as Mac OS Standard, and it was succeeded by
• A file processing system is a collection of files and programs Mac OS Extended. Originally introduced in 1985 for floppy and
that access/modify these files hard disks, HFS replaced the original Macintosh file system.
• Typically, new files and programs are added over time (by ❑ New Technology File System (NTFS):
different programmers) as new information needs to be stored is the default file system for Windows products from Windows
and new ways to access information are needed. Problems with NT 3.1 OS onward. Improvements from the previous FAT file
file processing systems: system include better metadata support, performance and use of
disk space.
Limitation/ Disadvantage of file ⮚ Domain Constrains ⮚Referential Integrity Constrains
processing system Eid Name Age Phone
ID Name Sem Age
101 ravi 5 17 101 ravi 35 982610123
❑ Data Redundancy 4
❑ Difficulty in accessing data 102 raj 5 abc 102 raj 38 999336667
❑ Data isolation 5
❑ Atomicity problem 103 ajay 25 799995678
❑ Concurrent access anomalies 9
❑Integrity Constrains ⮚Entity Integrity Constrains
❑Security Problems Primary Key Value should not be null Table -1
Integrity Constrains:
Phone Location
It is a set of rules and it is used for maintain quality
9826101234 Bhopal
information.
9993366675 Mumbai
7999956789 Pune
⮚Key Constrains
Table -2
primary key must be unique
and two same PK value not Table No. 1 for Phone No. is Foreign key
allow in record Table No. 2 . For Phone No is Primary key
Advantage of DBMS over File System
❑ Redundancy can be reduced by normalization
❑ Inconsistency can be avoided
❑ Data can be shared
❑ Security restrictions can be applied
❑ Integrity constrains are also available and can be applied
❑ Requirements can be balanced
❑ Atomicity is also in DBMS transaction
❑ Locking mechanism also there to prevent concurrent access
❑ Standards can be enforced
User:
Components of DBMS
Types of user who play different roles in DBMS
Data:
A data can be defined as a collection of Application Programmers
raw facts and figures.
The users who write the application programs in
The term database is referred as a
programming languages (such as
collection of the related data.
Java, Python ,C++,etc )to interact with
The data is a key component and for the
databases are called Application Programmer.
management of it the DBMS works.
Software:
Database Administrators (DBA)
Software is the actual DBMS b/w the
physical DB and the user of the system all Person who manages the overall DBMS is
request from the user for accessing the DB called a database administrator or
are handled by DBMS software simply DBA
Hardware: End-Users
Procedures:
The hardware is the actual computer system
The end-users are those who interact with
used for keeping and accessing the database
the database management system to perform Procedures are instructions and rules that assist
conventional DBMS Hardware consist of
different operations by using the different on how to use the DBMS, in its design and
secondary storage devices
database commands such running the database. They serve as a guide to
as insert, update, retrieve, and delete on the the users that operate and manage it.
data, etc.
DBMS - Architecture
• Semantic content can be put in it. • It requires a powerful system due to which the transaction is very
• It supports inheritance which increases data slow.
integrity. • It is a very complex model.
• It improves performance. • To use it, one has to learn it first.
• There is very little security in it.
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
DBMS Schema
Definition: Design of a database is called the
schema.
DBA: person in the organization who controls the design and the
5. Approving Data Access:
use of the database refers as DBA.
The DBA determines which user needs access to which
1. Schema Definition: part of the database.
The DBA definition the logical Schema of the database. A Schema According to this, various types of authorizations are
refers to the overall logical structure of the database. granted to different users.
According to this schema, database will be developed to store 6. Monitoring Performance:
required data for an organization. The DBA monitors performance of the system. The DBA
2. Storage Structure and Access Method Definition: ensures that better performance is maintained by making
The DBA decides how the data is to be represented in the stored changes in physical or logical schema if required.
database. 7. Backup and Recovery:
3. Assisting Application Programmers: Database should not be lost or damaged.
The DBA provides assistance to application programmers to develop The DBA ensures this periodically backing up the
application programs. database on magnetic tapes or remote servers.
4. Physical Organization Modification: In case of failure, such as virus attack database is
The DBA modifies the physical organization of the database to recovered from this backup.
reflext the changing needs of the organization or to improve
performance.
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
Codd's Rule :
Every database has tables, and
constraints cannot be referred to as a
rational database system. And if any
database has only relational data model,
it cannot be a Relational Database
System (RDBMS) . So, some rules define
a database to be the correct RDBMS.
Conceptually ER Model is very easy to build. If we know the No industry standard for notation:
relationship between the attributes and the entities we can easily build There is no industry standard for developing an ER
the ER Diagram for the model.
model. So one developer might use notations which
Effective Communication Tool: are not understood by other developers.
This model is used widely by the database designers for
communicating their ideas. Hidden information: Some information might be lost
or hidden in the ER model. As it is a high-level view
Easy Conversion to any Model: so there are chances that some details of information
This model maps well to the relational model and can be easily might be hidden.
converted relational model by converting the ER model to the table.
This model can also be converted to any other model like network
model, hierarchical model etc.
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
Component of ER Diagram
Entity Set
1. Entity:
An Entity is an object of Entity Type
An entity may be any object, class, person or and set of all entities is called as
place. In the ER diagram, an entity can be entity set.
represented as rectangles.
Weak Entity
An entity that depends on another entity called
a weak entity. The weak entity doesn't contain
any key attribute of its own. The weak entity is
represented by a double rectangle.
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
2. Attribute Types of Attribute Composite Attribute
The attribute is used to describe the
Key Attribute An attribute composed of many other
property of an entity. Eclipse is used to
represent an attribute. The attribute which uniquely identifies attribute is called as composite attribute.
each entity in the entity set is called key For example, Address attribute of student
attribute. Entity type consists of Street, City, State,
For example, Roll_No will be unique for and Country. In ER diagram, composite
each student. In ER diagram, key attribute is represented by an oval
attribute is represented by an oval with comprising of ovals.
underlying lines.
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
Multivalued Attribute
Derived Attribute
An attribute which can be derived from other
attributes of the entity type is known as derived
attribute. e.g.; Age (can be derived from DOB). In
ER diagram, derived attribute is represented by
dashed oval.
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
One-to-One Relationship
Relationship When only one instance of an entity is associated with the relationship,
A relationship is used to describe the relation then it is known as one to one relationship.
between entities. Diamond or rhombus is used example, A female can marry to one male, and a male can marry
to represent the relationship. to one female.
One-to-many relationship
Types of Relationship When only one instance of the entity on the left, and more than one instance
of an entity on the right associates with the relationship then this is known as
One-to-One Relationship a one-to-many relationship.
One-to-many Relationship
example, Scientist can invent many inventions, but the invention
Many-to-one Relationship
is done by the only specific scientist.
Many-to-many Relationship
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
Many-to-one relationship
Many-to-many relationship
When more than one instance of the entity on the left, and
When more than one instance of the entity on the left, and
only one instance of an entity on the right associates with
more than one instance of an entity on the right associates
the relationship then it is known as a many-to-one
with the relationship then it is known as a many-to-many
relationship.
relationship.
Example, Employee can assign by many projects and project
example, Student enrolls for only one course, but a can have many employees.
course can have many students.
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
Participation:
How many entities are going to be participated in
relationship
Total Participation
if all the entities of an entity set participation in
relationship set then the participate is called total
participation
Total Participation − Each entity is involved in
the relationship. Total participation is represented
by double lines.
(One to many relation Total)
Partial Participation:
Recursive Relationship
Aggregation
Specialization & Generalization
Aggregation
Specialization
One entity is specialized into some
other entities by adding some special
attributes.
It is Top-Down Approach.
Shows conversion of higher level
entities into lower level entity by
adding some additional attributes.
Lower level will inherit by higher
level attributes.
Generalization
Reverse of Specialization
Bottom up approach
Combining similar attributes to one
general class
G/S
03/28/24
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
Online RR System
03/28/24
HM System
03/28/24
Table to ER
03/28/24
Table
Column/Attribute
Row/Record
Domain
03/28/24
SQL DATATYPE
Create Table
UNIQUE,
INSERT QUERY
03/28/24
SQL PROGRAMMING
• Data Definition Language (DDL)
• Data Definition Language (DDL) is a set of special commands that allows us to define and modify the structure and the
metadata of the database. These commands can be used to create, modify, and delete the database structures such
as schema, tables, indexes, etc.
• Since DDL commands can alter the structure of the whole database and every change implemented by a DDL command is
auto-committed (the change is saved permanently in the database), these commands are normally not used by an end-user
(someone who is accessing the database via an application).
03/28/24
SQL PROGRAMMING
• DROP
• It is used to delete the database or its schema objects.
• DROP TABLE table name;
• To delete the whole database :
• DROP DATABASE database name;
• ALTER :
• It is used to modify the structure of the database objects.
Syntax -
• To add new column(s) in a table :
• ALTER TABLE table name ADD ( column_1 DATATYPE, column_2 DATATYPE, column DATATYPE );
• To change the data type of a column in a table :
• ALTER TABLE table name MODIFY column name DATATYPE;
03/28/24
SQL PROGRAMMING
03/28/24
SQL PROGRAMING
• Data Manipulation Language (DML)
• Data Manipulation Language (DML) is a set of special commands that allows us to
access and manipulate data stored in existing schema objects. These commands are
used to perform certain operations such as insertion, deletion, updation, and retrieval
of the data from the database.
• These commands deal with the user requests as they are responsible for all types of
data modification. The DML commands that deal with the retrieval of the data are
known as Data Query language.
SELECT :
• It is used to retrieve or fetch data from a database. The SELECT statement cannot
manipulate data, it can only access it. Hence, it is known as the Data Query Language,
i.e., a limited form of DML statement.
• MySQL Syntax -
•To fetch an entire table :
SELECT * FROM table name;
•To fetch particular columns from a table :
SELECT column_1, column_2 FROM table_name;
•To fetch particular columns from a table based on a condition:
SELECT column_1, column_2 FROM table_name WHERE <condition>;
03/28/24
SQL PROGRAMMING
• INSERT :
It is used to insert new rows into the table.
• MySQL Syntax -
• To insert values according to the table structure :
• INSERT INTO table_name VALUES value1, value2, value3;
• To insert values based on the columns :
• INSERT INTO table_name column1, column2, column3 VALUES value1, value2, value3;
• UPDATE :
• It is used to update existing column(s)/value(s) within a table.
• MySQL Syntax -
• To update the columns of a table based on a condition (General UPDATE statement) :
• UPDATE table name SET column_1 = value1, column_2 = value2, column_3 = value3,
[WHERE condition]
03/28/24
MY SQL PROGRAMMING
• 1) Show databases; ///showing the databases
• 2) Create database demo;
• 3) Use demo; // database changed
• use demo; //table use
• select * from (previous database);
• 4) Create table student (name varchar (30), id int not null primary key, address varchar
(50), marks int);
• 5) Desc student; /// describe table name
• 6) insert into student(name,id,address,marks)values(‘ranber’,101,Mumbai,50); //secure
way
• 7) Insert into student values (‘ranbera’, 102, Mumbayi, 52)//unsecure way
• 8) Insert into student values (‘ranber1’, 201, Mumbaina, 100), (‘aliya’, 301, bhaitunda,
200)); //multivalue insert
• Query ok, 2 rows affected
03/28/24
MY SQL PROGRAMMING
03/28/24
MY SQL PROGRAMMING
• 15) Alter table student modify column name varchar(30); //ADD the new size/dty
• 16) Alter table student drop column phone no;//remove column name
• Desc student; //to show again the remaining column
• 17) delete from student where name =”ranbeer”;
• 18)rollback; //last value rollback whether insert or delete// use start transaction;
• 19)commit;
• Function
• Select sum (marks) from student;
• Select average (marks) from student;
• Select count (name) from student;
• Select max (marks) from student;
• Select min (marks) from student;
• Select * from student order by name; //ascending order
• Select *from student order by name desc; //descending order
03/28/24
MY SQL PROGRAMMING
• //wild card//
• Select * from student where name like’r%’; start with r
• Select * from student where name like’%r’; end with r
• Select * from student where name like’’_r%’; //second character
• Select * from student where name like’’%r_’; //last second character
03/28/24
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
Thank You