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

Unit 1

basic introductin

Uploaded by

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

Unit 1

basic introductin

Uploaded by

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

Database

Management
System(DBMS)
🠶 Unit 1:Introduction to DBMS,Data
Models

🠶 Unit 2:E-R Model,Relational Model

🠶 Unit 3:SQL(Structured Query Language)

🠶 Unit 4:Schema Refinement

🠶 Unit 5:Transaction Management and


Concurrency Control
Introduction to
DBMS
UNIT-I
Unit I
► Overview
► File system vs DBMS
► Advantages of DBMS
► Storage data
► Queries
► Transaction management
► DBMS structure
► Data modelling and data models
► The importance of data models
► Data model basic building blocks
► The evolution of data models
► Degree of data abstraction
Introduction to DBMS

► Data: Raw ,unprocessed facts like


traditional data(text,numbers) or
multimedia(Images,Videos,Audios)

► Ex:25,Suman,Hyderabad

► Ex: Flipkart,Ola,Youtube

► Information: Processed or meaningful


data
► Ex: The age of suman is 25
Data & Information

Data Information
Input for computer system Output of data

Unprocessed facts Processed data

Doesn’t depend on Depends on data


information
Not specific Specific

doesn’t carry a meaning Group of data carrying


logical meaning
INFORMATION

🠶 Information is the knowledge communicated or


received concerning a particular fact or
circumstance.
University Database

Example
Application program examples
 Add new students, instructors, and courses
 Register students for courses, and generate class
rosters
 Assign grades to students, compute grade point
averages (GPA) and generate transcripts
 In the early days, database applications were built directly
on top of file systems
File System
Approach
🠶 Disadvantages of File system

1. Data redundancy and inconsistency


2. Difficulty in accessing data
3. Data isolation
4. Integrity Problems
5. Atomicity
6. Concurrent access
7. Security Problems
Drawbacks of using file systems to store data

 Data redundancy and inconsistency


 Multiple file formats, duplication of information in different
files
 Difficulty in accessing data
 Need to write a new program to carry out each new task
 Data isolation
 Multiple files and formats
 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
 Atomicity of updates
 Failures may leave database in an inconsistent state with
partial updates carried out
 Example: Transfer of funds from one account to another
should either complete or not happen at all
 Concurrent access by multiple users
 Concurrent access needed for performance
 Uncontrolled concurrent accesses can lead to
inconsistencies
 Example: Two people reading a balance (say 100) and
updating it by withdrawing money (say 50 each) at the
same time
 Security problems
 Hard to provide user access to some, but not all, data

Database systems offer solutions to all the above problems


Database & DBMS

Database: Collection of Inter-related


data which is used to retrieve ,insert and
delete data efficiently.
Ex: College Database

DBMS = Database + Set of Programs


DBMS

► DBMS is a software which is used to manage


database.
► DBMS is a collection of data and set of programs
to access and store the data in an easy and
efficient way.
Designers

Users

Database

Apps
USERS
🠶 A typical DBMS has users with different rights and
permissions who use it for different purposes.

🠶 Administrators − Administrators maintain the DBMS and are


responsible for administrating the database.

🠶 Designers − Designers are the group of people who actually


work on the designing part of the database.

🠶 End Users − End users are those who actually reap the benefits
of having a DBMS.
ADVANTAGES OF DBMS
🠶 Data Independence
🠶 Reducing Data Redundancy
🠶 Sharing of Data
🠶 Efficient data access
🠶 Data integrity
🠶 Concurrent access
🠶 Data Security
🠶 Privacy
🠶 Backup & Recovery
🠶 Data Consistency
Examples of DBMS

🠶 IBM DB2
🠶 Microsoft Access
🠶 Mongo DB
🠶 Microsoft SQL Server
🠶 MySQL
🠶 Oracle RDBMS
🠶 Sybase
🠶 Informix
🠶 Postgres
DBMS Applications

 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 can be very large.
 Databases touch all aspects of our lives
Disadvantages of DBMS

