0% found this document useful (0 votes)
10 views

DBMS

This document provides an overview of Database Management Systems (DBMS), including definitions of data, records, tables, and databases, as well as the functionality and advantages of DBMS over traditional file systems. It discusses the history of DBMS, popular software, applications, and the roles of various users involved in database management. Additionally, it outlines the characteristics, advantages, and disadvantages of DBMS, emphasizing its importance in reducing redundancy, ensuring data integrity, and supporting concurrent access.

Uploaded by

Ajay Kumar R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

DBMS

This document provides an overview of Database Management Systems (DBMS), including definitions of data, records, tables, and databases, as well as the functionality and advantages of DBMS over traditional file systems. It discusses the history of DBMS, popular software, applications, and the roles of various users involved in database management. Additionally, it outlines the characteristics, advantages, and disadvantages of DBMS, emphasizing its importance in reducing redundancy, ensuring data integrity, and supporting concurrent access.

Uploaded by

Ajay Kumar R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

Chapter-1 Database Management System (DBMS)

DATABASE ARCHITECTURE

Introduction to Database Management System:


Data:
 Data is nothing but facts and statistics stored, generally it's raw and unprocessed.
 Data becomes information when it is processed, turning it into something meaningful.
 Raw data ("unprocessed data") is a collection of numbers or characters before it has been
"cleaned" and corrected by researchers.
 Example – Name, Age, Height, Sem, Course

Record:

A record in a Database Management System (DBMS) is a collection of related data fields that
represent a single entity or instance within a table.

Example: In a student table, a record might include fields like Name, Age, Height, Sem, Course. Each
row in the table is a record, such as: John, 18, 4.5, 2nd sem, BCA as shown below.

Name Age Height Sem Course


John 18 4.5 2nd sem BCA

Table:

A table in a database is a collection of data organized into rows and columns. Each row represents a
single record, and each column represents a specific attribute of the data.

Example: Consider a table named Employees:

EmployeeID FirstName LastName Position Salary


1 John Doe Manager 60000
2 Jane Smith Engineer 80000
3 Alice Johnson Technician 40000

In this example:

 Each row is a record of an employee.


 Each column (e.g., EmployeeID, FirstName, LastName, Position, Salary) represents an
attribute of the employee

Database:
 A database is a collection of related data which represents some aspect of the real world.
 A Database is a systematic collection of data.

pg. 1
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

Database Management System (DBMS):


 A DBMs is software that allows creation, definition and manipulation of database, allowing
users to store, process and analyze data easily.
 DBMS provides us with an interface or a tool, to perform various operations like creating
database, storing data in it, updating data, creating tables in the database and many more.
 BDMS also provides protection and security to the databases.
 It also maintains data consistency and security to the databases.
Popular DBMS Software:
Here, is the list of some popular DBMS system:
 MySQL
 Microsoft Access
 Oracle
 PostgreSQL
 dBASE
 FoxPro
 SQLite
 IBM DB2
 LibreOffice Base
 MariaDB
 Microsoft SQL Server etc.

Note:
 Charles Bachman, was an American Computer Scientist, He was particularly known for his
work in the early development of Database Management System (DBMS)
 Edgar. F Codd was a English Computer Scientist , while working for IBM, invented
the Relational Database Management System (RDBMS)

History of DBMS:
 1960 - Charles Bachman designed first DBMS system
 1970 - Codd introduced IBM'S (International Business Machines) Information Management
System
 1976 - Peter Chen coined and defined the Entity- relationship model
 1980 - Relational Model becomes a widely accepted database.
 1985 - Object-oriented DBMS develops.
 1990s - Incorporation of object-orientation in relational DBMS.

pg. 2
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

 1991- Microsoft ships - MS access, a personal DBMS


 1995: First Internet database applications
 1997: XML applied to database processing.
 2000s : NoSQL and NewSQL

Difference between File System and DBMS:

 File System Approach

File based systems were an early attempt to computerize the manual system. It is also called a
traditional based approach in which a decentralized approach was taken where each department stored
and controlled its own data with the help of a data processing specialist. The main role of a data
processing specialist was to create the necessary computer file structures, and also manage the data
within structures and design some application programs that create reports based on file data.

In the above figure:

Consider an example of a student's file system. The student file will contain information regarding the
student (i.e. roll no, student name, course etc.). Similarly, we have a subject file that contains
information about the subject and the result file which contains the information regarding the result.

Some fields are duplicated in more than one file, which leads to data redundancy. So to overcome this
problem, we need to create a centralized system, i.e. DBMS approach.

 DBMS:

A database approach is a well-organized collection of data that are related in a meaningful way which
can be accessed by different users but stored only once in a system. The various operations performed
by the DBMS system are: Insertion, deletion, selection, sort.

pg. 3
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

In the above figure, duplication of data is reduced due to centralization of data.

There are the following differences between DBMS and File systems:

Basics File System DBMS


Structure The file system is a way of arranging DBMS is software for managing the
the files in a storage medium within a database.
computer.
Data Redundant data can be present in a file In DBMS there is no redundant
Redundancy system. data.
Backup and It doesn’t provide Inbuilt mechanism It provides in house tools for
Recovery for backup and recovery of data if it is backup and recovery of data even if
lost. it is lost.
Query There is no efficient query processing Efficient query processing is there
processing in the file system. in DBMS.
Consistency There is less data consistency in the file There is more data consistency
system. because of the process of
normalization.
Complexity It is less complex as compared to It has more complexity in handling
DBMS. as compared to the file system.
Security File systems provide less security in DBMS has more security
Constraints comparison to DBMS. mechanisms as compared to file
systems.
Cost It is less expensive than DBMS. It has a comparatively higher cost
than a file system.
Data There is no data independence. In DBMS data independence exists,
Independence mainly of two types:
1) Logical Data Independence.
2) Physical Data Independence.
User Access Only one user can access data at a time. Multiple users can access data at a
time.
Meaning The users are not required to write The user has to write procedures for
procedures. managing databases

