0% found this document useful (0 votes)
21 views89 pages

dbms1 ppt

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)
21 views89 pages

dbms1 ppt

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/ 89

1

DATABASE
MANAGEMENT SYSTEM
DATA & INFORMATION 2
 What is Data?
 Definition: Known facts or figures with implicit
meaning, representing facts, concepts, or instructions
in a formal manner for understanding and
processing.
 Representation: Can be in alphabets, digits, and
special characters (e.g., "25", "ajit").
 Information:
 Definition: Processed data used for decision-making,
organized and classified to provide meaningful
values.
 Example: "The age of Ravi is 25."
3

 File:
 Definition: A collection of related data stored in
secondary memory.

 File-Oriented Approach:
 Traditional Method: Each application has a separate
master file and personal files, with program
dependency on the files and vice versa.
Disadvantages of File- 4
Oriented Approach:
 Data Redundancy and Inconsistency: Same information in multiple
files, leading to higher storage costs and data inconsistency.
 Difficulty in Accessing Data: Conventional systems do not allow
convenient data retrieval based on user preference.
 Data Isolation: Scattered data in various files with different formats
makes data retrieval difficult.
 Integrity Problems: Difficulty in enforcing new constraints due to
changes in the application program.
 Atomicity: Challenges in ensuring all or none operations in a
transaction due to system failures.
 Concurrent Access: Not possible to access the same file
simultaneously for transactions.
 Security Problems: Lack of security measures to protect data from
unauthorized access.
DATABASE 5

 An organized collection of related data stored in a format


accessible by multiple users.
 Features:
 Well-organized
 Related data
 Logical order for easy access
 Stored only once
 Concepts:
 Persistent: Data remains unless explicitly removed by the user.
 Integrated: Redundant data across files are removed, creating a
unified dataset.
 Sharing: Data can be shared by multiple users simultaneously
without errors.
Why Database? 6

 Overcomes File System Limitations: Provides


centralized data collection, self-describing nature, and
integration.
 Large Database Management: A computerized
database is essential for large databases with multiple
users.
 Advantages of Database System:
 Compactness: Reduces the need for large paper files.
 Speed: Faster data retrieval and modification compared to
manual processes.
 Less Drudgery: Minimizes manual maintenance efforts.
 Accuracy: Ensures up-to-date information is available when
required.
Database Management 7

System (DBMS)
 Definition: A collection of related data managed by programs
for defining, creating, maintaining, and manipulating a
database.
 Functions of DBMS:
 Defining Database Schema: Allows specifying the structure and
access rights for users.
 Manipulation of Database: Includes inserting, updating, deleting,
and retrieving data.
 Sharing Database: Facilitates consistent data sharing among
multiple users.
 Protection of Database: Ensures protection against unauthorized
access.
 Database Recovery: Supports recovery in case of system failures.
Advantages of DBMS 8

 Reduction of Redundancies: Centralized data control reduces


duplication and inconsistencies.
 Sharing of Data: Multiple users or applications can access shared
data.
 Data Integrity: Ensures data is accurate and consistent within the
database.
 Data Security: Implements proper access procedures and
authentication to secure data.
 Conflict Resolution: The DBA resolves user and application conflicts
for optimal performance.
 Data Independence:
 Physical Data Independence: Allows changes in physical storage
without affecting application programs.
 Logical Data Independence: Conceptual schema changes without
impacting external schemas or application programs.
Disadvantages of DBMS 9

 High Costs: Both software and hardware setup are


expensive.
 Processing Overhead: DBMS incurs overhead for
implementing security, integrity, and data sharing.
 Centralized Database Control: Requires specialized
knowledge and skills for setup and maintenance.
 Complexity: The complexity of the database system
may affect performance.
Database Applications 10

 Universities: Manages data such as student, teacher, and


course information.
 Banking: Handles account details, transactions, and
customer data systematically.
 Railway Reservation System: Stores passenger and booking
information for efficient retrieval.
 Social Media Sites: Maintains vast amounts of user data,