1. DBMS S/w & H/w Cost is HIGH


2. Processing overhead for implementation of security, Integrity
and sharing of DATA.
3. Centralized DB control
4. Setup DBS requires more knowledge, money, skills and time
5. Complexity of the DB may result in poor performance.
File System Vs DBMS
Functions of DBMS

• Defining database schema


• Manipulation of the database
• Sharing of database
• Protection of database
• Database Recovery
The Database System is further divided into
threecomponents. They are as follows:

1. Data Storage Manager


2. Query Manager
3. Transaction Management
Data Storage Manager
Data Storage Manager also known as “Database Control
System”, is generally a program that provides an interface
between the data/information stored and the queries
received. It helps us to maintain the integrity and
consistency of the database by applying the constraints. It
is a highly flexible and scalable product that provides us
with the capability of fully managed storage.

Authorization and Integrity Manager: The main purpose of


the Authorization and Integrity Manager is to ensure the
satisfaction of the integrity constraints and checks the
authority of users to access information.

Transaction Manager: The main purpose of Transaction


Manager is to ensure that even after the system failures,
the database should remain in a uniform state.

File Manager: The main purpose of File Manager is to


manage the allocation of space on the disk storage.

Buffer Manager: The main purpose of Buffer Manager is to


fetch the data from disk storage into the main memory
Queries in DBMS
• A query is a statement requesting the retrieval of
information.
• The portion of a DML that involves information
retrieval is called a query language.
• A DBMS provides a specialized language, called the
query language, in which queries can be posed.
Types of queries in DBMS

 Data definition language queries (DDL)


 Data manipulation language queries (DML)
 Data control language queries (DCL)
 Transaction language queries (TCL)
DBMS Queries
Data definition language queries
(DDL)

🠶 CREATE- creates object in the database and creates a


table.
🠶 DROP- removes entire database object from the
database.
🠶 ALTER- alter or modify the structure and adds
additional columns, drops existing column and change
datatype of column.
🠶 RENAME- rename an object and database table.
🠶 TRUNCATE- delete all the rows from the table
permanantly.
Data Manipulation language
queries (DML)

1. INSERT: Used to add new records to a database


table.
2. UPDATE: Used to modify existing records in a
database table.
3. DELETE: Used to delete existing records from a
database table.
4. SELECT: Used to retrieve data from one or more
tables in a database.
DCL queries
DCL has only two SQL statements:
• GRANT
• REVOKE
1) GRANT Statement
GRANT grants users certain permissions. You can use the
following syntax to run the command:
Syntax: GRANT type_of_permission ON database_name.table_name TO
'@username'@'localhost‘

You can grant a certain type of permission using this line of code,
such as full or partial access to the resources in a specific data table.
2) REVOKE Statement
The REVOKE clause is used to revoke database user permissions and
privileges.Their syntax, however, is identical:
Syntax : REVOKE type_of_permission ON database_name.table_name FROM
username'@'localhost‘

Essentially, you can cancel a privilege from someone instead of


providing them permission.
WHAT IS A TRANSACTION

Transaction is a logical unit of work on a database

1. An entire program
2. A portion of a program
3. A single command

EXAMPLES OF A TRANSACTION

4. Updating a Record
5. Locate the Record on Disk
6. Bring record into Buffer
7. Update Data in the Buffer
8. Writing Data Back to Disk
Consider the following example of transaction
operations to be performed to withdraw cash from
an ATM vestibule.
Steps for ATM Transaction
1. Transaction Start.
2. Insert your ATM card.
3. Select a language for your transaction.
4. Select the Savings Account option.
5. Enter the amount you want to withdraw.
6. Enter your secret pin.
7. Wait for some time for processing.
8. Collect your Cash.
9. Transaction Completed.
All instructions before committing come under a partially committed
state and are stored in RAM. When the commit is read the data is
fully accepted and is stored on a Hard Disk.
If the transaction is failed anywhere before committing we have to go
back and start from the beginning. We can’t continue from the same
state. This is known as Roll Back.
A transaction can include the following basic database access operation.
Read/Access data (R): Accessing the database item from disk (where the database stored
data) to memory variable.
Write/Change data (W): Write the data item from the memory variable to the disk.
Commit: Commit is a transaction control language that is used to permanently save the
changes done in a transaction
Example: Transfer of 50₹ from Account A to Account B. Initially A= 500₹, B= 800₹.
Properties of
transaction
 Atomicity. Either all operations of the transaction are properly
