Professional Documents
Culture Documents
DBMS Unit-1
DBMS Unit-1
Introduction
Veena Parihar
Database Management System
Veena Parihar
Purpose of Database Systems
Veena Parihar
Disadvantages of file systems
Veena Parihar
Data Redundancy and Inconsistency
Since different programmers create the files and application programs over a
long period, the various files are likely to have different structures and the
programs may be written in several programming languages.
Same information may be duplicated in multiple files.
Example- address and contact number
This redundancy leads to higher storage and access cost.
It may lead to data inconsistancy
Veena Parihar
Difficulty in accessing data
Veena Parihar
Data Isolation
Because data are scattered in various files, and files may be in different
formats, writing new application programs to retrieve the appropriate data is
difficult.
Veena Parihar
Integrity Problems
The data values stored in the database must satisfy certain types of
consistency constraints. For example, the balance of certain types of bank
accounts may never fall below a prescribed amount.
Developers enforce these constraints in the system by adding appropriate
code in the various application programs.
When new constraints are added, it is difficult to change the programs to
enforce them.
Veena Parihar
Atomicity problems
Veena Parihar
Concurrent access anamolies
For the sake of overall performance of the system and faster response, many
system allow multiple users to update the data simultaneously.
In that scenario, interaction of concurrent updates is possible and may result
in inconsistent data.
To guard against this possibility, the system must maintain some form of
supervision.
But this supervision is difficult to provide because data may be accessed by
many different application programs that have not been coordinated
previously.
Veena Parihar
Security Problems
Not every user of the database should be able to access all the data.
For ex, in a banking system, payroll personnel need to see only that part of
the database that has information about various bank employees. They do not
need access to information about customer accounts.
Since, application programs are added to the file systems in an ad hoc
manner, enforcing such security constraints is difficult.
Veena Parihar
View of data
Veena Parihar
Data Abstraction
The need for efficiency has led designers to use complex data structures to
represent data in the database.
Developers hide the complexity from users through several levels of
abstraction, to simplify users interaction with the system.
Physical level – the lowest level of abstraction describes how the data are actually
stored. It describes complex low level data structures in detail.
Logical level – The next higher level of abstraction describes what data are stored
in the database what relationships exist among those data. The logical level
describes the entire database in terms of a small number of relatively simple
structures.
View level – The highest level of abstraction describes only part of the entire
database. The view level exists to simplify users interaction with the system. The
system may provide many views for the same database.
Veena Parihar
Veena Parihar
1. Physical or Internal Level
It is the lowest level of abstraction for DBMSs, defining how data is stored, data
structures for storing data, and database access mechanisms. Developers or
database application programmers decide how to store data in the database. It is
complex to understand.
Example
The physical level, being the lowest level of abstraction, can be understood with
an example, like how information about a customer is stored in tables while the
data is stored in the form of blocks.
Another example of physical-level abstraction would be sequential file
organization due to the continuous storage of records. While in indexed file
organizations, we can access the records with the help of indexes.
Veena Parihar
2. Logical or Conceptual Level
The logical level is the next higher level or intermediate level. It explains what data is
stored in the database and how those data are related. It seeks to explain the complete
or entire data by describing what tables should be constructed and what the linkages
between those tables should be. It is less complex than the physical level.
Example
The logical level in DBMS is used for representing entities and relationships among
the data stored. For example, defining tables and their attributes and specifying
relationships between them. A table named ‘class’ may have different attributes like
student_name, Roll_no, student ID, and Marks.
A table named ‘IDs’ contains details about the address of the teacher's ID (foreign
key), and student ID (foreign key).
Veena Parihar
3. View or External Level
This is the top level. There are various views at the view level, with each view
defining only a portion of the total data. It also facilitates user engagement by
providing a variety of views or numerous views of a single database. All users
have access to the view level. This is the easiest and most simple level.
Example
The external level in DBMS defines a part of the entire data and simplifies
interaction with the user by providing multiple views of a similar database. For
example, interacting with a system using a graphical user interface (GUI) to
access an application's features. Here GUI is the view level, and the user does
not know how and what data is exactly stored, i.e hiding the details for the user.
Veena Parihar
Instances and Schemas
• The data which is stored in the database at a particular moment of time is called an
instance of the database.
• The overall design of a database is called schema.
• A database schema is the skeleton structure of the database. It represents the logical
view of the entire database.
• A schema contains schema objects like table, foreign key, primary key, views,
columns, data types, stored procedure, etc.
• A database schema is designed by the database designers to help programmers
whose software will interact with the database. The process of database creation is
called data modeling.
Veena Parihar
Data Models
Veena Parihar
Veena Parihar
Veena Parihar
Data Independance
Veena Parihar
1. Logical Data Independence
Veena Parihar
2. Physical Data Independence
Veena Parihar
DBMS Languages
Veena Parihar
1. Data Definition Language (DDL)
Veena Parihar
Here are some tasks that come under DDL:
Veena Parihar
2. Data Manipulation Language (DML)
DML stands for Data Manipulation Language. It is used for accessing and
manipulating data in a database. It handles user requests.
Here are some tasks that come under DML:
• Select: It is used to retrieve data from a database.
• Insert: It is used to insert data into a table.
• Update: It is used to update existing data within a table.
• Delete: It is used to delete all records from a table.
Veena Parihar
Data Control Language (DCL)
• DCL stands for Data Control Language. It is used to retrieve the stored or
saved data.
• The DCL execution is transactional. It also has rollback parameters.
(But in Oracle database, the execution of data control language does not have
the feature of rolling back.)
Here are some tasks that come under DCL:
• Grant: It is used to give user access privileges to a database.
• Revoke: It is used to take back permissions from the user.
Veena Parihar
4. Transaction Control Language (TCL)
TCL is used to run the changes made by the DML statement. TCL
can be grouped into a logical transaction.
Here are some tasks that come under TCL:
• Commit: It is used to save the transaction on the database.
• Rollback: It is used to restore the database to original since the
last Commit.
Veena Parihar
Database Architectures
1-Tier Architecture
• In this architecture, the database is directly available to the user. 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.
• The 1-Tier architecture is used for development of the local
application, where programmers can directly communicate with the
database for the quick response.
Veena Parihar
2-Tier Architecture
Veena Parihar
3-Tier Architecture
Veena Parihar
Symbols Used in ER Model
Veena Parihar
Veena Parihar
Components of ER Diagram
Veena Parihar
Veena Parihar
Veena Parihar
Veena Parihar
Veena Parihar
Veena Parihar
Veena Parihar
Veena Parihar
Relations
Veena Parihar
Veena Parihar
Keys
Veena Parihar
Veena Parihar
Primary key
It is the first key used to identify one and only one instance of an
entity uniquely. An entity can contain multiple keys, as we saw in
the PERSON table. The key which is most suitable from those lists
becomes a primary key.
In the EMPLOYEE table, ID can be the primary key since it is
unique for each employee. In the EMPLOYEE table, we can even
select License_Number and Passport_Number as primary keys
since they are also unique.
For each entity, the primary key selection is based on
requirements and developers.
Veena Parihar
Candidate key
Veena Parihar
Super Key
Veena Parihar
Foreign key
Foreign keys are the column of the table used to point to the primary key of
another table.
Every employee works in a specific department in a company, and employee
and department are two different entities. So we can't store the department's
information in the employee table. That's why we link these two tables
through the primary key of one table.
We add the primary key of the DEPARTMENT table, Department_Id, as a new
attribute in the EMPLOYEE table.
In the EMPLOYEE table, Department_Id is the foreign key, and both the tables
are related.
Veena Parihar
Veena Parihar
Alternate key
Veena Parihar
Composite key
Veena Parihar
Generalization
Generalization is a bottom-up approach
in which two lower level entities combine
to form a higher level entity. In
generalization, the higher level entity
can also combine with other lower level
entities to make further higher level
entity.
It's more like Superclass and Subclass
system, but the only difference is the
approach, which is bottom-up. Hence,
entities are combined to form a more
generalised entity, in other words, sub-
classes are combined to form a super-
class.
Veena Parihar
Specialization
Specialization is opposite to
Generalization. It is a top-down
approach in which one higher
level entity can be broken down
into two lower level entity.
In specialization, a higher level
entity may not have any lower-
level entity sets, it's possible.
Veena Parihar
Aggregation
Veena Parihar
Reduction of ER Diagram to Relationship
Schemas
Veena Parihar
Veena Parihar
Veena Parihar
Solution
Veena Parihar
Veena Parihar
Applying the rules, minimum 4 tables will be required-
• AR1R2 (a1 , a2 , b1 , c1)
• B (b1 , b2)
• C (c1 , c2)
• R3 (b1 , c1)
Veena Parihar
Veena Parihar
Veena Parihar
Veena Parihar
Veena Parihar
Assignment 1
1. Consider the relational database of Figure 2.14. What are the appropriate
primary keys.
Veena Parihar
Assignment 1
2. In the instance of
instructor shown in
Figure 2.1, no two
instructors have the
same name. From
this, can we
conclude that name
can be used as a
superkey (or primary
key) of instructor.
Veena Parihar
Assignment 1
Veena Parihar
Assignment 1
Veena Parihar
Assignment 1
Veena Parihar
Assignment 1
7. You are required to create a conceptual data model of the data requirements
for a company that specializes in IT training. The Company has 30 instructors and
can handle up to 100 trainees per training session. The Company offers five
advanced technology courses, each of which is taught by a teaching team of two
or more instructors. Each instructor is assigned to a maximum of two teaching
teams or may be assigned to do research. Each trainee undertakes one advanced
technology course per training session.
a. Identify the main entity types for the company.
b. Identify the main relationship types and specify the multiplicity for
each relationship. State any assumptions you make about the data.
c. Using your answers for (a) and (b), draw a single ER diagram to
represent the data requirements for the company.
Veena Parihar