including images, videos, and chats.
 Library Management System: Tracks book availability,
issues, and returns.
 E-commerce Websites: Stores customer, product, and
transaction details securely.
 Medical: Manages patient records, appointments, and
medical data.
 MORE……
Data Abstraction 11

Hides the
complexity of
the database
system,
presenting only
necessary
details to users
or applications.
Levels of Abstraction 12
•Physical Level (Storage Level):
1. Deals with the actual storage of data on hardware.
2. Includes file structures, indexing, access methods, and
data retrieval/storage optimization.
•Conceptual Level (Logical Level):
1. Provides a unified view of the database, focusing on the
logical structure of data.
2. Involves schema design, tables, relationships,
constraints, and views.
•External Level (View Level):
•Description: Concerned with how data is presented to
individual users or applications.
•Details: Includes user-specific views and access controls.
Benefits of Data 13

Abstraction
 Simplified Interaction: Users can interact
with a simplified view of data without
complex storage details.
 Data Independence: Changes in storage
or schema do not affect user interaction.
 Enhanced Security: Controls visibility and
access at the external level, protecting
sensitive information.
Data Independence 14

 Ability
to change
the database
schema/structure
at one level
without affecting
other levels or
applications.
Types of Data
15
Independence
•Logical Data Independence:
Change the conceptual schema without altering external schemas or
applications.
•Implications:
•Changes to Logical Schema: Modify schema without impacting user
access.
•Minimal Impact: Applications/views remain unaffected if logical
structure isn’t altered.
•Example: Adding a new column to a table without affecting existing
applications.
•Physical Data Independence:
•Definition: Change physical storage without impacting the conceptual
schema or applications.
•Implications:
•Changes to Storage: Reorganize storage methods without affecting
the logical schema or user access.
•Flexibility: DBMS can optimize performance without disrupting
applications.
•Example: Switching from a B-tree index to a hash index without affecting
Benefits of Data 16

Independence
•Flexibility and Adaptability: Easier updates
and maintenance with minimal disruption.

•Application Stability: Applications are


insulated from database schema/storage changes.

•Efficient Database Management:


Administrators can independently optimize physical
storage and conceptual design.
17
DATA DATA
ABSTRACTION INDEPENDENCE
Manages complexity Ensures flexibility and
by presenting data at stability by allowing
different levels— schema/storage changes
physical, conceptual, without affecting other
and external. levels or applications.
Database Basics 18

 Data
Item: The smallest unit of data
meaningful to users (e.g., "e101", "sumit").
 Entities and Attributes:
 Entity:Distinguishable objects in the real world
(e.g., Bank, Employee, Student).
 Attributes:
Properties of entities (e.g.,
Empcode, Ename, Roll No, Name).
Database Administration 19

A person who has central control over the system is


called database administrator .
The function of DBA are :
 1. Creation and modification of conceptual Schema
definition
 2. Implementation of storage structure and access
method.
 3. Schema and physical organization modifications .
 4. Granting of authorization for data access.
 5. Integrity constraints specification.
 6. Execute immediate recovery procedure in case of
failures
 7. Ensure physical security to database
SQL Commands 20
SQL commands are used to interact with
databases, allowing users to perform various
operations on database systems.

•Understanding these commands is essential for


effectively managing and manipulating data in
databases.
1. Data Definition Language (DDL)
2. Data Query Language (DQL)
3. Data Manipulation Language (DML)
4. Data Control Language (DCL)
5. Transaction Control Language (TCL)
21
DDL (Data Definition 22
Language)
•DDL consists of SQL commands used to define and modify
the database schema.
•It focuses on the structure of the database and its objects
rather than data manipulation.
•Purpose of DDL:
•Used to create, modify, and delete database structures such
as tables, indexes, and schemas.
•Deals with descriptions of the database schema and its
objects.
•Characteristics of DDL:
•DDL commands affect the structure, not the data.
•Typically used by database administrators or developers, not
general users.
DDL Command 23
DQL (Data Query 24
Language)
•DQL statements are used to query data within schema
objects.
•Primary command: SELECT.
•Purpose of DQL:
•Retrieves data from the database based on specified
conditions.
•Organizes and imposes order on the retrieved data.
•How DQL works:
•SELECT queries fetch data and compile it into a temporary
table.
•The result can be displayed or used by front-end applications
for further operations.
DQL Command 25
DML (Data Manipulation 26

Language)
•DML commands are used to manipulate data in the
database.
•Includes SQL commands for inserting, updating, deleting,
and retrieving data.