reflected in the database or none are.
 Consistency. Execution of a transaction in isolation preserves
the consistency of the database.
 Isolation. Although multiple transactions may execute
concurrently, each transaction must be unaware of other
concurrently executing transactions. Intermediate transaction
results must be hidden from other concurrently executed
transactions.
• That is, for every pair of transactions Ti and Tj, it appears to
Ti that either Tj, finished execution before Ti started, or Tj
started execution after Ti finished.
 Durability. After a transaction completes successfully, the
changes it has made to the database persist, even if there are
system failures.
Desirable Properties of Transaction
(ACID Properties)
For a transaction to be performed in DBMS, it must possess several properties
often called ACID properties.
• A – Atomicity
• C – Consistency
• I – Isolation
• D – Durability
DBMS STRUCTURE
Query processor:
It consists of DDL(Data Definition Language) interpreter, DML(Data
Manipulation Language) compiler and query evaluation engine.
The following are various functionalities and components of query processor
• DDL interpreter: This is basically a translator which interprets the DDL
statements in data dictionaries.
• DML compiler: It translates DML statements query language into an
evaluation plan. This plan consists of the instructions which query
evaluation engine understands.
• Query evaluation engine: It executes the low-level instructions
generated by the DML compiler.
When a user issues a query, the parsed query is presented to a query
optimizer, which uses information about how the data is stored to produce
an efficient execution plan for evaluating the query. An execution plan is a
blueprint for evaluating a query. It is evaluated by query evaluation engine.
Storage manager:
Storage manager is the component of database system that provides
interface between the low level data stored in the database and the
application programs and queries submitted to the system.
The storage manager is responsible for storing, retrieving, and updating
data in the database. The storage manager components include
• Authorization and integrity manager: Validates the users who
want to access the data and tests for integrity constraints.
• Transaction manager: Ensures that the database remains in
consistent despite of system failures and concurrent transaction
execution proceeds without conflicting.
• File manager: Manages allocation of space on disk storage and
representation of the information on disk.
• Buffer manager: Manages the fetching of data from disk storage
into main memory. The buffer manager also decides what data to
cache in main memory. Buffer manager is a crucial part of database
system.
Disk Storage

The Disk Storage in the Structure of DBMS represents


the space where data is stored. It has the following
components:
1. Files: These are responsible for storing the data.
2. Data Dictionary: It is the repository that maintains
the information of the database object and
maintains the metadata.
3. Indices: These are the keys that are used for faster
retrieval of data.
Types of Databases
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.

• An example of a Centralized database can be Central


Library that carries a central database of each library in a
college/university.
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. E.F. Codd invented the
database in 1970.

• Examples of Relational databases are MySQL, Microsoft


SQL Server, Oracle, etc.
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.

• There are numerous cloud platforms, but the best


options are:
• Amazon Web Services(AWS)
• Microsoft Azure
• Kamatera
• PhonixNAP
• ScienceSoft
• Google Cloud SQL, etc.
DATA MODELS
Data Models

• It is a graphical model, which includes entities, attributes and


relationships among the entities.
• Describes the logical structure of a database.
• It gives an idea of how the final system looks like after its
complete implementation.
• Used to show how data is stored, connected, accessed and
updated in the DBMS.
• Set of symbols and text are used to represent the information.
• E.g: blueprint of a car or house
• Plan for database design
• Data Model
• Data modelling is a way to organize and join data
together for the purpose of data analysis.

• It defines how data is connected to each other and how


they are processed and stored inside the system.
Objectives

In this module, we have:


