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

DBMS_V.0 (1)

Uploaded by

Abhishek Chauhan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

DBMS_V.0 (1)

Uploaded by

Abhishek Chauhan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 92

1

2 Database Management System TCS-503


3
4
5 DBMS

 A database-management system (DBMS) is a collection


of interrelated data and a set of programs to access
those data.
 The collection of data, usually referred to as the
database, contains information relevant to an
enterprise.
 The primary goal of a DBMS is to provide a way to store
and retrieve database information that is both
convenient and efficient.
6 Database System Applications

 Banking
 Airlines
 Universities
 Telecommunication
 Finance
 Sales
 Manufacturing
 Etc.
7 Benefits of DBMS
 The amount of data redundancy in stored data can be
reduced.
 No more data inconsistencies.
 Stored data can be shared by a single user or multiple user.
 Standards can be set and followed.
 Data integrity can be maintained. Data integrity refers to the
problem of ensuring that database contains only accurate
data.
 Data independence can be achieved, i.e. data and
programs that manipulate the data are two different entities.
 Security of data can be simply implemented.
8 What is Relational Database
management System (RDBMS)?
A Relational database management system(RDBMS) is a
database management system (DBMS) that is based on
relational model as introduced by Dr. Edgar F. Codd.
Strictly speaking it should also satisfy Codd’s 12 rule, but in
pratice there is no DBMS that satisfy all these rules.
RDBMS stores data in the form of related tables. RDBMS are
powerful because they require few assumptions about
how data is related or How it will be extracted from the
database. As a result, the same database can be viewed
in many different ways.
9 RDBMS……
Today, popular commercial RDBMS for large databases include Oracle,
Microsoft SQL server, Sybase and IBM DB2.

The most commonly used free RDBMS are MySQL and PostgreSQL.
10 Dr. E. F. Codd’s Rules
for RDBMS
Dr. E.F. Codd was an IBM researcher who
first developed the relational data model in
1970. In 1985 Dr. E.F. Codd published a list of
12 rules that define an ideal relational
database and has provided a guide line for
the design of all relational database
systems.
Dr. Codd has used the term guideline
because till date no commercial relational
database system fully conforms to all 12
rules.
11 Rule 1: The Information Rule

All Data should be presented in table form.


12 Rule No. 2: Guaranteed Access Rule
All Data should be accessible without ambiguity. This can
be accomplished through the combination of table name,
primary key, and column name.
13 Rule No. 3: Systematic treatment of null
values
A field should be allowed to remain empty. This involves
the support of null value, which is distinct from an empty
string or a number with a value of zero. Of course this can
not apply to primary keys.
14 Rule No. 4: Dynamic online catalog
based on the relational model
A relational database must provide access to its structure through the same
tools that are used to access data. This is usually accomplished by storing the
structure definition within special system tables.
Rule No. 5: Comprehensive Data sub- 15
language Rule

The database must support at least one clearly


defined language that includes functionalities
for data definition, data manipulation, data
integrity and database transaction control. All
commercial and free databases use forms of
standard SQL as their supported
comprehensive language.
Rule No. 6: View
Updating Rule
Data can be presented in
different logical combinations
called views. Each view should
support the same full range of
data manipulation that has
direct access to a table
available.

16
17 Rule No. 7: High-level Insert, Update,
and Delete
Data can be retrieved from a relational database in sets constructed of data
from multiple rows and /or multiple tables. This rules states that insert, update
and delete operations should be supported for any retrievable set rather than
just for a single row in a single table.
Rule no. 8: Physical Data Independence 18

The user is isolated from the physical method of storing and


retrieving information from the database. Changes can be
made to the underlying architecture (hardware, disk storage
methods) without affecting how the user accessed it.
Rule No. 9: Logical Data Independence 19

How data is viewed should not be changed when the logical


structure (table’s structure) of the database changes. This rule
is particularly difficult to satisfy. Most databases rely on strong
ties between the data viewed and the actual structure of the
underlying tables.
Rule 10: Integrity Independence 20

The database language (like SQL) should support constraints


on user input that maintain database integrity. This rule is not
fully implemented by most major vendors. At a minimum, all
the databases do preserve two constraints through SQL. No
components of a primary key can have a null value. If a
foreign key is defined in one table, any value in it must exist as
a primary key in another table.
21 Rule no. 11: Distribution independence