pg. 4
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

Sharing Data is distributed in many files. So, it Due to centralized nature data
is not easy to share data. sharing is easy
Data It give details of storage and It hides the internal details of
Abstraction representation of data Database
Integrity Integrity Constraints are difficult to Integrity constraints are easy to
Constraints implement implement
Attributes To access data in a file, user requires No such attributes are required.
attributes such as file name, file
location.
Example Cobol, C++ Oracle, SQL Server

Database Applications:

1. Railway Reservation System


In the rail route reservation framework, the information base is needed to store the record or
information of ticket appointments, status of train’s appearance, and flight. Additionally, if trains get
late, individuals become acquainted with it through the information base update.
2. Library Management System
There are many books in the library so; it is difficult to store the record of the relative multitude of
books in a register or duplicate. Along these lines, the data set administration framework (DBMS) is
utilized to keep up all the data identified with the name of the book, issue date, accessibility of the
book, and its writer.
3. Banking
Database the executive’s framework is utilized to store the exchange data of the client in the
information base.

pg. 5
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

4. Education Sector
Presently, assessments are led online by numerous schools and colleges. They deal with all assessment
information through the data set administration framework (DBMS). In spite of that understudy’s
enlistments subtleties, grades, courses, expense, participation, results, and so forth all the data is put
away in the information base.
5. Credit card exchanges
The database Management framework is utilized for buying on charge cards and age of month to month
proclamations.
6. Social Media Sites
We all utilization of online media sites to associate with companions and to impart our perspectives to
the world. Every day, many people group pursue these online media accounts like Interest, Facebook,
Twitter, and Google in addition to. By the utilization of the data set administration framework, all the
data of clients are put away in the information base and, we become ready to interface with others.
7. Broadcast communications
Without DBMS any media transmission organization can’t think. The Database the executive’s
framework is fundamental for these organizations to store the call subtleties and month to month
postpaid bills in the information base.
8. Accounting and Finance
The information base administration framework is utilized for putting away data about deals, holding
and acquisition of monetary instruments, for example, stocks and bonds in a data set.
9. E-Commerce Websites
These days, web-based shopping has become a major pattern. Nobody needs to visit the shop and burn
through their time. Everybody needs to shop through web based shopping sites, (for example, Amazon,
Flipkart, Snapdeal) from home. So all the items are sold and added uniquely with the assistance of the
information base administration framework (DBMS). Receipt charges, installments, buy data these are
finished with the assistance of DBMS.
10. Human Resource Management
Big firms or organizations have numerous specialists or representatives working under them. They
store data about worker’s compensation, assessment, and work with the assistance of an information
base administration framework (DBMS).

Purpose of database system:


1. Reduction of redundancy & inconsistency: Unlike file processing system in database approach
data can be stored at a single place or Centralized control of data by the Database administrator. It
avoids unnecessary duplication of data which saves space and does not permit inconsistency.
2. Shared data: A database allows the sharing of data under its control by any number of application
programs or users.

pg. 6
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

3. Data independence: Application programs should be as independent as possible from details of


data representation and storage. The DBMS can provide an abstract view of the data to protect
application code from such details.
4. Integrity can be improved: Data integrity refers to validity and consistency. Data integrity means
data should be accurate & consistent. This is done by providing some checks & constraints. These are
the consistency rules that the database is not permitted to violate. For Example, the age of an employee
can be between 18 to 58 years only. While entering the data for the age of an employee, the database
should check this.
5. Supports Concurrent access: A DBMS schedules concurrent accesses to the data in such a manner
that users can think of the data as being accessed by only one user at a time. Example: Two people
reading a balance and updating it at the same time and gives accurate result.
6. Improved Backup & Recovery: DBMS provides facilities for recovering the hardware & software
failures. A backup & recovery subsystem is responsible for this. In case a program fails, it restores the
database to a state in which it was before the execution of program.
7. Improved Security: DBMS can enforce access controls that govern what data is visible to different
classes of users. For Example, salary of the employees should not be visible anyone other than the
department dealing in this.

Characteristics of DBMS:

1. Provides Security and Removes Redundancy:

 A DBMS ensures data security by restricting unauthorized access and allowing permissions
and roles. It also eliminates data redundancy by storing data in a single database and allowing
multiple applications to share the data, thus preventing duplication.

2. Self-Describing Nature of a Database System:

 A DBMS includes a catalogue or dictionary that describes the structure of the database, such
as table definitions, schemas, constraints, and relationships. This metadata provides a
comprehensive overview of the database's organization and usage.

3. Insulation between Programs and Data Abstraction:

 DBMS abstracts the data structure from the application programs, allowing changes to the
database structure without affecting the applications. This insulation ensures that programs do
not need to be rewritten if the database schema changes.

4. Support of Multiple Views of the Data:

 A DBMS allows different users to have customized views of the same database according to
their needs. These views can hide certain data or display data in a specific format, enhancing
security and usability.

pg. 7
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

5. DBMS Allows Entities and Relations Among Them to Form Tables:

 In a DBMS, entities (real-world objects) and their relationships are modelled as tables. Each
table represents an entity, and relationships are established through foreign keys, enabling
complex queries and data integrity.

6. It Follows the ACID Concept (Atomicity, Consistency, Isolation, and Durability):

 DBMS ensures reliable transactions through ACID properties. Atomicity guarantees complete
transactions, Consistency ensures data integrity, Isolation prevents transaction interference,
and Durability ensures permanence of committed transactions.

