Unit 1 Dbms Part1
Unit 1 Dbms Part1
1
In a daily life, we come across various needs to store data. It can be maintaining
daily household bills, bank account details, salary details, payment details, student
information, student reports, books in the library etc. How it will be recorded at
one place, so that we can get it back when required? It should be recorded in such
a way that
1 XYZ 55 66 77
198
2 NML 42 51 61
Student = 154
3 ABC 37 56 66
159
4 PQR 56 68 72
196
5 IJK 47 57 67
171
. 2
Basic Concept
•Database Applications:
• Banking: transactions
• Airlines: reservations, schedules
• Universities: registration, grades
• Sales: customers, products, purchases
• Online retailers: order tracking, customized recommendations
• Manufacturing: production, inventory, orders, supply chain
• Human resources: employee records, salaries, tax
deductions
•Databases touch all aspects of our lives
3. Data isolation
4. Integrity problems
5. Atomicity problem
7. Security problems
8
File system v/s Database system
1. Data redundancy and inconsistency
• Multiple file formats, created by different programmers,
duplication of information in different files..
• This redundancy leads to higher storage and may leads to inconsistency.
9
DBMS Maintains ACID properties, ensuring valid and consistent data after
transactions.
In DBMS, data isolation means keeping data separate between transactions to ensure
integrity, but it is well organized and accessible through queries.
12
File system v/s Database system
4. Integrity problems
• Integrity constraints (e.g., account balance > 0) become “buried” in program
code rather than being stated explicitly
• Hard to add new constraints or change existing ones
• Example:
ACCOUNT: A
1000
Error Msg.: No sufficient balance
14
Atomicity refers to completion of whole transaction or not completing it at all. Partial completion of
any transaction leads to incorrect data in the system. File system does not guarantee the atomicity.
It may be possible with complex programs, but introduce for each of transaction costs money.
DBMS ensures that if a failure occurs, the transaction is rolled back to its previous
state—no partial updates.
Managed through transaction logs, undo operations, and ACID properties (Atomicity,
Consistency, Isolation, Durability).
When updating a customer’s account and logging the transaction, either both actions are
committed or neither is.
Full support for atomic transactions via commands like BEGIN, COMMIT, ROLLBACK.
File system v/s Database system
6. Concurrent access by multiple users
• Concurrent access needed for performance
• Uncontrolled concurrent accesses can lead to inconsistencies
• Example: Two people reading a balance and updating it by withdrawing money at the
same time
16
File system v/s Database system
6. Concurrent access by multiple users Example Cont..
17
Accessing the same data from the same file is called concurrent access. In the file system, concurrent
access leads to incorrect data. For example, a student wants to borrow a book from the library. He
searches for the book in the library file and sees that only one copy is available. At the same time
another student also, wants to borrow same book and checks that one copy available. First student opt
for borrow and gets the book. But it is still not updated to zero copy in the file and the second student
also opt for borrow! But there are no books available. This is the problem of concurrent access in the
file system.
In file system Locks are usually applied to entire files, not specific data items.
Two programs editing the same file might overwrite each other’s data if no lock is used.
In DBMS Uses sophisticated techniques like locking protocols, timestamp ordering,
multiversion concurrency control (MVCC).
Automatically managed by the DBMS — no need for manual coding.
Two users updating different rows of the same table can do so simultaneously without conflict.
If they update the same row, one will wait or retry.
7. Security problems
It is difficult to enforce security constraints using file processing system
Each file can be password protected. But what if have to give access to only few records in the file? For
example, user has to be given access to view only their bank account information in the file. This is very
difficult in the file system.
Relies entirely on the operating system’s login credentials. No custom user management.
Not built-in; encryption must be handled manually by the application.
Any user with file access can modify or delete all contents, even if only limited access is
required.
In DBMS
Provides role-based access with fine-grained control over tables, rows, and even columns.
permissions can be set per user, table, column, or operation (SELECT, INSERT, etc.).
Supports data-at-rest and in-transit encryption natively in most modern DBMSs.
A user can be allowed to view only salary data without being able to update or delete it.
Data abstraction
•To hide certain details from user that how the data is stored and
maintained.
21
Data abstraction
•Physical Level:
• It is the lowest level of abstraction
• It describe how the data is actually
stored and describes the data structure
and access methods to be used by the
database. i.e (files, indices, et al.).These
information are usually the basic
storage information of any computer.
• It is also called as internal level.They are
least known to any programmer.
22
Example
1 XYZ 55 66 77
198
2 NML 42 51 61
Student = 154
3 ABC 37 56 66
159
4 PQR 56 68 72
196
5 IJK 47 57 67
171
• Example
• In a STUDENT table example, records of each student which user sees are view
level of information. Columns, their data types, their mapping, and constraints
like primary key, foreign key information are the logical level of information. The
actual structure of table and data are stored in the server’s memory. This is
physical level of information.
• Physical level of abstraction is the lowest level of abstraction and view level of
abstraction is the highest level of abstraction. Based on these levels of
abstraction, we have two types of data independence.
• Suppose there was a change in memory size of the database servers. This will
not affect the logical structure of any of the objects in the database. They are
completely independent of the physical structure. This is called physical data
independence.
Data Independence
•The abilityto modify a schema definition in one level
without affecting schema definition in the next higher level.
•Types of Data Independence:
32
•Any changes to the database objects like changes to table structure, size or
addition/removal of columns from the table will not affect user views. They will see
the data like before. This is called logical data independence.
• By these two types of data independence, the isolation between the physical and
logical layer is achieved. This helps in reducing the time and cost acquired by
changes in any one level in the database. Hence, the main purpose of database to
provide abstract view of data is achieved.
•
Instances and Schema
•Instance: Collection of information stored in the database
at a particular moment of time is called as instance of db.
•Schema: The overall design of the database is called as schema.
34
Types of Schema:
• Physical Schema : Schema at Physical level.
• Conceptual Schema: Schema at Conceptual level.
• View Schema: Schema at view level also called as sub schema.
• Example: Title, Author, Title, Author, Publication Year
Member Name, Address, Phone Number
Book:
● Attributes: ISBN (Primary
Key), Title, Author,
Conceptual level/Schema Er-Digram/structure Publication Year
design Author:
● Attributes: AuthorID
(Primary Key), Author Name
LibraryMember:
● Attributes: MemberID
Files/Other Data (Primary Key), Member
Physical Level/Schema Structure/Indices
Name, Address, Phone
Number
35
Database Architecture
36
Database Users and Administrators
1. Naive User : are unsophisticated users who
interact with the system by invoking by one
of the application Ex. User who wishes to
find A/c balance.
39
Components of DBMS
•Components of DBMS is broadly
classified as :
Query processor
Storage Manager
Disk Storage
40
Components of DBMS
1. Query processor
I. DDL interpreter:
which interprets DDL statements
and records the definition.
II. DML Compiler:
Which translates DML statements in
a query language and then to low
level instructions.
41
Components of DBMS
2. Storage Manager:
-is a program module that provides
interface between low level data
stored & query processor.
42
Components of DBMS
•Storage Manager:
• File Manager: which manages the allocation
of space on disk.
• Data Dictionary :
• stores metadata. i.e. data about data
• Indices :
• which provides fast access to data items.
44
Characteristics of Database
1. Concurrent Use :
A database system allows several users to access the database concurrently.
2. Structured and Described Data :
database systems does not only contain the data but also the complete definition and
description of these data. i.e. metadata ("data about data").
3. Separation of Data and Applications :
via a standardized interface with the help of a standardized language like SQL.
4. Data Integrity :
Data integrity is a by word for the quality and the reliability of the data of a
database system.
5. Transactions :
Within a transaction all or none of the actions need to be carried out.
6. Data Persistence :
Data persistence means that in a DBMS all data is maintained as long as it is not deleted
explicitly.
45