•Purpose of DML:
•Manages data access and modifications.
•Used for day-to-day database operations like adding,
updating, or querying records.
DML commands 27
DCL (Data Control 28

Language)
DCL includes commands such as GRANT and
REVOKE which mainly deal with the rights,
permissions, and other controls of the
database system.
DCL commands 29
TCL (Transaction Control 30

Language)
•TCL commands manage transactions within a database.
•Transactions group multiple tasks into a single execution
unit.

Purpose of TCL:

•Ensures data consistency by allowing multiple operations


to be treated as a single unit.
•Ensures either full success (commit) or full rollback in case
of failure.
TCL Commands 31
Important SQL Commands 32

 SELECT: Used to retrieve data from a database.


 INSERT: Used to add new data to a database.
 UPDATE: Used to modify existing data in a database.
 DELETE: Used to remove data from a database.
 CREATE TABLE: Used to create a new table in a database.
 ALTER TABLE: Used to modify the structure of an existing
table.
 DROP TABLE: Used to delete an entire table from a
database.
 WHERE: Used to filter rows based on a specified condition.
 ORDER BY: Used to sort the result set in ascending or
descending order.
 JOIN: Used to combine rows from two or more tables
based on a related column between them.
SQL Commands With
33
Examples
Types of Databases 34
Centralized Database 35

 Stores data in a central system,


accessible from different locations.
 Example: Central Library database.
 Advantages:
 Reduced data management risks.
 Maintains data consistency.
 Improved data quality.
 Lower costs due to fewer vendors.
 Disadvantages:
 Large size increases response time.
 Difficult to update.
 Server failure could result in complete
data loss.
Distributed Database 36

 Data distributed across different systems,


connected by communication links.
 Example: Apache Cassandra, HBase,
Ignite.
 Types:
 Homogeneous DDB: Same OS and
hardware.
 Heterogeneous DDB: Different OS and
hardware.
 Advantages:
 Modular development is possible.
 Server failure won’t affect the entire
dataset.
Relational Database 37

 Based on the relational model (tables of


rows and columns).
 Example: MySQL, Microsoft SQL Server,
Oracle.
 Properties (ACID):
 Atomicity: 'All or nothing' strategy for
transactions.
 Consistency: Data is preserved before
and after operations.
 Isolation: Concurrent transactions remain
isolated.
 Durability: Changes are permanent once
committed.
NoSQL Database 38

Stores data in various forms, not limited to


tables.
 Types:
 Key-value storage.
 Document-oriented.
 Graph databases.
 Wide-column stores.
 Advantages:
 Increased productivity in app
development.
 Manages large datasets effectively.
 High scalability.
 Quick data access via key-value pairs.
Cloud Database 39

•Data stored in a virtual


environment on cloud
computing platforms.
•Examples: AWS, Microsoft
Azure, Google Cloud SQL.
•Advantages:
•Provides cloud services
like SaaS, PaaS, IaaS.
Object-oriented Database 40

•Data stored as
objects, similar
to object-
oriented
programming.
Hierarchical Database 41

 Data stored in a tree-like


structure (parent-child
relationships).
 Disadvantages:
 Each child can have only one
parent, but parents can have
multiple children.
Network Database 42

 Follows the network model,


representing data in node-link
structures.
 Advantages:
 Allows multiple parent and
child nodes, forming a graph
structure.
DBMS Architecture 43

 The DBMS design depends upon its architecture. The


basic client/server architecture is used to deal with a
large number of PCs, web servers, database servers
and other components that are connected with
networks.
 The client/server architecture consists of many PCs