A user should be totally unaware of whether


the database is distributed( parts of the
database exist in multiple locations ) or not.
A variety of reasons make this rule difficult to
implement.
Rule no. 12: Non subversion Rule

There should be no way to modify the database


structure other than through the multiple row
22
database language (like SQL). Most databases today
support administrative tools that allow some direct
manipulation of the data structure.
23
24 Database Systems versus File Systems

 This typical file-processing system is supported by a


conventional operating system.
 The system stores permanent records in various files, and
it needs different application programs to extract
records from, and add records to, the appropriate files.
 Before database management systems (DBMSs) came
along, organizations usually stored information in such
systems.
25 Disadvantages of file-processing System:

 Data redundancy and inconsistency.


 Difficulty in accessing data.
 Data Isolation and integrity problem.
 Atomicity problems.
 Concurrent Access Anomalies.
 Security Problems.
26 View of Data

 A database system is a collection of interrelated files


and a set of programs that allow users to access and
modify these files.
 A major purpose of a database system is to provide
users with an abstract view of the data.
 That is, the system hides certain details of how the data
are stored and maintained.
27 View of Data
28 Data Abstraction

 Since many database-systems users are not computer trained, developers


hide the complexity from users through several levels of abstraction, to
simplify users’ interactions with the system:
 Physical level. The lowest level of abstraction describes how the data are
actually stored. The physical level describes complex low-level data
structures in detail.
 Logical level. The next-higher level of abstraction
describes what data are stored in the database,
and what relationships exist among those data.
29  View level. The highest level of abstraction describes only part of the entire
database. Even though the logical level uses simpler structures, complexity
remains because of the variety of information stored in a large database.

The Three levels of abstraction


30 Data Independence

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


change the Database schema at one level of a database system without
requiring to change the schema at the next higher level.
 Data independence helps you to keep data separated from all programs
that make use of it.
 In DBMS there are two types of data independence
 Physical data independence
 Logical data independence.
Logical Data Independence vs Physical Data Independence
31
32 Instances and Schemas
 Databases change over time as information is inserted and deleted.
 The collection of information stored in the database at a particular
moment is called an instance of the database.
 The overall design of the database is called the database schema.
Schemas are changed infrequently, if at all.
 Database systems have several schemas, partitioned according to the
levels of abstraction.
 The physical schema describes the database design at the physical level,
while the logical schema describes the database design at the logical
level.
 A database may also have several schemas at the view level, sometimes
called subschemas, that describe different views of the database.
33 Data Models
 A Database model defines the logical design and structure of a database
and defines how data will be stored, accessed and updated in a
database management system. While the Relational Model is the most
widely used database model, there are other models too:
 Hierarchical Model
 Network Model
 Entity-relationship Model
 Relational Model
34 Hierarchical Model
 This database model organizes data into a tree-like-structure, with a single
root, to which all the other data is linked. The hierarchy starts from the Root
data, and expands like a tree, adding child nodes to the parent nodes.

Hierarchical Model
35 Network Model
 This is an extension of the Hierarchical model. In this model data is
organized more like a graph, and are allowed to have more than one
parent node.
 In this database model data is more related as more relationships are
established in this database model.
 Also, as the data is more related, hence accessing the data is also easier
and fast. This database model was used to map many-to-many data
relationships.
36
37 Entity-relationship Model
 In this database model, relationships are created by dividing object of
interest into entity and its characteristics into attributes.
 Different entities are related using relationships.
 E-R Models are defined to represent the relationships into pictorial form to
make it easier for different stakeholders to understand.

A Sample E-R diagram


Relational Model
38  In this model, data is organized in two-dimensional tables and the
relationship is maintained by storing a common field.
 This model was introduced by E.F Codd in 1970, and since then it has been
the most widely used database model, in fact, we can say the only
database model used around the world.
 The basic structure of data in the relational model is tables. All the
information related to a particular type is stored in rows of that table.

Relational Model
39
40 Database Languages
 A database system provides a data definition language to specify the
database schema and a data manipulation language to express database
queries and updates.
 In practice, the data definition and data manipulation languages are not