7. DBMS Supports Multi-User Environment that Allows Users to Access and Manipulate Data
in Parallel:

 A DBMS enables concurrent data access and manipulation by multiple users without conflicts,
using locking mechanisms and transaction management to ensure data consistency and
isolation, supporting collaborative work environments.

Advantages of DBMS
1. Data Security: Provides controlled access to data, ensuring only authorized users can view or
modify data.
2. Data Integrity: Ensures accuracy and consistency of data through constraints and validation
rules.
3. Data Independence: Separates data structure from application programs, allowing changes
without affecting applications.
4. Data Redundancy Reduction: Minimizes duplicate data by storing data centrally.
5. Concurrent Access: Supports multiple users accessing data simultaneously without conflicts.
6. Backup and Recovery: Offers automated backup and recovery options to protect data from
loss.
7. Data Sharing: Facilitates data sharing among multiple users and applications.
8. Complex Query Support: Allows complex queries using SQL for advanced data retrieval and
manipulation.
9. Data Abstraction: Provides different views of data for different users, enhancing data
usability.
10. Transaction Management: Ensures reliable transactions with ACID properties.

Disadvantages of DBMS:

1. Cost: High initial setup and ongoing maintenance costs.


2. Complexity: Requires skilled personnel to manage and maintain the system.
3. Size: Consumes significant disk space and system resources.
4. Upgrades: Requires regular updates.
5. Hardware Requirements: Often needs high-end hardware to function efficiently.
6. Security Risks: Centralized data can be a target for security breaches if not properly protected.

pg. 8
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

People who deal with databases:


Many persons are involved in the design, use and maintenance of any database. These persons can be
classified into 2 types as below.
 Actors on the scene:
The people, whose jobs involve the day-to-day use of a database are called as 'Actors on the scene',
listed as below.
1. Database Administrators (DBA): In a database environment, the primary resource is the database
itself and the secondary resource is the DBMS and related software. Administering these resources is
the responsibility of the database administrator (DBA). The DBA is responsible for authorizing access
to the database, for coordinating and monitoring its use, and for acquiring software and hardware
resources as needed.
2. Database Designers: Database designers are responsible for identifying the data to be stored in the
database and for choosing appropriate structures to represent and store this data.
3. End Users: People who wish to store and use data in a database. End users are the people whose
jobs require access to the database for querying, updating and generating reports, listed as below.
a. Casual End users: These people occasionally access the database, but they may need different
information each time.
b. Naive or Parametric End Users: Their job function revolves around constantly querying and
updating the database using standard types of queries and updates.
c. Sophisticated End Users: These include Engineers, Scientists, Business analyst and others
familiarize to implement their applications to meet their complex requirements.
d. Standalone End users: These people maintain personal databases by using ready-made program
packages that provide easy to use menu based interfaces.
4. System Analyst: These people determine the requirements of end users and develop specifications
for transactions.
5. Application Programmers (Software Engineers): These people can test, debug, document and
maintain the specified transactions.
 Workers behind the scene:
a. Database Designers and Implementers: These people who design and implement the
DBMS modules and interfaces as a software package.
b. Tool Developers: Include persons who design and implement tools consisting the packages
for design, performance monitoring, and prototyping and test data generation.
c. Operators and maintenance personnel: These re the system administration personnel who
are responsible for the actual running and maintenance of the hardware and software
environment for the database system.

pg. 9
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

Data Model:
 Data models show that how the data is connected and stored in the system.
 It shows the relationship between data.
 A Model is basically a conceptualization between attributes and entities.
Types of Relational Models:
 Conceptual Data Model
 Representational Data Model
 Physical Data Model
It is basically classified into 3 types:-

1. Conceptual Data Model


A conceptual data model, like the Entity-Relationship (ER) model, acts as a blueprint for databases. It
simplifies complex data structures into clear entities (like customers or products), their relationships
(such as purchases), and attributes (like names or prices). This visual representation helps non-
technical stakeholders express their needs clearly, ensuring that database designers understand and
incorporate requirements effectively before building begins.
Entity-Relationship Model(ER Model): It is a high-level data model which is used to define the data
and the relationships between them. It is basically a conceptual design of any database which is easy
to design the view of data.
Components of ER Model:
Entity: An entity is referred to as a real-world object. It can be a name, place, object, class, etc. These
are represented by a rectangle in an ER Diagram.
Attributes: An attribute can be defined as the description of the entity. These are represented by
Ellipse in an ER Diagram. It can be Age, Roll Number, or Marks for a Student.
Relationship: Relationships are used to define relations among different entities. Diamonds and
Rhombus are used to show Relationships.

2. Representational Data Model

The representational data model, like the Relational Model, focuses on how data is organized logically
using tables to show relationships. It's about designing databases without worrying about how they're
physically stored. Relational Algebra and Calculus are theories that help in designing how data can be
managed and queried, while the actual storage details are handled in the Physical Data Model.

pg. 10
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

3. Physical Data Model


The physical data model translates the relational model into a real database system. It specifies how
data tables are stored on disk or other storage devices, including file formats and structures. This model
is crucial for efficient data access and is created by database administrators and developers using SQL
to implement relational concepts practically. It focuses on the actual implementation details needed to
make the database work smoothly.
Some Other Data Models:

 Hierarchical Model: Data is structured like a tree with parent and child relationships.
Developed in the 1950s by IBM, it's organized into segments where each record has one parent
and many children, forming chains or fan-like structures.
 Network Model: A generalization of the hierarchical model, formalized in the 1960s, it allows
multiple parent segments and many-to-many relationships between segments. Segments are
grouped into levels with logical associations, extending the hierarchical structure.
 Object-Oriented Data Model: Combines object-oriented programming concepts with
