DBMSNotes
DBMSNotes
DBMS 1
What will we study?
DBMS 3
Why data is important ?
DBMS 5
Examples of Data and Information
Example 1: Weather
– Data: Hourly temperature readings throughout a day: 15°C, 17°C, 20°C, 22°C, 21°C,
18°C, 16°C.
– Information: The average temperature for the day is 18.4°C, indicating a mild day.
Example 2: Sales
– Data: Sales figures for a week: $200, $450, $300, $500, $700, $650, $400.
– Information: The total sales for the week amount to $3,200, showing a steady increase in
sales over the week.
Example 3: Health
– Data: Daily step counts: 5,000, 7,200, 6,800, 10,000, 8,500, 9,000, 7,500.
– Information: The average daily step count is 7,714 steps, suggesting an active lifestyle.
DBMS 6
Flat File System
• Before database has come in use, people used to keep records in file base
or flat file system. A flat file system is a simple database system where data
is stored in a single table or file without any structured relationships between
records. Here are some common examples:
1. CSV Files: Comma-Separated Values files store tabular data in plain text. Each line in the file
represents a row in the table, and fields are separated by commas.
2. TXT Files: Plain text files can be used to store data in a simple, readable format. Each line
typically represents a single record.
3. TSV Files: Tab-Separated Values files are similar to CSV files but use tabs to separate fields
instead of commas
DBMS 7
Limitations of Flat File System
1. Data redundancy
2. Inconsistent data
3. Inefficient data retrieval
4. Poor Accessibility
5. No support for complex Queries
DBMS 8
Database
DBMS 9
DBMS
DBMS 10
Features of DBMS
DBMS 13
Record
DBMS 15
Primary Key
• A primary key is a unique identifier for a
record in a database table.
• It ensures that each record within the table
can be uniquely identified by the key.
• Primary keys are a fundamental concept in
relational database design and are essential
for maintaining data integrity and establishing
relationships between tables.
DBMS 16
Characteristics of a Primary Key
StudentID Name Email PhoneNumber The PhoneNumber column is a super key because
1 [email protected]
9876543210 every student has a unique phone number.
2 Agastya [email protected]
9876543211 4. {StudentID, Name}:
3 Ravi [email protected]
9876543212 This combination is a super key because
StudentID already uniquely identifies each student.
However, it includes an additional column (Name),
Possible Super Keys in the Students Table: making it a redundant super key.
1. {StudentID}:
The StudentID column by itself is a super key 5{Email, Name}:
because it uniquely identifies each student. This combination is also a super key because
2. {Email}: Email alone is unique, but adding Name is
The Email column is also a super key because redundant.
every student has a unique email address.
3. {PhoneNumber}:
DBMS 21
Candidate key
• A candidate key is a minimal super key, meaning it has no unnecessary attributes. It is the smallest
possible combination of columns that can uniquely identify each row. For example:
• {StudentID} is a candidate key because it is the minimal set needed to uniquely identify a student.
• {Email} is another candidate key.
• {StudentID, Name} is not a candidate key because Name is redundant (it is not needed to ensure
uniqueness).
DBMS 22
Composite Key
• A composite key is a type of candidate key that consists of two or more columns (attributes) that
together uniquely identify a row in a table. Unlike a simple candidate key, which is made up of just one
column, a composite key uses multiple columns to achieve uniqueness.
DBMS 23
Example of Composite Key
• Let's consider a StudentCourses table that stores the courses taken by students.
DBMS 29
E-R Diagram
ER-Model
• The ER-Model (Entity-Relationship Model) is a high-level conceptual data
model used for designing databases.
• It is a diagram that represents relationships among entities in a database.
• The ER model serves as a blueprint for the design of a database, helping
database designers to understand the organization of data before
implementing it in a relational database.
DBMS 30
E-R Diagram
Key Concepts of ER-Model
1. Entity:
An entity represents an object or a thing in the real world that has a distinct
existence. For example, in a university database, entities could be Student,
Course, Professor, etc.
2. Entity Set:
An entity set is a collection of similar entities. For example, all students in a
university form the Student entity set.
3. Attribute:
Attributes are properties or characteristics of an entity. Each attribute represents
a piece of data about the entity.
DBMS 31
E-R Diagram
Key Concepts of ER-Model
4. Relationship:
• A relationship describes how entities are related to one another.
For example, a Student entity may be related to a Course entity
through an Enrolls relationship, indicating that a student enrolls in
a course.
• There are three types of relationship
– One to one relationship
– One to many relationship
– Many to may relationship
. DBMS 32
E-R Diagram
Key Concepts of ER-Model
DBMS 33
E-R Diagram
Key Concepts of ER-Model
DBMS 34
E-R Diagram
Key Concepts of ER-Model
DBMS 35
E-R Diagram
• E-R Diagram(Entity-Relationship Diagram) Symbols used in ER-Diagram
DBMS 36
ER-Diagram (Examples)
DBMS 37
Database Model
DBMS 38
Hierarchical Model
DBMS 40
Features Hierarchical Model
DBMS 41
Limitation of Hierarchical Model
• Complexity in Relationships: The hierarchical model is based on a tree
structure, where each record has a single parent.
• Rigidity: The structure of a hierarchical database is rigid, meaning that
changes in the data structure can be complex and costly.
• Redundancy: Since each child node can only have one parent, the
hierarchical model can lead to redundancy when the same data needs to be
associated with multiple parent records.
• Difficult Navigation: To retrieve data in a hierarchical database, you often
need to navigate through the entire tree structure, which can be time-
consuming and inefficient, especially for large databases.
DBMS 42
Network Model
DBMS 44
Features of Network Model
• Graph Structure: The network model uses a graph structure to represent
data. It consists of nodes (also called records) and edges (also called sets)
that define the relationships between nodes.
• Many-to-Many Relationships: The network model allows many-to-many
relationships between records, which is one of its most significant
advantages over the hierarchical model.
• Data Independence: The network model provides a degree of data
independence, allowing the physical storage of data to be separated from its
logical representation.
• Efficient Data Retrieval: The use of pointers and predefined relationships
allows for efficient data retrieval.
DBMS 45
Limitation of Network Model
• Complexity: The network model is more complex to design, implement, and
maintain compared to other database models, such as the relational model.
• Difficult Navigation and Querying: The explicit use of pointers requires that
users have a good understanding of the database structure to navigate and
query the data effectively.
• Maintenance Overhead: The complexity of the network model increases the
maintenance overhead.
• Learning Curve: The network model has a steep learning curve for
database designers and users.
DBMS 46
Relational Database Model
DBMS 47
Relational Database Model
DBMS 48
Features of relational database
DBMS 49
Limitation of Relational
database
• Complexity in Handling Unstructured Data: The relational
model is designed to handle structured data organized in tables.
• Scalability Issues: Relational databases can face challenges
when scaling horizontally (across multiple servers).
• Performance Bottlenecks: As the volume of data grows,
relational databases can experience performance bottlenecks.
• Cost of Scaling and Maintenance: As relational databases grow
in size and complexity, the cost of scaling, maintaining, and
optimizing them can increase significantly.
DBMS 50
Schema And Instances
DBMS 51
Schema And Instances
DBMS 52
Centralized Vs. Distributed
Database
• A centralized database, as the name suggests, is a
single database system that stores and manages all the
data in one location. It is typically hosted on a single
server or a cluster of servers within a single physical
location.
• A distributed database, on the other hand, is a database
system that stores and manages data across multiple
physical locations or servers.
DBMS 53
Difference between centralized and
distributed database
S.N centralized Database Distributed Database
DBMS 55
DDL (Data Definition Language)
DBMS 57
DML commands
DBMS 58
Difference between DDL and
DML
S.N DDL DML
1 It stands for Data Definition Language. It stands for Data Manipulation Language.
2 It basically defines the column (Attributes) of the It adds or updates the row of the table. These
table. rows are called tuples.
3 Basic commands present in DDL are CREATE, BASIC commands present in DML are
DROP, RENAME, ALTER, etc. UPDATE, INSERT, MERGE etc.
4 DDL is used to define the structure of a DML is used to manipulate the data within the
database. database.
5 DDL statements are typically executed by DML statements are typically executed by
database administrators. application developers or end-users.
59
Database Security
DBMS 60
Database Security
DBMS 61
Database Security
DBMS 62
Database Security
DBMS 63
Database Security
DBMS 64
Concept of Normalization: 1NF,
2NF, 3NF
• Normalization is the process of organizing the data in the database.
• Normalization is used to minimize the redundancy from a relation or set
of relations.
• It is also used to eliminate undesirable characteristics like Insertion, Update,
and Deletion Anomalies.
• Normalization divides the larger table into smaller and links them using
relationships.
• The normal form is used to reduce redundancy from the database table.
DBMS 65
1NF
DBMS 66
1NF (Example)
Here in the given table, two employees Ram and Shayam have two mobile
numbers. This table in not in 1NF as rule says that each table attribute must
have atomic value and attribute must be dependent on primary key.
DBMS 67
1NF (Example)
• So to make the above table to be in 1NF, we should have data like this:
DBMS 68
2NF
DBMS 69
3NF
DBMS 70
Question Of Normalization
• UnNormalized Table
Teacher Subject Age Address
DBMS 71
1NF
DBMS 72
2NF
t_ID Teacher Age Address
1.Table should be in 1NF 1 Ram 28 Jhapa
2 Gita 29 Pokhara
2.Introduction of primary
3 Hari 30 Kathmandu
and foregin key to
eliminate functional t_id Subjects
1 Math
dependency. 1 Physics
3.there exit transitive 2 English
functional 3 Nepali
dependency. in 2NF.
DBMS 73
3NF
DBMS 75
Qualities of DBA
DBMS 77
Some Important terms
Data dictionary:
• A data dictionary is a file which contains meta-data that is
data about data. It also called information system
catalogue.
• It keeps all the data information about the database
system such as location, size of the database, tables,
records, fields, user information, recovery system, etc.
DBMS 78
Some Important terms
Data Integrity:
• Data integrity refers to the accuracy, consistency, and
reliability of data throughout its lifecycle.
• It ensures that data is complete, accurate, and maintained
in a way that prevents unauthorized access, accidental or
intentional corruption, and loss.
DBMS 79
Some Important terms
DBMS 80
Some Important terms
DBMS 81
Some Important terms
DBMS 82
END Of Slide
DBMS 83