two separate languages; instead they simply form parts of a single
database language, such as the widely used SQL language.
41 DDL vs DML
42 SQL Statements
43 SQL Statements and their description
44 Database users and Administrators
 A primary goal of a database system is to retrieve information from and
store new information in the database.
 People who work with a database can be categorized as database users
or database administrators.
 There are four different types of database-system users, differentiated by
the way they expect to interact with the system.
 Different types of user interfaces have been designed for the different types
of users.
 Naïve Users.
 Application programmers.
 Sophisticated User.
 Specialized user.
45 Database Administrator
 One of the main reasons for using DBMSs is to have central control of both
the data and the programs that access those data.
 A person who has such central control over the system is called a database
administrator (DBA). The functions of a DBA include:
 Schema definition: The DBA creates the original database schema by
executing a set of data definition statements in the DDL.
 Storage structure and access-method definition.
 Schema and physical-organization modification. The DBA carries out
changes to the schema and physical organization to reflect the changing
needs of the organization, or to alter the physical organization to improve
performance.
46  Granting of authorization for data access: By granting different types of
authorization, the database administrator can regulate which parts of the
database various users can access.
 The authorization information is kept in a special system structure that the
database system consults whenever someone attempts to access the data
in the system.
 Routine maintenance: Examples of the database administrator’s routine
maintenance activities are:
 Periodically backing up the database, either onto tapes or onto remote servers,
to prevent loss of data in case of disasters such as flooding.
 Ensuring that enough free disk space is available for normal operations, and
upgrading disk space as required.
 Monitoring jobs running on the database and ensuring that performance is not
degraded by very expensive tasks submitted by some users.
Data Dictionary 47

In a relational database, the metadata in the data dictionary


includes the following:

 Names of all tables in the database and their owners

 Names of all indexes and the columns to which the tables


in those indexes relate

 Constraints defined on tables, including primary keys,


foreign-key relationships to other tables, and not-null
constraints
48 Types of Data Dictionary:
Here are the two types of data dictionary:

 Active Data Dictionary


The DBMS software manages the active data dictionary automatically.
The modification is an automatic task and most RDBMS has active data
dictionary. It is also known as integrated data dictionary.

 Passive Data Dictionary


Managed by the users and is modified manually when the database
structure change. Also known as non-integrated data dictionary.
49
50 Classification of Database Management Systems
51 Classification of Database Management Systems
52 ER-Model
 The ER or (Entity Relational Model) is a high-level conceptual data model
diagram.
 Entity-Relation model is based on the notion of real-world entities and the
relationship between them.
 ER modeling helps you to analyze data requirements systematically to
produce a well-designed database.
 So, it is considered a best practice to complete ER modeling before
implementing your database.
53 Facts about ER Diagram Model:

 ER model allows you to draw Database Design

 It is an easy to use graphical tool for modeling data

 Widely used in Database Design

 It is a GUI representation of the logical structure of a Database

 It helps you to identifies the entities which exist in a system and the
relationships between those entities
54 Why use ER Diagrams?
 Provide a preview of how all your tables should connect, what fields are
going to be on each table .

 Helps to describe entities, attributes, relationships .

 ER diagrams are translatable into relational tables which allows you to build
databases quickly.

 The database designer gains a better understanding of the information to


be contained in the database with the help of ERP diagram.

 ERD is allowed you to communicate with the logical structure of the


database to users.
55 ER-Diagram Notations
56 ER-Diagram Notations
57 Cardinality Ratios

 In ER model, a relationship is an association among


entities (records) of one or more entity sets. Cardinality
ratio or mapping cardinalities is a concept that
describes binary relationship set (a relationship that
connects two entity sets) and its types.
 It is about the maximum number of entities of one entity
set that are associated with the maximum number of
entities of the other entity set.
58
59
60 Participation constraints in DBMS
This constraint specifies the number of instances of an entity that are
participating in the relationship type.

There are two types of Participation constraint:


 Total participation
 Partial participation
61 Total participation constraint
It specifies that each entity present in the entity set must mandatorily
participate in at least one relationship instance of that relationship set,for this
reason, it is also called as mandatory participation.
It is represented using a double line between the entity set and relationship
set.
Example of total participation constraint
 It specifies that each student must be enrolled in at least one course where
the “student” is the entity set and relationship “enrolled in” signifies total
participation
 It means that every student must have enrolled at least in one course