1. About data modeling and why data models are important
2. About the basic data-modeling building blocks
3. What are business rules and how they influence database
design
4. How the major data models evolved
5. How data models can be classified by level of abstraction
Data Modeling and Data Models

• Data modeling – the first step in designing a


database, refers to the process of creating a specific
data model for a determined problem domain.
• Problem domain – is a clearly defined area within
the real-world environment, with well-defined scope
and boundaries, that is to be systematically
addressed.
• Database Models - Collection of logical constructs
used to represent data structure and relationships
within the database.
Importance of data models

• Data models can facilitate interaction among the


designer, the applications programmer, and the
end user.

• A well-developed data model can even foster


improved understanding of the organization for
which the database design is developed.

• Data models are a communication tool


Important for your applications to have a
good
data model:

a) Higher Quality Applications


b) Reduced Cost & Time of Application Development
c) Early Detection of Data Issues & Errors
d) Better Documentation for long term maintenance
Phases involved in Data
Model
• Conceptual Data Model- high level
• Logical Data Model
• Physical Data Model- low level
Conceptual Data Model

• Also called as High level Data Model


• Defines WHAT the system contains
• Doesn’t focus on processing
• Created by Data Architects
• Highly abstracted
• Easily understood (even if the user is non-technical)
• Only entities are visible
• Abstract relationships
• Independent of either hardware /software
Logical Data Model
• HOW the system should be implemented regardless DBMS.
• Created by Data Architects and Business Analysts.
• Used to define the structure of data elements and to set
relationships between them.
• It adds further information to Conceptual Data Model.
• Presence of attributes for each entity.
• Key Attributes & Non- Key Attributes.
• User friendly attribute names
• More effort required to understand, than CDM
• Developed using Data Modeling tools like erwin or Power
Desiger softwares.
Physical Data Model
• Describes “HOW” the system is implemented using a specific
DBMS.
• Dependent on DBMS software.
• Created by DBA and developers.
• Actual implementation of database.
• Low-level data model- describes how data is stored on the
physical storage.
• Difficult to understand.
• Entities- tables, attributes- columns
• Database compatible table/column names
• Database specific datatypes
• Include indexes, constraints, triggers and other database
objects
• Difficult to port to a different database, once design is
completed.
Data model basic building blocks
• The basic building blocks of all data models are
• Entities
• Attributes
• Relationships
• Constraints.
Entity
- is anything (a person, a place, a thing, or an event)
about which data are to be collected and stored.
- represents a particular type of object in the real world.
Example:
CUSTOMER entity would have many distinguishable
customer occurrences, such as Juan Dela Cruz, Pedro
Dinamita, Tom Cruz, etc
Attribute
- a characteristic of an entity.
- are the equivalent of fields in file systems.

Example:

CUSTOMER entity would be described by attributes


such as
1. customer last name
2. customer first name
3. customer phone
4. customer address
5. customer credit limit
4 types of relationships used in data models:
1.) one-to-one (1:1) – only one entity can have a relationship with
another entity.
Example: One person has one passport, and the passport can only be
used by one person
2.) one-to-many (1:M) – one entity can have more than one of that
type of relationship.
Example: A painter paints many different paintings, but each one of
them is painted by only one painter.
Thus, the PAINTER (the “one”) is related to the PAINTINGS (the
“many”).
3.) one-to-many (M:1) – more number of entities can have one
relationship
Ex: Food ordering: Many dishes ordered by single customer
4.) many-to-many (M:N) – can have any number of relationships
with other entities.
Example: A student can take many classes and each class can be
taken by many students, thus yielding the M:N relationship “STUDENT
takes CLASS.”
Constraints
- a restriction placed on the data.
- Constraints are important because they help to ensure data
integrity.
- Constraints are normally expressed in the form of rules.
Example of constraints:
• An employee’s salary must have values that are between
6,000 and 350,000.
• A student’s GPA must be breather than 7.5 for campus
placements
• Each class must have only one CR
Building blocks of Data Models

1. Entities – is an object about which we want to collect and store