databases. Data and relationships are represented as objects with attributes, reflecting real-
world entities. Objects can have multiple relationships between them, blending flexibility with
structured data storage.
 Float Data Model: The float data model basically consists of a two-dimensional array of data
models that do not contain any duplicate elements in the array. This data model has one
drawback it cannot store a large amount of data that is the tables cannot be of large size.
 Context Data Model: The Context data model is simply a data model which consists of more
than one data model. For example, the Context data model consists of ER Model, Object-
Oriented Data Model, etc. This model allows users to do more than one thing which each
individual data model can do.
 Semi-Structured Data Model: Semi-Structured data models deal with the data in a flexible
way. Some entities may have extra attributes and some entities may have some missing
attributes. Basically, you can represent data here in a flexible way.

Advantages of Data Models


 Data Models help us in representing data accurately.
 It helps us in finding the missing data and also in minimizing Data Redundancy.
 Data Model provides data security in a better way.
 The data model should be detailed enough to be used for building the physical database.
 The information in the data model can be used for defining the relationship between tables,
primary and foreign keys, and stored procedures.

Disadvantages of Data Models


 In the case of a vast database, sometimes it becomes difficult to understand the data model.
 You must have the proper knowledge of SQL to use physical models.
 Even smaller change made in structure require modification in the entire application.
 There is no set data manipulation language in DBMS.
 To develop Data model one should know physical data stored characteristics.

pg. 11
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

Database Schema:
 The database schema of a database is its structure described in a formal language supported by
the database management system (DBMS).
 The term "schema" refers to the organization of data as a blueprint of how the database is
constructed (divided into database tables in the case of relational databases).

In the context of databases and DBMS, there are primarily three types of schemas:

1. Physical Schema:
o Defines how data is stored physically on a storage system such as disks or tapes. It
includes details like file structures, indexing methods, and data partitioning. This
schema is concerned with optimizing performance and storage efficiency.
2. Logical Schema:
o Describes the database structure at a conceptual level, focusing on how data is
represented and organized, independent of the specific DBMS implementation. It
includes tables, columns, relationships, and constraints, providing a high-level view of
the database.

pg. 12
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

3. External Schema (or View Schema):


o Represents the part of the database schema that is relevant to a particular user or group
of users. It defines the subset of the database that each user can access and specifies
their view of the database. This schema helps in presenting a customized and simplified
view of the database to different user groups based on their needs and permissions.

Difference between schema and database:

DBMS Architecture and Data Independence:


An architecture for database systems, called the three-schema architecture which was proposed to help
achieve and visualize the DBMS characteristics
The Three-Schema Architecture:
Proposed to support DBMS characteristics of:
 Program-data independence.
 Support of multiple views of the data.

 Not explicitly used in commercial DBMS products, but has been useful in explaining database system
organization

pg. 13
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

1. External level
It is also called view level. The reason this level is called “view” is because several users can view
their desired data from this level which is internally fetched from database with the help of conceptual
and internal level mapping.
External level is the “top level” of the Three Level DBMS Architecture.
2. Conceptual level
It is also called logical level. The whole design of the database such as relationship among data, schema
of data etc. are described in this level.
Database constraints and security are also implemented in this level of architecture. This level is
maintained by DBA (database administrator).
3. Internal level
This level is also known as physical level. This level describes how the data is actually stored in the
storage devices. This level is also responsible for allocating space to the data. This is the lowest level
of the architecture.

Data Independence:
The three-schema architecture can be used to explain the concept of data independence, which can be
defined as the capacity to change the schema at one level of a database system without having to
change the schema at the next higher level. We can define two types of data independence:
1. Logical data independence is the capacity to change the conceptual schema without having to
change external schemas or application programs. We may change the conceptual schema to expand
the database (by adding a record type or data item), or to reduce the database (by removing a record
type or data item).
2. Physical data independence is the capacity to change the internal schema without having to change
the conceptual (or external) schemas. Changes to the internal schema may be needed because some
physical files had to be reorganized—for example, by creating additional access structures—to
improve the performance of retrieval or update. If the same data as before remains in the database, we
should not have to change the conceptual schema.

pg. 14
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

Database Language:
Databases are used to store information. The Database is related to both software and hardware here
The Software is used for accessing the data in the form of Software applications, and The Hardware is
used for storing the data in the memory or hard disk.
Any Database provides an interface between the end user and the database by using this interface, the
end user can access the database data. It is a very secure means before accessing database data we need
to authenticate first, and then we get access to the database. We have different types of Database
Languages which are represented in the below image.

 DDL (Data Definition Language)


The DDL stands for Data Definition Language, Which is used for define the database’s internal
structure and Pattern of the Database.
Basically, The DDL is used for creating tables, indexes, constraints, and schema in the Database.
By using DDL statements we can able to create the architecture of the required database.
Below I list out types of database commands that are used in DDL. By using those queries we can able
to perform the DDL on the Database.
 Create It is used to create objects in the database
 Alter It is used for change or alter the structure of the database objects
 Drop It is used for delete objects from the database
 Truncate It is used for remove all records from a table
 Rename It is used to rename the object in database
 Comment It is used for comment on the data dictionary.

Create
It is one the command in DDL which is used for creating objects in database means creating Tables,
Users, Triggers, functions and other objects. Here I will show how to create a table by using create
command from DDL.

pg. 15
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

Syntax:
CREATE TABLE Students (
Column1 INT,
Column2 VARCHAR (50),
Column3 INT
);
Alter
It is one the command in DDL which is used for change or alter the structure of the database or table.
I already created students table with some columns you can see in the above image. Now by using
Alter command I add new column that weight to the students table.
Syntax:
ALTER TABLE Students ADD column_name;

