0% found this document useful (0 votes)
11 views54 pages

DBMS Ggi

Uploaded by

Pradeep Kumar
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)
11 views54 pages

DBMS Ggi

Uploaded by

Pradeep Kumar
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/ 54

DBMS

Rajdavinder Singh Boparai


iNurture Education Solutions Pvt. Ltd.
Common terms

• Data: Facts, figures, statistics etc. having no particular meaning (e.g. 1, ABC, 19
etc).

• Record: Collection of related data items, e.g. in the above example the three data
items had no meaning. But if we organize them in the following way, then they
collectively represent meaningful information.

iNurture Education Solutions Pvt. Ltd.


Introduction to RDBMS

• Table or Relation: Collection of related records

The columns of this relation are called Fields, Attributes or Domains. The rows are called
Tuples or Records.
iNurture Education Solutions Pvt. Ltd.
(Introduction to RDBMS)

• Database: Collection of related relations. Consider the following collection of


tables:

iNurture Education Solutions Pvt. Ltd.


Files and Databases

• File: A collection of records or documents dealing with one organization, person,


area or subject
• Manual (paper) files
• Computer files
• Database: A collection of similar records with relationships between the records
• Bibliographic, statistical, business data, images, etc.

iNurture Education Solutions Pvt. Ltd.


Purpose of Database Systems

• In the early days, database applications were built directly on top


of file systems
• 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
iNurture Education Solutions Pvt. Ltd.
Purpose of Database Systems (Cont.)

• Drawbacks of using file systems (cont.)


• 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 accessed needed for performance
• Uncontrolled concurrent accesses can lead to inconsistencies
• Example: Two people reading a balance and updating it
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

iNurture Education Solutions Pvt. Ltd.


Importance of DBMS
• It helps make data management more efficient and effective.
• Its query language allows quick answers to ad hoc queries.
• It provides end users better access to more and better-managed
data.
• It promotes an integrated view of organization’s operations --
“big picture.”
• It reduces the probability of inconsistent data.
• Data Independence
• Efficient data access
• Data integrity and security
• Data administration
• Concurrent access and crash recovery
iNurture Education Solutions Pvt. Ltd.
Examples of Database Applications

• Banking: all 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

iNurture Education Solutions Pvt. Ltd.


Database Management System (DBMS)

iNurture Education Solutions Pvt. Ltd.


(Database Users)
• Data Base Administrator (DBA):-
• Authorizing access to the database
• Coordinating and monitoring its use
• Acquiring software and hardware resources
• Database designers are responsible for:
• Identifying the data to be stored
• Choosing appropriate structures to represent and store this
data
• System analysts
• Determine requirements of end users
• Application programmers
• Implement these specifications as programs

iNurture Education Solutions Pvt. Ltd.


Database Users….contd

• End users : People whose jobs require access to the database


• Types
• Casual end users: access database occasionally by sophisticated
query language when needed.
(Manager)
• Naive or parametric end users: they make up a large section of
the end-user population. Learn only a few facilities that they may
use repeatedly
(bank clerk)
• Sophisticated end users: These include business analysts,
scientists, engineers, others thoroughly familiar with the system
capabilities.
• Standalone users: Normal users

iNurture Education Solutions Pvt. Ltd.


Three Level/View Architecture of DBMS

• Physical level: describes how a record (e.g., customer) is stored.


• Logical level: describes data stored in database, and the relationships
among the data.
• View level: application programs hide details of data types. Views can
also hide information (such as an employee’s salary) for security
purposes.
• The database can be viewed from different levels of abstraction to
reveal different levels of details. From a bottom-up manner, we
may find that there are three levels of abstraction or views in the
database.
• The term Abstraction is very important here. Generally it means the
amount of detail you want to hide. Any entity can be seen from
different perspectives and levels of complexity to make it a reveal
its current amount of abstraction.
iNurture Education Solutions Pvt. Ltd.
Three Views of Data

Schema: It means arrangement – how we want to arrange things that we have to store.
The diagram above shows the three different schemas used in DBMS, seen from different
levels of abstraction.
Instance: the actual content of the database at a particular point in time
iNurture Education Solutions Pvt. Ltd.
Three Views of Data…..contd