and a workstation which are connected via the
network.
 DBMS architecture depends upon how users are
connected to the database to get their request
done.
Types of DBMS 44

Architecture
1-Tier Architecture 45

 In this architecture, the database is directly available to the


user.
 The Client, Server and Database all reside on the same
machine.
 It means the user can directly sit on the DBMS and uses it.
 Any changes done here will directly be done on the
database itself.
 It doesn't provide a handy tool for end users.
 No network connection is required to perform the action
on the database.
46

 For development of the local application, where


programmers can directly communicate with
the database for the quick response.
 Data does not change frequently
 Where no multiple user is accessing the system
 For development of local application, where
programmers can directly communicate with
the database for the quick response.
 Such architecture is rarely used in production.
2-Tier Architecture 47
 Same as basic client-server.
 Applications on the client end can directly
communicate with the database at the server
side.
 The user interfaces and application programs
are run on the client-side.
 Application Programming Interfaces (API’s) like
ODBC, JDBC are used by client side program to
call DBMS.
 The user interfaces and application programs
are run on the Client side
 To communicate , client side application
establishes a connection with server side
 The server side is responsible to provide the
functionalities like: query processing and
transaction management.
48

 Used inside organization where multiple clients


accessing the database server directly.
 Ex: Railway reservation from counter, where clerk
as a client accesses the railway server directly
49
ADVANTAGE DIS ADVANTAGE
 Direct and faster  Scalability: Poor
communication performance when
 Maintenance and there are a large no.
understanding is of users
easier  Less secure as client
 Compatible with can access the
existing system server directly
3-Tier Architecture 50
 Contain another application layer between
the client and server.
 Client can't directly communicate with the
server.
 The application on the client-end interacts
with an application server which further
communicates with the database system,
then the query processing and transaction
management take place.
 This intermediate layer of Application Server
acts as a medium for exchange of partially
processed data between Server and Client.
 End user has no idea about the existence of
the database beyond the application server.
The database also has no idea about any
other user beyond the application.
51

 In 3 Tier Architecture, an application is virtually


split into three separate logical layers
 The 3-Tier architecture is used in case of large web
application.
 Most popular DBMS architecture
52

ADVANTAGE
DIS ADVANTAGE
 Enhanced scalability
Increased complexity
 Data Integrity
 Security
Three schema Architecture 53

 The three schema architecture is also


called ANSI/SPARC architecture or
three-level architecture.
 This framework is used to describe
the structure of a specific database
system.
 The three schema architecture is also
used to separate the user
applications and physical database.
 The three schema architecture
contains three-levels. It breaks the
database down into three different
categories.
54

DATA MODELS
DATA MODELS
55
•Concept of tools that are developed to summarize the description of the database
•Defines how the logical structure of a database is modeled
•Data Model refers to the modeling of data description, data semantics, and consistency
constraints.
•A Data Model is collection of conceptual tools for describing :
 Data
 Data Relationships
 Data Semantics
 Consistency constraints
It provides a structured way to define how data is stored, organized, and manipulated.
•A conceptual tool that helps in the design and representation of databases.
•Used to specify the logical structure of a database, including data types, relationships, and
rules.
•Helps to ensure data consistency by defining constraints and relationships.
•Describes data at various levels of abstraction—physical, logical, and conceptual.
•Facilitates communication between developers, database designers, and users.
56

DATA MODEL GIVES US AN IDEA THAT

HOW THE FINAL SYSTEM WILL LOOK LIKE

AFTER ITS COMPLETE IMPLEMENTATION


57
Relational Data Model 58
•Most widely used model by commercial data processing application
•The model was first described by Edgar F. Codd in 1969.
•It used collection of tables for representing data and the relationship
•Data is stored in tables called Relations
•Each tables is a group of Column and Rows, where column
represents attribute of an entity and rows represents records (or tuples).

 Attributes: Each column in a relation is called an attribute.


 The vales of the attribute should be from the same domain.
 Ex: Student_Id, Student_Name, Student_Age etc

 Tuple : Each row in the relation called Tuple


 A Tuple defines a collection of attributes values
 So each row in a relation contain unique values.
 Ex: Each row has all the information about any specific individual