Drop
This Drop command is used for delete objects from the database. In this example I drop the students
table
Syntax:
DROP Table Table_name;

Truncate
Truncate command is used for remove all records from a table. Now I remove rows from the Student
table.
Syntax:
TRUNCATE TABLE table_name;

Comment
It is used for comment on the data dictionary. We have two different comments namely Single line
comment and Multi-line comments.
Single Line
-- This is a single-line comment

pg. 16
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

Multi-line comment
/*
This is a
Multi-line comment
*/

Rename
It is used to rename the object in database. Now I rename the table from students to Class Members.
Below I provide the example for better understanding.
Syntax:
ALTER TABLE Old_Table_Name RENAME TO New_Table_Name;

 DCL (Data Control Language)


The DCL stands for Data Control Language means these commands are used to retrieve the saved data
from database. And one more thing is the DCL execution is Transactional that means it have roll back
parameters. We have two tasks under the Data Control Language below I listed them

 Grant It is used for give user access to the database


 Revoke It is used for to take back the access or permissions from the user

Grant
Basically the grant command is used for provide database access to the new user. Here I create one
user then I give the access to the database.
Syntax:
GRANT privileges
ON object
TO user_or_role [WITH GRANT OPTION];
Example:
GRANT SELECT, INSERT ON students TO user;

Revoke
The Revoke command is used to take back database access from the user. Now I provide the example
in the below

pg. 17
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

Syntax:
REVOKE privileges ON object FROM user_or_role;
Example:
REVOKE ALL PRIVILEGES ON students FROM user;

 DML (Data Manipulation Language)


The Data Manipulation Language is used to manipulate the data in the database by using different
commands. In this category we can able to perform Insert new data into Table, Update existing data in
the Table, Delete Data from the Table and other functions we can perform on data by using these DML
commands. Below I listed those commands for your reference
 Select It is used for select data from the Table based on the requirements
 Insert It is sued for Inserting data into existing table
 Update It is used for update data in the Table based on the requirement
 Delete It is used for delete data from the Table

Select
The Select command is used for select required data based on conditions from an existing Table. Here
I select all data from the ClassMembers Table.
Syntax:
SELECT * FROM Table_Name;
Insert
The Insert command is used for inserting new data into Table. Now I insert a new data into
ClassMembers Table. Below I provide the example.
Syntax:
INSERT INTO Table_Name (Column 1, Column 2, Column 3, Column 4) VALUES (Value 1, Value
2, Value 3, Value 4);
Update
The Update command is used for update information In the Table. Now I will update name John Doe
to Roman in the ClassMemebers Table. Below I provide that Example you can update any row or
columns data.
Syntax:
UPDATE Table_Name SET Name = 'New_Value' WHERE Name = 'Ola_Value';
Delete:
The Delete command is used for delete data from the Table. Here I delete Student Id with 2 from the
ClassMembers. Below I provide the Example for your reference.

pg. 18
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

Syntax:
DELETE FROM Table_Name WHERE Column = Value;

 TCL ( Transaction Control Language )


The TCL full form is Transaction Control Language commands are used to run the changes made by
the DML commands and one more thing is TCL can be grouped into a logical transaction. And we
have two different commands in this category below I listed them for reference.
 Commit It is used for save the transaction on the Database. And these very useful in banking
sectors.
 Rollback It is used for restore the database to original state from last commit. This command
also plays an important role in Banking Sectors.

Commit
The Commit command is used for save the transaction in the database and changes are made by the
DML statements. Now I will provide the example below Here I used ClassMembers Table. Here I
inserted a new data into Table then I commit it.
Syntax:
Commit;
ROLLBACK
Rollback command is used for restore the database to original state from last commit. Here I provide
the example and in this I already commit the you can see in the above, now I delete one row from the
Table then again rollback the previous database state.
Syntax:
ROLLBACK;

DBMS Interfaces:
DBMS Interfaces are the various methods through which users and applications interact with a
database management system. These interfaces facilitate the execution of operations such as querying,
updating, and managing the data stored within the database. The main types of DBMS interfaces
include:
 Menu-Based Interfaces for Browsing
 Forms-Based Interfaces
 Graphical User Interfaces
 Natural Language Interfaces
 Interfaces for Parametric Users
 Interfaces for the DBA

pg. 19
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

 Menu-Based Interfaces for Browsing: These interfaces present the user with lists of options,
called menus that lead the user through the formulation of a request. They are often used in
browsing interfaces, which allow a user to look through the contents of a database in an
exploratory and unstructured manner.
 Forms-Based Interfaces: A forms-based interface displays a form to each user. Users can fill
out all of the form entries to insert new data, or they fill out only certain entries, in which case
the DBMS will retrieve matching data for the remaining entries.
 Graphical User Interfaces: A graphical interface (GUI) typically displays a schema to the
user in diagrammatic form.
 Natural Language Interfaces: These interfaces accept requests written in English or some
other language and attempt to "understand" them. A natural language interface usually has its
own "schema," which is similar to the database conceptual schema. The natural language
interface refers to the words in its schema, as well as to a set of standard words, to interpret the
request.
 Interfaces for Parametric Users: Parametric users, such as bank tellers, often have a small
set of operations that they must perform repeatedly. Systems analysts and programmers design
and implement a special interface for a known class of naive users. Usually, a small set of
abbreviated commands is included, with the goal of minimizing the number of keystrokes
required for each request.
 Interfaces for the DBA: Most database systems contain privileged commands that can be used
only by the DBA’s staff. These include commands for creating accounts, setting system
parameters, granting account authorization, changing a schema, and reorganizing the storage
structures of a database.

Classification of DBMS:

1) Centralized Database: It is the type of database that stores data at a centralized database system.
It comforts the users to access the stored data from different locations through several applications.