Three General levels :-


Internal View (Physical View) :-
The way the data is stored in the storage media. (Specified by the DBA)
Conceptual View (Logic View):-
Describes the structure and constraints for the whole database. (Specified
and used by the programmers).
External View (Sub-Scheme):-
The view of the database as seen by the end user.

iNurture Education Solutions Pvt. Ltd.


Internal or Physical schema

• The lowest level, called the Internal or Physical schema, deals with
the description of how raw data items (like 1, ABC, KOL, H2 etc.)
are stored in the physical storage (Hard Disc, CD, Tape Drive etc.).
• It also describes the data type of these data items, the size of the
items in the storage media, the location (physical address) of the
items in the storage device and so on.
• This schema is useful for database application developers and
database administrator.

iNurture Education Solutions Pvt. Ltd.


Conceptual or Logical Schema

• The middle level is known as the Conceptual or Logical Schema,


and deals with the structure of the entire database.
• Please note that at this level we are not interested with the raw
data items anymore, we are interested with the structure of the
database.
• This means we want to know the information about the
attributes of each table, the common attributes in different
tables that help them to be combined, what kind of data can
be input into these attributes, and so on.
• Conceptual or Logical schema is very useful for database
administrators whose responsibility is to maintain the entire
database.

iNurture Education Solutions Pvt. Ltd.


External or View Schema

• The highest level of abstraction is the External or View


Schema.
• This is targeted for the end users.
• Now, an end user does not need to know everything about
the structure of the entire database, rather than the amount
of details he/she needs to work with.

iNurture Education Solutions Pvt. Ltd.


Data Independence

• It is the property of the database which tries to ensure that if we make


any change in any level of schema of the database, the schema
immediately above it would require minimal or no need of change.
• Ability to modify a schema definition in one level without affecting a schema
definition in the next higher level.
• The interfaces between the various levels and components should be well
defined so that changes in some parts do not seriously influence others.
• Example: We know that in a building, each floor stands on the floor below
it. If we change the design of any one floor, e.g. extending the width of a
room by demolishing the western wall of that room, it is likely that the
design in the above floors will have to be changed also. As a result, one
change needed in one particular floor would mean continuing to change the
design of each floor until we reach the top floor, with an increase in the
time, cost and labour. Would not life be easy if the change could be
contained in one floor only? Data independence is the answer for this. It
removes the need for additional amount of work needed in adopting the
single change into all the levels above.
iNurture Education Solutions Pvt. Ltd.
Types of Data Independence

Data independence can be classified into the following two types:


1. Physical Data Independence
2. Logical Data Independence

Physical Data Independence: This means that for any change made in
the physical schema, the need to change the logical schema is
minimal. This is practically easier to achieve.

Logical Data Independence: This means that for any change made in
the logical schema, the need to change the external schema is
minimal. As we shall see, this is a little difficult to achieve.

iNurture Education Solutions Pvt. Ltd.


Key Constraint
• Values in a column (or columns) of a relation are unique: at
most one row in a relation instance can contain a particular
value(s)

• Key - set of attributes satisfying key constraint


• e.g., Id in Student,
• e.g., (StudId, CrsCode, Semester) in Transcript
• Super Key
Super Key is defined as a set of attributes within a table that uniquely
identifies each record within a table. Super Key is a superset of
Candidate key.
• Candidate Key
Candidate keys are defined as the set of fields from which primary key
can be selected. It is an attribute or set of attribute that can act as a
primary key for a table to uniquely identify each record in that table.
iNurture Education Solutions Pvt. Ltd.
Key Constraint…contd

• Primary Key
Primary key is a candidate key that is most appropriate to become main key of
the table. It is a key that uniquely identify each record in a table. PK must be
unique and Not Null.
• Foreign Key
Foreign Key is a field or set of fields that are identical to a primary key in
another table.

iNurture Education Solutions Pvt. Ltd.


Key Constraint…contd

• Composite Key
Key that consist of two or more attributes that uniquely identify
an entity occurance is called Composite key. But any attribute
that makes up the Composite key is not a simple key in its own.
• Secondary or Alternative key
The candidate key which are not selected for primary key are
known as secondary keys or alternative keys
• Non-key Attribute
Non-key attributes are attributes other than candidate
key attributes in a table.
• Non-prime Attribute
Non-prime Attributes are attributes other than Primary
attribute.