59
60

•Relationships between data are maintained using keys (primary


keys and foreign keys).
•It is the most widely used data model, especially in commercial data
processing applications.
•Enables data integrity and consistency through relational
constraints (e.g., referential integrity).
•Supports SQL (Structured Query Language) for data manipulation and
querying.
Entity Relationship (ER) Model 61
1. An high level data model diagram
2. Describes the structure of a database known as ER
Diagram
3. Design or blueprint of a database that can later be
implemented as a database.
4. It is based on the notion of real-world entities and
relationship among them
5. An ER model is a logical representation of data as objects
(entities) and relationships among them.
6. Entities represent objects, while relationships are
associations between these entities.
7. The ER model was designed by Peter Chen and introduced
in a 1976 paper.
8. It is widely used in database design for structuring data.
62
ER Diagram has the following three components:
1. Entities : Real world things or objects (Person, Place or Concept)
2. Attributes: An Entity contains a real world property called Attribute
Ex: An Entity ‘Teacher’ has the property called Attribute like ‘Teacher ID’,
‘T_Name’, ‘T_Salary’ etc
3. Relationship: Tells how two attributes are related.

 Entities are described by a set of attributes (e.g.,


student_name, student_id describe the 'student' entity).
 A collection of similar entities forms an 'Entity set.'
 A collection of similar relationships forms a 'Relationship set.'
63
64
65
66
67
68
69
70
Draw an ER Diagram for a University Database System
that includes the following entities and relationships:
 Entities:
 Student (Student_ID, Student_Name, Age)
 Course (Course_ID, Course_Name, Credits)
 Department (Dept_ID, Dept_Name)
 Professor (Prof_ID, Prof_Name, Salary)
 Relationships:
 A student enrolls in one or more courses.
 A course is taught by one or more professors.
 Each professor belongs to one department.
 Each department offers multiple courses.
71

Construct an ER Diagram for a Car Insurance


company whose customer own one or more cars
each.
Each car has associated with it zero to any number
of recorded accidents.
72
Write the ENTITY, ATTRIBUTE AND 73
RELATIONSHIP OF FOLLOWING
Object-based Data Model 74

 An extension of the ER model that incorporates object-oriented


concepts like encapsulation and object.
 In this model both the data and relationship are present in a
single structure known as an object
 Two or more objects are connected through links.
 We use this links to relate one object to other objects
 Emerged in the 1980s with the rise of object-oriented database
systems.
75

Here two objects Employee and Department

All Data and Relationship of each are contained as a Single Unit

The Attributes like Name, Job of Employee and the Methods which will be

performed by that object are stored as a Single object

The Two Attributes are connected through a common Attribute


Semistructured Data Model 76
1. Evolved form of the relational model
2. A flexible data model that differs from traditional models.
3. Data Flexibility: Allows variable data structures, where data
items of the same type may have different sets of attributes.
4. Key Example: Extensible Markup Language (XML) is a
common format used for representing semistructured data.
5. Origin of XML: Initially designed to add markup information to
text documents.
6. Importance of XML: Gained significance for its role in data
exchange and interoperability across platforms.
7. Use Cases: Ideal for scenarios where data doesn’t follow a strict
schema, allowing flexibility and hierarchical data
representation.
77
 <student1>
<Roll No>……………</Roll No>
<Name>……………</Name>  <student2>
<Class>……………</Class> <Name>……………</Name>
<Age>……………</Age> <Class>……………</Class>
</student1> <Age>……………</Age>
</student2>
Network Model 78
 A network data model is a representation of data that emphasizes the
connections and interactions among different entities,
 Provide a dynamic framework for understanding the intricate web of
relationships within a system.
 Dynamic Framework: Provides a way to understand the complex
web of relationships within a system.
 Organizes Data: Structures data to reflect the inherent