pg. 20
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

2) Distributed Database: Unlike a centralized database system, in distributed systems, data is


distributed among different database systems of an organization.

3) Relational Database: This database is based on the relational data model, which stores data in the
form of rows (tuple) and columns (attributes), and together forms a table (relation). A relational
database uses SQL for storing, manipulating, as well as maintaining the data.

pg. 21
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

4) NoSQL Database: Non-SQL/Not Only SQL is a type of database that is used for storing a wide
range of data sets. It is not a relational database as it stores data not only in tabular form but in several
different ways.

5) Cloud Database: A type of database where data is stored in a virtual environment and executes
over the cloud computing platform. It provides users with various cloud computing services (SaaS,
PaaS, IaaS, etc.) for accessing the database.

6) Object-oriented Databases: The type of database that uses the object-based data model approach
for storing data in the database system. The data is represented and stored as objects which are similar
to the objects used in the object-oriented programming language.

pg. 22
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

7) Hierarchical Databases: It is the type of database that stores data in the form of parent-children
relationship nodes. Here, it organizes data in a tree-like structure.

E-R Model:

Entity Relationship Modelling:


The ER model was created to provide a simple and understandable model for representing the structure
and logic of databases. It has since evolved into variations such as the Enhanced ER Model and the
Object Relationship Model
The Entity Relational Model is a model for identifying entities to be represented in the database and
representation of how those entities are related. The ER data model specifies enterprise schema that
represents the overall logical structure of a database graphically.
The Entity Relationship Diagram explains the relationship among the entities present in the database.
ER models are used to model real-world objects like a person, a car, or a company and the relation
between these real-world objects. In short, the ER Diagram is the structural format of the database.

Components of ER Model:
ER Model consists of Entities, Attributes, and Relationships among Entities in a Database System.

pg. 23
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

Entity
 An entity is an object in the real world with an independent existence and can be differentiated
from other objects
An entity might be
 An object with physical existence. E.g. a lecturer, a student, a car.
 An object with conceptual existence. E.g. a course, a job, a position.

Entity Type:
It refers to the category that a particular entity belongs to.
Example:
 A table named student in a university database.
 A table named employee in a company database.

Entity Set:
An Entity Set is a collection of entities of an entity type at a point of time.
Example:
 The collection of all the students from the student table at a particular instant of time.
 The collection of all the employees from the employee table at a particular instant of time.

Attributes: Entities are represented by means of their properties called attributes.


 Each entity is described by a set of attributes. E.g. Employee = (Name, Address, Age, Salary).
 Each attribute has a name, associated with an entity and is associated with a domain of legal
values. However the information about attribute domain is not presented on the ER diagram.
 In the diagram, each attribute is represented by an oval with a name inside.

pg. 24
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

Types of attributes:
 Simple attributes are attributes that are drawn from the atomic value domains
Example: Name = {John}; Age = {23}, also called Single valued.

 Composite attributes: Attributes that consist of a hierarchy of attributes


Example: Address may consists of “Number”, “Street” and “Suburb” → Address = {59 +
‘Meek Street’ + ‘Kingsford’}

 Single-Valued Attribute: The attribute which takes up only a single value for each entity
instance is a single-valued attribute.
Example: The age of a student, Aadhar card number.

pg. 25
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

 Multivalued attributes: Attributes that have a set of values for each entity
Example: Degrees of a person: ‘BSc’, ‘MIT’, ‘PhD’

 Derived attributes: Attributes contain values that are calculated from other attributes
Example: Age can be derived from attribute DateOfBirth. In this situation, DateOfBirth might
be called Stored Attribute.

 Complex Attribute
Those attributes, which can be formed by the nesting of composite and multi-valued attributes, are
called “Complex Attributes“. These attributes are rarely used in DBMS (DataBase Management
System). That’s why they are not so popular.
Example: Address because address contain composite value like street, city, state, PIN code and also
multivalued because one people has more than one house address.

pg. 26
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

Key attribute:
Key attributes are those attributes that can uniquely identify the entity in the entity set.
Example: Roll-No is the key attribute because it can uniquely identify the student.

Keys in DBMS:
Keys are one of the basic requirements of a relational database model. It is widely used to identify the
tuples (rows) uniquely in the table. We also use keys to set up relations amongst various columns and
tables of a relational database.
Different Types of Database Keys:

Primary Key-
 A primary key is a candidate key that the database designer selects while designing the
database.
NOTES-
 The value of primary key can never be NULL.
 The value of primary key must always be unique.
 The values of primary key can never be changed i.e. no updation is possible.
 The value of primary key must be assigned when inserting a record.
 A relation is allowed to have only one primary key.

pg. 27
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

Foreign Key-
 A foreign key is the one that is used to link two tables together via the primary key. It means
the columns of one table points to the primary key attribute of the other table.
 It further means that if any attribute is set as a primary key attribute will work in another table
as a foreign key attribute.

Candidate Key-
 A minimal super key is called as a candidate key.
OR
 A set of minimal attribute(s) that can identify each tuple uniquely in the given relation is called
as a candidate key.
For example: In the EMPLOYEE table, id is best suited for the primary key. The rest of the
attributes, like SSN, Passport_Number, License_Number, etc., are considered a candidate key.

Super Key-
 A super key is a set of attributes that can identify each tuple uniquely in the given relation.
 A super key is not restricted to have any specific number of attributes.
 Thus, a super key may consist of any number of attributes.

pg. 28
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

For example: In the above EMPLOYEE table, for (EMPLOEE_ID, EMPLOYEE_NAME), the name
of two employees can be the same, but their EMPLYEE_ID can't be the same. Hence, this combination
can also be a key.
Alternate Key-
 Candidate keys that are left unimplemented or unused after implementing the primary key are