the data. It can be living/non-living thing.
2. Attributes– characteristics/features of an entity.
3. Relationships– meaningful association between 2 or more
entities
E.g: Students learn course
customer places order
Types of Relationships:
• One-to-one (1:1) Relationship—e.g: Patient vs Bed
• One-to-many(1:M) Relationship--- e.g: Customer vs Order
• Many-to-one(M:1) Relationship--- e.g: order vs customer
• Many-to-Many(M:M) Relationship – e.g: Students vs courses
4. Constraints– rule/ restriction placed on the data elements.Used
for data integrity.
e.g: salary, d.o.b, age
EVOLUTION OF DATA MODELS

Types of Data Models

1. Hierarchical Model

2. Network Model

3. Entity-relationship Model

4. Relational Model

5. Object-Oriented(OO) Model
Hierarchical
model
The hierarchical model classifies the data into a tree-like
structure with a single parent or root for each record. Sibling
records are arranged in a certain sequence. This is the physical
order in which the database is stored. This model is useful for
explaining a wide range of real-world interactions.

Database Management
It depicts a set of 1:M relationships between a parent and its children
segments
Dr. Jay Sarraf, School of Computer Engineering, KIIT Deemed to be
Hierarchical
model

Advantages of Hierarchical
Model
• It is very simple and fast to traverse through a tree-
like
structure.

Database Management
• Any change in the parent node is automatically
reflected in the child node so, the integrity of data
is maintained.
Disadvantages of Hierarchical
Model
• Complex relationships are not supported.

• As it does not support more than one parent of the


child node so if we have some complex relationship
where a child node needs to have two parent node
then that can't be represented using this model.

• If a parent node is deleted then the child node is


automatically deleted.

Dr. Jay Sarraf, School of Computer Engineering, KIIT Deemed to be


Network
Model

This paradigm is an expansion of the hierarchical model. It was


the most prevalent model prior to the relational model. The main
difference between this model and the hierarchical approach is
that a record can have several parents. It replaces the
hierarchical tree with a graph. In the sample below, we can see
that node student has two parents, CSE Department and Library.
This was previously not allowed in the hierarchical model.

Dr. Jay Sarraf, School of Computer Engineering, KIIT Deemed to be


Network Model

Advantages of Network
Model
• When compared to the hierarchical approach, data may be obtained
more quickly. This is because the data in the network model is more
linked and there may be more than one path to a certain node. As a

Database Management
result, the information may be accessed in a variety of ways.

• Data integrity is present since there is a parent-child connection. Any


changes
made to the parent record are mirrored in the child record.

Disadvantages of Network
Model
• As additional relationships are added, the system may get
increasingly complicated. To operate with the model, a user needs
have full understanding of it.

• Any modification, such as an update, deletion, or insertion, is quite


difficult.

Dr. Jay Sarraf, School of Computer Engineering, KIIT Deemed to be


Entity-Relationship
Model

The Entity-Relationship Model, sometimes known as the ER Model, is a


high-level data model diagram. We express the real-world problem in
visual form in this model to make it easier for stakeholders to grasp.
The ER diagram also makes it extremely simple for developers to

Database Management
comprehend the system. The ER diagram is a visual tool used to
depict an ER Model. The ER diagram is made up of three parts:

Dr. Jay Sarraf, School of Computer Engineering, KIIT Deemed to be


Entity-Relationship
Model
Advantages of Entity-Relationship Model
• Simple: Conceptually ER Model is very easy to build. If we know the
relationship between the attributes and the entities we can easily
build the ER Diagram for the model.

• Effective Communication Tool : This model is used widely by the

Database Management
database designers for communicating their ideas.

• Easy Conversion to any Model : This model maps well to the relational
model and can be easily converted relational model by converting
the ER model to the table. This model can also be converted to any
other model like network model, hierarchical model etc.

Disadvantages of Entity-Relationship Model


• No industry standard for notation: There is no industry standard for
developing an ER model. So one developer might use notations
which are not understood by other developers.