62 Example of total participation constraint
63 Partial participation
 It specifies that each entity in the entity set may or may not participate in
the relationship instance of the relationship set, is also called as optional
participation
 It is represented using a single line between the entity set and relationship
set in the ER diagram

 Example of partial participation


 A single line between the entities i.e courses and enrolled in a relationship
signifies the partial participation,which means there might be some courses
where enrollments are not made i.e enrollments are optional in that case
64 Example of partial participation
65
66 Generalization
67 Specialization
68 Degree of Relationship
Degree of relationship refers to the number of participating entities in a
relationship. If there are two entities involved in relationship, then it is referred
to as binary relationship. If there are three entities involved, then it is called as
ternary relationship and so on.
Following are the degrees of Relationships.
1. Single Entity - Unary
2. Double Entities - Binary
3. Triple Entities - Ternary
4. N Entities - N- ary
69 Unary
70
71 Ternary
72 Components of the ER Diagram

This model is based on three basic concepts:


 Entities
 Attributes
 Relationships
73 WHAT IS ENTITY?
A real-world thing either living or non-living that is easily recognizable and
nonrecognizable. It is anything in the enterprise that is to be represented in our
database. It may be a physical thing or simply a fact about the enterprise or
an event that happens in the real world.

 Examples of entities:
 Person: Employee, Student, Patient
 Place: Store, Building
 Object: Machine, product, and Car
 Event: Sale, Registration, Renewal
 Concept: Account, Course
74 Entity set:
An entity set is a group of similar kind of entities. It may contain entities with
attribute sharing similar values. Entities are represented by their properties,
which also called attributes. All attributes have their separate values. For
example, a student entity may have a name, age, class, as attributes.
75
76
77
78
79 Key in DBMS

A DBMS key is an attribute or set of an attribute


which helps you to identify a row(tuple) in a
relation(table). They allow you to find the relation
between two tables. Keys help you uniquely identify
a row in a table by a combination of one or more
columns in that table.
80 Why we need a Key?

 Keys help you to identify any row of data in a table. In a real-world


application, a table could contain thousands of records. Moreover,
the records could be duplicated. Keys ensure that you can uniquely
identify a table record despite these challenges.
 Allows you to establish a relationship between and identify the
relation between tables
 Help you to enforce identity and integrity in the relationship.
81 Various Keys in Database Management System

 Super Key
 Primary Key
 Candidate Key
 Alternate Key
 Foreign Key
 Compound Key
 Composite Key
82 What is the Super key?

A super key is a group of single or multiple keys which


identifies rows in a table. A Super key may have additional
attributes that are not needed for unique identification.
83 What is a Primary Key?
A column or group of columns in a table which helps us to uniquely identifies
every row in that table is called a primary key. This DBMS can't be a duplicate.
The same value can't appear more than once in the table.

Rules for defining Primary key:


 Two rows can't have the same primary key value
 It must for every row to have a primary key value.
 The primary key field cannot be null.
 The value in a primary key column can never be modified or
updated if any foreign key refers to that primary key.
84 In the following example, StudID is a Primary Key.
85 What is the Alternate key?

All the keys which are not primary key are called
an alternate key. It is a candidate key which is
currently not the primary key. However, A table
may have single or multiple choices for the
primary key.
86
StudID, Roll No, Email are qualified to become a primary key. But since StudID
is the primary key, Roll No, Email becomes the alternative key.
87 What is a Candidate Key?
A super key with no repeated attribute is called candidate key.
The Primary key should be selected from the candidate keys. Every table must
have at least a single candidate key.

Properties of Candidate key:


 It must contain unique values
 Candidate key may have multiple attributes
 Must not contain null values
 It should contain minimum fields to ensure uniqueness
 Uniquely identify each record in a table
88 Example: In the given table Stud ID, Roll No, and email are
candidate keys which help us to uniquely identify the
student record in the table.
89
90 What is the Foreign key?

A foreign key is a column which is added to


create a relationship with another table. Foreign
keys help us to maintain data integrity and also
allows navigation between two different instances
of an entity. Every relationship in the model needs
to be supported by a foreign key.
91
92 In this table, adding the foreign key in Deptcode to the
Teacher name, we can create a relationship between the
two tables.

You might also like