called as alternate keys.
OR
 Unimplemented candidate keys are called as alternate keys.
 For example, employee relation has two attributes, Employee_Id and PAN_No that act as
candidate keys. In this relation, Employee_Id is chosen as the primary key, so the other
candidate key, PAN_No, acts as the Alternate key.

Composite Key-
 A primary key comprising of multiple attributes and not just a single attribute is called as a
composite key.

For example, in employee relations, we assume that an employee may be assigned multiple roles, and
an employee may work on multiple projects simultaneously. So the primary key will be composed of
all three attributes, namely Emp_ID, Emp_role, and Proj_ID in combination. So these attributes act as
a composite key since the primary key comprises more than one attribute.

pg. 29
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

Secondary Key-
 Secondary key is required for the indexing purpose for better and faster searching.
Unique Key-
Unique key is a key with the following properties-
 It is unique for all the records of the table.
 Once assigned, its value cannot be changed i.e. it is non-updatable.
 It may have a NULL value.
Example-
 The best example of unique key is Adhaar Card Numbers.
Partial Key-
 Partial key is a key using which all the records of the table cannot be identified uniquely.
 However, a bunch of related tuples can be selected from the table using the partial key.
Example-
 Department ( Emp_no , Dependent_name , Relation )
Emp_no Dependent_name Relation

E1 Suman Mother

E1 Ajay Father

E2 Vijay Father

E2 Ankush Son

 Here, using partial key Emp_no, we cannot identify a tuple uniquely but we can select a bunch
of tuples from the table.

pg. 30
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

Surrogate Key-
 Surrogate key is a key with the following properties-
 It is unique for all the records of the table.
 It is updatable.
 It cannot be NULL i.e. it must have some value.
Example-
 Mobile Number of students in a class where every student owns a mobile phone.

Domain of Attributes:
The set of possible values that an attribute can take is called the domain of the attribute. For example,
the attribute day may take any value from the set {Monday, Tuesday ... Friday}. Hence this set can be
termed as the domain of the attribute day.

Relationships between the entities:


Any association between two entity types is called a relationship. Entities take part in the relationship.
It is represented by a diamond shape.
There are three types of relationships that can exist between two entities.
 One-to-One Relationship
 One-to-Many or Many-to-One Relationship
 Many-to-Many Relationship
One-to-One Relationship:
 Such a relationship exists when each record of one table is related to only one record of the
other table.
 For example, if there are two entities ‘Person’ (Id, Name, Age, Address) and ‘Passport’
(Passport_id, Passport_no). So, each person can have only one passport and each passport
belongs to only one person.

One-to-Many or Many-to-One Relationship


 Such a relationship exists when each record of one table can be related to one or more than one
record of the other table.

pg. 31
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

 This relationship is the most common relationship found.


 A one-to-many relationship can also be said as a many-to-one relationship depending upon the
way we view it.

Many-to-Many Relationship
 Such a relationship exists when each record of the first table can be related to one or more than
one record of the second table and a single record of the second table can be related to one or
more than one record of the first table.
 The linking table links two tables by having fields which are the primary key of the other two
tables.
 If there are two entity type ‘Customer’ and ‘Product’ then each customer can buy more than
one product and a product can be bought by many different customers.

pg. 32
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

Structural Constraints of Relationships in ER Model:


Prerequisite – ER Model to understand Structural Constraints, we must take a look at Cardinality
Ratios and Participation Constraints. Cardinality Ratios of relationships: The entities are denoted by
rectangle and relationships by diamond.

There are numbers (represented by M and N) written above the lines which connect relationships and
entities. These are called cardinality ratios. These represent the maximum number of entities that can
be associated with each other through relationship, R.

Types of Cardinality: There can be 4 types of cardinality –

One-to-one (1:1) – When one entity in each entity set takes part at most once in the relationship, the
cardinality is one-to-one.
One-to-many (1: N) – If entities in the first entity set take part in the relationship set at most once and
entities in the second entity set take part many times (at least twice), the cardinality is said to be one-
to-many.

pg. 33
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

Many-to-one (N:1) – If entities in the first entity set take part in the relationship set many times (at
least twice), while entities in the second entity set take part at most once, the cardinality is said to be
many-to-one.
Many-to-many (N: N) – The cardinality is said to be many to many if entities in both the entity sets
take part many times (at least twice) in the relationship structural Constraints of Relationships in ER
Model

Participation Constraints: Participation constraints tell us that the participation in a relationship


can either be total or partial.

Types of participation constraints:


 Total Participation
 Each entity in the entity set is involved in at least one relationship in a relationship set.

 Consider two entities Employee and Department related via Works For relationship.
 Now, every Employee works in at least one department therefore an Employee entity exist if it
has at least one Works For relationship with Department entity.
 Thus the participation of Employee in Works For is total relationship.
 Partial Participation
 E ach entity in entity set may or may not occur in at least one relationship in a relationship set.

pg. 34
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

 Consider two entities Employee and Department and they are related to each other via Manages
relationship.
 An Employee must manage a Department, he or she could be the head of the department.
 But not every Employee in the company manages the department.
 So, participation of employee in the Manages relationship type is partial i.e. only a particular
set of Employees will manage the Department but not all.

Structural Constraints:
 Structural Constraints are also called Structural properties of a database management system
(DBMS). Cardinality Ratios and Participation Constraints taken together are called Structural
Constraints. The name constraints refer to the fact that such limitations must be imposed on the
data, for the DBMS system to be consistent with the requirements.

 The Structural constraints are represented by Min-Max notation. This is a pair of numbers (m,
n) that appear on the connecting line between the entities and their relationships. The minimum
number of times an entity can appear in a relation is represented by m whereas, the maximum
time it is available is denoted by n. If m is 0 it signifies that the entity is participating in the
relation partially, whereas, if m is either greater than or equal to 1, it denotes total participation
of the entity. Note – Number of times an entity participates in a relationship is same as the
number appearance of the entity in the tuples.