iNurture Education Solutions Pvt. Ltd.


Key Constraint…contd

• Primary Key
Customers

iNurture Education Solutions Pvt. Ltd.


Key Constraint…contd

iNurture Education Solutions Pvt. Ltd.


(Data Models

• Type of Data Models:


• Relational Model
• Network Model
• Hierarchical Model
• ER Model
• Design issues
• Mapping constraints
• ER diagram
• Comparison of Models

iNurture Education Solutions Pvt. Ltd.


What is a Data Model?

Definition: precise description of the data content in a system

Categories of data models:


1. Conceptual(high-level, semantic ): describes WHAT the system contains
2. Logical(low-level, internal ): describes HOW the system will be
implemented, regardless of the DBMS
3. Physical(representational ): describes HOW the system will be implemented
using a specific DBMS

iNurture Education Solutions Pvt. Ltd.


Categories of data models

• Object Based Data Models: Object based data models use


concepts such as entities, attributes, and relationships.
• Entity Relationship
• Object Oriented
• Semantic
• Functional
• Physical Data Models
• Unifying Model
• Record Based Data Models: Record based logical models are
used in describing data at the logical and view levels
• Hierarchical
• Network
• Relational

iNurture Education Solutions Pvt. Ltd.


Why do we need to create data models?

To aid in the development of a sound database design that does not allow anomalies
or inconsistencies

Goal: to create database tables that do not contain duplicate data values that can
become inconsistent

iNurture Education Solutions Pvt. Ltd.


Schemas versus Instances

• Database Schema: The description of a database. Includes descriptions of the


database structure and the constraints that should hold on the database.
• Schema Diagram: A diagrammatic display of (some aspects of) a database
schema.
• Database Instance: The actual data stored in a database at a particular moment in
time. Also called database state (or occurrence).

iNurture Education Solutions Pvt. Ltd.


Database Schema Vs. Database State

• Database State: Refers to the content of a database at a moment in time.


• Initial Database State: Refers to the database when it is loaded
• Valid State: A state that satisfies the structure and constraints of the database.

• Distinction
• The database schema changes very infrequently. The database state changes
every time the database is updated.
• Schema is also called intension, whereas state is called extension.

iNurture Education Solutions Pvt. Ltd.


Sample Database

iNurture Education Solutions Pvt. Ltd.


Hierarchical model

iNurture Education Solutions Pvt. Ltd.


Hierarchical model….contd

• Advantages
• Many of the hierarchical data model’s features formed the
foundation for current data models
• Its database application advantages are replicated,
implemented in a different form, in current database
environments
• Generated a large installed (mainframe) base, created a
pool of programmers who developed numerous tried-and-
true business applications
• Disadvantages
• Complex to implement
• Difficult to manage
• Lacks structural independence
• Implementation limitations
• Lack of standards iNurture Education Solutions Pvt. Ltd.
Network Model: Graph

iNurture Education Solutions Pvt. Ltd.


Network model….contd

• Advantages
• Represent complex data relationships more effectively
• Improve database performance
• Impose a database standard
• Disadvantages
• Too cumbersome
• The lack of ad hoc query capability put heavy pressure on programmers
• Any structural change in the database could produce havoc in all application
programs that drew data from the database
• Many database old-timers can recall the interminable information delays

iNurture Education Solutions Pvt. Ltd.


Relational model

iNurture Education Solutions Pvt. Ltd.


Equivalent Relational Model

iNurture Education Solutions Pvt. Ltd.


Relational Database

A database whose logical organization is based on relational data


model is a Relational Database

iNurture Education Solutions Pvt. Ltd.


Relational Model

The main highlights of this model are −


• Data is stored in tables called relations.
• Relations can be normalized.
• In normalized relations, values saved are atomic values.
• Each row in a relation contains a unique value.
• Each column in a relation contains values from a same domain.

iNurture Education Solutions Pvt. Ltd.


Entity-Relationship Model

• Entity-Relationship (ER) Model is based on the notion of real-


world entities and relationships among them. While
formulating real-world scenario into the database model, the
ER Model creates entity set, relationship set, general attributes
and constraints.
• ER Model is best used for the conceptual design of a database.

iNurture Education Solutions Pvt. Ltd.


Entity-Relationship Model….contd

ER Model is based on −
Entities and their attributes.
Relationships among entities.
• Entity − An entity in an ER Model is a real-world entity having properties
called attributes. Every attribute is defined by its set of values called domain.
For example, in a school database, a student is considered as an entity. Student
has various attributes like name, age, class, etc.
• Relationship − The logical association among entities is called relationship.
Relationships are mapped with entities in various ways. Mapping cardinalities
define the number of association between two entities.
• An entity set is a set of entities of the same type that share the same properties.
Example: set of all persons, companies, trees, holidays
iNurture Education Solutions Pvt. Ltd.
Entity-Relationship Model..contd

Types of Attributes
• Simple attribute − Simple attributes are atomic values, which cannot be divided
further. For example, a student's phone number is an atomic value of 10 digits.
• Composite attribute − Composite attributes are made of more than one simple
attribute. For example, a student's complete name may have first_name and
last_name.
• Derived attribute − Derived attributes are the attributes that do not exist in the
physical database, but their values are derived from other attributes present in the
database. For example, average_salary in a department should not be saved directly
in the database, instead it can be derived. For another example, age can be derived
from data_of_birth.
• number, email_address, etc.

iNurture Education Solutions Pvt. Ltd.


Entity-Relationship Model..contd

Types of Attributes
• Single-value attribute − Single-value attributes contain single value.
• For example − Social_Security_Number.
• Multi-value attribute − Multi-value attributes may contain more than one values.
For example, a person can have more than one phone

iNurture Education Solutions Pvt. Ltd.


Entity-Relationship Model..contd

Relationships: Link between different entities of the database is called


relationship.

Mapping Cardinalities
Cardinality defines the number of entities in one entity set, which can be associated
with the number of entities of other set via relationship set.
• Express the number of entities to which another entity can be associated via a
relationship set.
• Most useful in describing binary relationship sets.

iNurture Education Solutions Pvt. Ltd.


Types of Relationships

One - One Relationship:- (1 – 1)


Each value in the first table could relate with only one record in the second table.
One – Many Relationship:- (1 - ∞)
Each value in the first table could relate with many records in the second table.
Many – Many Relationship (∞ - ∞)
Each value in the first table could relate with many records in the second table
and each value of the second table could relate with many records in the first
table.
Many – One Relationship(∞-1)
• More than one entities from entity set A can be associated with at most one entity
of entity set B, however an entity from entity set B can be associated with more
than one entity from entity set A.
iNurture Education Solutions Pvt. Ltd.
Relationships….contd

One - One Relationship:- (1 – 1)


Each value in the first table could relate with only one record in the second table

iNurture Education Solutions Pvt. Ltd.


Relationships….contd

One – Many Relationship:- (1 - ∞)


Each value in the first table could relate with many records in the second table.

iNurture Education Solutions Pvt. Ltd.


Relationships….contd

• Many-to-many − One entity from A can be associated with more than one entity
from B and vice versa

iNurture Education Solutions Pvt. Ltd.


Relationships….contd

• Many-to-one − More than one entities from entity set A can be associated with at
most one entity of entity set B, however an entity from entity set B can be
associated with more than one entity from entity set A.

iNurture Education Solutions Pvt. Ltd.


E-R Diagrams
 Rectangles represent entity sets.
 Diamonds represent relationship sets.
 Lines link attributes to entity sets and entity sets to relationship sets.
 Ellipses represent attributes
Double ellipses represent multivalued attributes.
 Dashed ellipses denote derived attributes.
 Underline indicates primary key attributes (will study later)

iNurture Education Solutions Pvt. Ltd.


E-R Diagram With Composite, Multivalued, and
Derived Attributes

iNurture Education Solutions Pvt. Ltd.


Comparison of Record based model

iNurture Education Solutions Pvt. Ltd.


Comparison of Record based model

iNurture Education Solutions Pvt. Ltd.

You might also like