relationships between entities.
 Flexible Structure: Unlike hierarchical and relational models, the
network model offers a more flexible and interconnected approach.
 Data Representation: Instead of tables or trees, data is organized in
a graph-like structure, allowing multiple relationships between
records.
 Use Case: Ideal for systems where many-to-many relationships are
common, such as social networks or supply chain management.
 Network Data Model: Emphasizes connections and interactions
between entities.
79

“Nodes represent entities, while edges define the


relationships or connections between these entities”
80

 Constraints:
Constraints are rules applied to
database columns to enforce  Integrity Constraints:
data integrity and consistency.
They ensure that the data Integrity constraints are a subset
entered into the database of constraints that specifically
adheres to specified rules. deal with maintaining the
accuracy and consistency of
 Types: Include various types of data within a database. They
constraints such as primary focus on the integrity of the
keys, foreign keys, unique data.
constraints, and check
constraints.  Purpose: To ensure that the
data adheres to certain
 Primary Key, Foreign Key, conditions that maintain the
Unique Constraint, Not Null, correctness and consistency
Check, Default of the database. They are
essential for ensuring that
relationships between data
elements are preserved.
Integrity Constraints 81

 Integrity constraints are predefined rules designed to


maintain the quality of information in a database.
 They ensure that operations like data insertion, updating,
and deletion do not compromise data integrity.
 Integrity constraints act as guidelines to keep data accurate
and consistent within the database.
 They are essential for protecting the database and ensuring
its reliability.
Types of Integrity 82

Constraints
Domain Constraints 83

 These are defined as the definition of valid set of values for an


attribute. The data type of domain include string, char, time,
integer, date, currency etc. The value of the attribute must be
available in comparable domains.

Student_Id Name Semester Age

21CSE100 Ramesh 5th 20

21CSE101 Kamlesh 5th 21

21CSE102 Aakash 5th 22

21CSE103 Mukesh 5th 20


Not-Null Constraints 84

 It specifies that within a tuple, attributes overs which not-null


constraint is specified must not contain any null value.

Student_id Name Semester Age

21CSE100 Ramesh 5th 20

21CSE101 Kamlesh 5th 21

21CSE102 Akash 5th 22

21CSE103 Mukesh 20
Entity Integrity Constraints 85

 Entity integrity constraints state that primary key can never


contain null value because primary key is used to determine
individual rows in a relation uniquely, if primary key contains
null value then we cannot identify those rows. A table can
contain null value in it except primary key field.

Student_id Name Semester Age

21CSE101 Ramesh 5th 20

21CSE102 Kamlesh 5th 21

21CSE103 Aakash 5th 22

Mukesh 5th 20
Key Constraints 86
 Keys are the entity set that are used to identify an entity within
its entity set uniquely. An entity set can contain multiple keys, bit
out of them one key will be primary key. A primary key is always
unique, it does not contain any null value in table.

Student_id Name Semester Age

21CSE101 Ramesh 5th 20

21CSE102 Kamlesh 5th 21

21CSE103 Aakash 5th 22

21CSE102 Mukesh 5th 20


Primary Key Constraints 87

 It states that the primary key attributes are required to be


unique and not null. This constraint is specified on database
schema to the primary key attributes to ensure that no two
tuples are same.

Student_id Name Semester Age

21CSE101 Ramesh 5th 20

21CSE102 Kamlesh 5th 21

21CSE103 Akash 5th 22

21CSE103 Mukesh 5th 20


Referential integrity 88
constraints
 It can be specified between two tables. In case of referential
integrity constraints, if a Foreign key in Table 1 refers to Primary
key of Table 2 then every value of the Foreign key in Table 1 must
be null or available in Table 2.

Student_id Name Semester Block_No


Block_No Block Location
22CSE101 Ramesh 5th 20
20 Chandigarh

21CSE105 Kamlesh 6th 21


21 Punjab

22CSE102 Aakash 5th 20 25 Delhi

23CSE106 Mukesh 2nd 22


89

You might also like