pg. 35
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

Degree of Relationship
The degree of a relationship is the number of entity types that participate (associate) in a relationship.
By seeing an E-R diagram, we can simply tell the degree of a relationship i.e. the number of an
entity type that is connected to a relationship is the degree of that relationship.

For example, if we have two entity type ‘Customer’ and ‘Account’ and they are linked using the
primary key and foreign key. We can say that the degree of relationship is 2 because here two entities
are taking part in the relationship.

There are 4 types of degrees of relationship based on the involved entities-

 Unary relationship
 Binary relationship
 Ternary relationship
 N-ary relationship

Unary Relationship:
In this type of relationship, both the associating entity types are the same. So, we can say that unary
relationships exist when both entity types are the same and we call them the degree of relationship is
1. In other words, in a relation only one entity set is participating then such type of relationship is
known as a unary relationship.
Example: In a particular class, we have many students, there are monitors too. So, here class monitors
are also students. Thus, we can say that only students are participating here. So the degree of such type
of relationship is 1.

Binary Relationship:

In a Binary relationship, there are two types of entity associates. So, we can say that a Binary
relationship exists when there are two types of entity and we call them a degree of relationship is 2.
Or in other words, in a relation when two entity sets are participating then such type of relationship
is known as a binary relationship. This is the most used relationship and one can easily be converted
into a relational table.

pg. 36
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

Example: We have two entity types ‘Student’ and ‘ID’ where each ‘Student’ has his ‘ID’. So, here
two entity types are associating we can say it is a binary relationship. Also, one ‘Father’ can have
many ‘daughters’ but each ‘daughter’ should belong to only one ‘father. We can say that it is a one-
to-many binary relationship.

Ternary (Degree 3)
In the Ternary relationship, there are three types of entity associates. So, we can say that a Ternary
relationship exists when there are three types of entity and we call them a degree of relationship is 3.
Since the number of entities increases due to this, it becomes very complex to turn E-R into a relational
table. Now let’s understand with the examples.
Example: We have three entity types ‘Teacher’, ‘Course’, and ‘Class’. The relationship between these
entities is defined as the teacher teaching a particular course, also the teacher teaches a particular class.
So, here three entity types are associating we can say it is a ternary relationship.

N-ary (n Degree)
In the N-ary relationship, there are n types of entity that associates. So, we can say that an N-ary
relationship exists when there are n types of entities. There is one limitation of the N-ary relationship,
as there are many entities so it is very hard to convert into an entity, rational table. So, this is very
uncommon, unlike binary which is very much popular.
Example: We have 5 entities Teacher, Class, Location, Salary, and Course. So, here five entity types
are associating we can say an n-ary relationship is 5.

pg. 37
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

Entity type:

A collection of entities with general characteristics is known as an entity type.

For example, a database of a corporate company has entity types such as employees, departments, etc.
In DBMS, every entity type contains a set of attributes that explain the entity.

The Employee entity type can have attributes such as name, age, address, phone number, and salary.

The Department entity type can have attributes such as name, number, and location in the department.

Entity types are of two types:

1. Strong Entity Type:

It is an entity that has its own existence and is independent.

The entity relationship diagram represents a strong entity type with the help of a single rectangle.
Below is the ERD of the strong entity type:

In the above example, the "Customer" is the entity type with attributes such as ID, Name, Gender, and
Phone Number. Customer is a strong entity type as it has a unique ID for each customer.

2. Weak Entity type:

It is an entity that does not have its own existence and relies on a strong entity for its existence.

The Entity Relationship Diagram represents the weak entity type using double rectangles. Below is
the ERD of the weak entity type:

pg. 38
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

In the above example, "Address" is a weak entity type with attributes such as House No., City,
Location, and State.

The relationship between a strong and a weak entity type is known as an identifying relationship.

Using a double diamond, the Entity-Relationship Diagram represents a relationship between the strong
and the weak entity type.

Let us see an example of the relationship between the Strong entity type and weak entity type with the
help of ER Diagram:

E-R Diagram:
 ER diagrams are used to represent the E-R model in a database, which makes them easy to
convert into relations (tables).
 ER diagrams provide the purpose of real-world modelling of objects which makes them intently
useful.
 ER diagrams require no technical knowledge and no hardware support.
 These diagrams are very easy to understand and easy to create even for a naive user.
 It gives a standard solution for visualizing the data logically.

Notation for ER diagram:

pg. 39
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

ER Diagram for a Company Database:


Entities and their Attributes are:
 Employee Entity: Attributes of Employee Entity are Name, Id, Address, Gender, DOB and
Doj.
It is Primary Key for Employee Entity.
 Department Entity: Attributes of Department Entity are D_no, Name and Location.
D_no is Primary Key for Department Entity.
 Project Entity: Attributes of Project Entity are P_No, Name and Location.
P_No is Primary Key for Project Entity.
 Dependent Entity: Attributes of Dependent Entity are D_no, Gender and relationship.
Relationships are:
 Employee’s works in Departments – Many employee works in one Department but one
employee cannot work in many departments.
 Manager controls a Department – Employee works under the manager of the Department
and the manager records the date of joining of employee in the department.
 Department has many Projects – One department has many projects but one project cannot
come under many departments.

pg. 40
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE

 Employee works on project – One employee works on several projects and the number of
hours worked by the employee on a single project is recorded.
 Employee has dependents – Each Employee has dependents. Each dependent is dependent
of only one employee.

pg. 41

You might also like