• Hidden information: Some information might be lost or hidden in the


ER model. As it is a high-level view so there are chances that some
details of information might be hidden.

Dr. Jay Sarraf, School of Computer Engineering, KIIT Deemed to be


Relational
Model

The most common model is the Relational Model. The data in this
model is kept in the form of a two-dimensional table. All data is
saved in the form of rows and columns. Tables are the foundation
of a relational paradigm. In the relational paradigm, the tables are

Database Management
also referred to as relations. Example: We have an Employee
table in this example.

Dr. Jay Sarraf, School of Computer Engineering, KIIT Deemed to be


Relational Model

Advantages of Relational Data


Model
• Simple: This model is more simple as compared to the
network and hierarchical model.

• Scalable: This model can be easily scaled as we can add as

Database Management
many rows and columns we want.

• Structural Independence: We can make changes in database


structure without changing the way to access the data. When we
can make changes to the database structure without affecting the
capability to DBMS to access the data we can say that structural
independence has been achieved.
Disadvantages of Relational Data
Model
• Hardware Overheads: For hiding the complexities and making things
easier for the user this model requires more powerful hardware
computers and data storage devices.

• Bad Design: As the relational model is very easy to design and use.
So the users don't need to know how the data is stored in order to
access it. This ease of design can lead to the development of a poor
database which would slow down if the database grows.

Dr. Jay Sarraf, School of Computer Engineering, KIIT Deemed to be


Object-Oriented(OO)
Model
A database, according to this paradigm, is a collection of
objects, or reusable software parts, with related
characteristics and operations.
• Object-oriented databases are classified into numerous types: A multimedia
database contains media, such as photos, that would be impossible to store in

Database Management
a relational database.

• Any object in a hypertext database can link to any other object. It is effective
for organizing a large amount of heterogeneous data, but it is not perfect for
numerical analysis.

• Because it integrates but is not limited to tables, the object-oriented database


model is the most well-known post-relational database paradigm. These types
of models are often known as hybrid database models.

OODs are most often used with object-oriented programming languages like Java, Kotlin, C#, Node JS
(React), and Swift.
Dr. Jay Sarraf, School of Computer Engineering, KIIT Deemed to be
Object-Oriented(OO)
Model
Advantages of Object Oriented Data
Model
• Complex data sets can be saved and retrieved quickly and easily.

• Object IDs are assigned automatically.

• Works well with object-oriented programming languages.

Database Management
• Semantic content is added

• Support for complex objects

• Visual representation includes semantic content

Disadvantages of Object Oriented Data


Model
• Object databases are not widely adopted.

• In some situations, the high complexity can cause performance


problems.

• High system overheads slow transactions.

Dr. Jay Sarraf, School of Computer Engineering, KIIT Deemed to be


Levels of Abstraction

There are mainly 3 levels of data abstraction:

• Physical or Internal Level


• Logical or Conceptual Level
• View or External Level
Levels of Abstraction

•It is a 3–level/schema
architecture.

•It is used to separate the user


applications and physical
database.

•It breaks the database down into


three different categories /levels.
Internal/physical level
• Describes the physical storage
structure of the database.

• Defines how the data will be stored in a


block

• Describes complex low-level data


structures in detail.
Conceptual/logical Level
• Describes the structure of the whole
database.

• Describes what data are to be stored in


the database and also describes what
relationship exists among those data.

• Internal details such as an


implementation of the data structure are
hidden.

• Programmers and database


administrators work at this level.
Data Independence

Data Independence is mainly defined as a property of DBMS that helps you to


change the database schema at one level of a system without requiring to
change the schema at the next level. it helps to keep the data separated from
all program that makes use of it.

We have namely two levels of data independence arising from these levels of
abstraction:
• Physical level data independence
• Logical level data independence
Logical Data Independence:

If we do any changes in the conceptual view of the data, then the


user view of the data would not be affected.

Physical Data Independence

If we do any changes in the storage size of the database system


server, then the Conceptual structure of the database will not be
affected.

You might also like