Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 63

Unit I - Introduction

Overview of Database
Database
Systems
• A Database is a collection of interrelated data.
• Designed to meet the information needs of
an organization.
• Eg. A university Database – It contains information about students,
faculty, courses, classroom etc. It could also contains the information
about which student is studying which course.
Database
CourseDetails
Example
CourseID CName CFees Level

1 MBA 28000$ 9

2 MCA 30000$ 9

The above database contains two tables. One table contains


the information about the student and the second table
contains the information about the course. This database also
contains the relationship between the tables. By using this
table we can find out which students is doing which course.
Database System
Applications
Database are widely used. Some applications are:

• Banking – For customer information, accounts, loans and


banking transactions etc.
• Airline– For reservation and schedule information
• Universities – For student information, Course registration
and grades.
• Sales – For customer, product and purchase
information.
• Human resources – For information about employees, salaries,
payroll taxes and benefits etc.
Database Management
System(DBMS)
 “A Database management system (DBMS) consists of a
collection of interrelated data and a set of programs to access
that data”(Korth & Silberschatz,1991,p.01).
 A software system that enables users to define, create,
maintain, and control access to the database.
 (Database) application program: a computer program that
interacts with database by issuing an appropriate request
( SQL statement) to the DBMS.
Basic Definitions
• Database:
• A collection of related data.
• Data:
• Known facts that can be recorded and have an implicit
meaning.
• Database Management System (DBMS):
• A software package/ system that enables users to create
and maintain a database.
• Application program:
Application program accesses the database by sending queries or
requests. for data to the DBMS
An Example
Simplified database system environment
Characteristics of the
Database Approach
Main Characteristics of the Database
Approach
• Self-describing nature of a database system:
• A DBMS catalog stores the description of a particular database (e.g. data structures,
types, and constraints)
• The description is called meta-data.
• This allows the DBMS software to work with different database applications.
• Insulation between programs and data:
• Called program-data independence.
• Allows changing data structures and storage organization without having to change
the DBMS access programs.
Main Characteristics of the Database
Approach (continued)
• Sharing of data and multi-user transaction processing:
• Allowing a set of concurrent users to retrieve from and to update the database.
• Concurrency control within the DBMS guarantees that each transaction is correctly
executed or aborted
• Recovery subsystem ensures each completed transaction has its effect permanently
recorded in the database
• OLTP (Online Transaction Processing) is a major part of database applications. This
allows hundreds of concurrent transactions to execute per second.
Database users
Database Users
• Actors on the scene
• Database administrators:
• Design of the Conceptual and Physical Schemas
• Security and Authorization
• Data Availability and Recovery from Failures
• Controlling its use and monitoring efficiency of operations.
• Database Designers:
• Responsible for identifying the data to be stored in the database and for
choosing appropriate structure to represent and store this data
• Responsible to define the content, the structure, the constraints, and
functions or transactions against the database.
• They must communicate with the end-users and understand their needs.
Categories of End-users (continued)
• Sophisticated:
• Sophisticated users are those who have their own way of accessing the database. This means
they do not use the application program provided in the system. Instead, they might define
their own application or describe their need directly by using query languages.
• These include business analysts, scientists, engineers, others thoroughly familiar with the
system capabilities.
• Many use tools in the form of software packages that work closely with the stored database.
Stand-alone:
• These are the users who maintain their personal
database using ready made software which is
available in the market easily and provide the menu
based interface through which they can easily used
the database.

• An example is a user that maintains an address


book.
Advantages of using the
DBMS Approach
Advantages of a DBMS
Efficient Data Access – DBMS utilizes different techniques to
store and retrieve data efficiently.
Data Independence – Application program should not, ideally, be
exposed to details of data representation and storage. It provides
a abstract view of data that hides such details.
Data Integrity & Security – DBMS can enforce integrity
constraints. Controlling Restricting unauthorized access to data

Concurrent Access and Crash Recovery – DBMS schedule


concurrent accesses to the data. i.e. data being accessed by one
user at the same time. DBMS also protect the users from the
effect of the system failures.
Advantages of Database
Reduced Application Development time – DBMS supports
important functions that are common to many
applications accessing data in the DBMS.
It avoid data redundancy - Data redundancy means
storing the same data more than once. For eg. In a
banking software, there is a possibility of storing
customer details (ie customer name and phone no..) in
more than one table(saving account, current account).
DBMS helps us to avoid data redundancy problems.
It avoid data inconsistency - Data redundancy may lead
to data inconsistency. For eg. The customer’s address is
contained in more than one table. If the customer’s
address is changed, then the changes are reflected in one
table but not elsewhere. This situation leads to data
inconsistency.
 
Advantages of Database
Providing Storage Structures (e.g. indexes) for efficient Query Processing.
Providing multiple interfaces to different classes of users.- Many of users with
varying levels of technical knowledge use a database, a DBMS provide a
variety of user interface. These include app for mobile users, query language
for casual users, programming language interface for application
programmers etc.
Potential for enforcing standards:
This is very crucial for the success of database applications in large organizations.
Standards refer to data item names, display formats, screens, report structures,
meta-data (description of data), Web page layouts, etc. DBMS permits the DBA to
define and enforce standards among database users in a large organization.
Reduced application development time: Incremental time to add each new
application is reduced.

 
Advantages
Flexibility to change data structures:
of Database
Database structure may evolve as new requirements are defined.
Availability of current information:
Extremely important for on-line transaction systems such as airline, hotel, car
reservations.
Economies of scale:
Wasteful overlap of resources and personnel can be avoided by consolidating data and
applications across departments.

 
Disadvantages of DBMS
• Size – Database management system needs large amount
of disk space, internal memory.
• Expensive – Mainframe DBMS is very expensive.
• Additional Hardware requirement – Depending upon the
complexity of the DBMS, additional hardware may be
required
• Complexity
Three Schema Architecture/
Three level Data abstraction
Three Level Architecture of DBMS
continue…
External
View 1 View 2 View 3
Level

Conceptual
Level

Physical
Level
Three Level Architecture of DBMS
continue…
Sales Officer Inventory Controller

View 1 View 2
External Item_Name Item_Name
Level Price Stock

Conceptual
Conceptual Item_Number Character (6)
Item_Name Character(30)
Level Price Numeric(5,2)
Stock Numeric(4)

Physical
Stored_Item Length=50
Physical Item # Type = Byte(6), offset = 0, Index = Ix
Name Type = Byte(30), offset = 6
Level Price Type = Byte(8), offset = 36
Stock Type = Byte(4), offset = 44
Physical Level
• Lowest level of abstraction
• Describes how the data are actually stored.
• Describes low level data structures in detail.
Logical Level
• Describes what data are stored in the database, What
relationship exist among them.
• Database Administrator use the logical level of abstraction.
View Level
• The highest level of abstraction describes only the part of the
entire database
• Allows to see only the data of interest to them.
• Users – Application programmers or end-users
External or View Level

This level is closest to the users and is concerned with the


way in which the data is viewed by individual users.
Most of the users are not concerned with all the
information contained in the database. Instead they
need only a part of the database relevant to them. The
system provides many views for the same database.
Conceptual Level
This level of abstraction describes what data are actually
stored in the database. It also describes the relationships
existing among data. At this level, the database is
described logically in terms of simple data-structures.
The users of this level are not concerned with how these
logical data structures will be implemented at the
physical level, rather they just are concerned about what
information is to be kept in the database.
Internal or Physical Level

The internal level is closest to physical storage. This level


is also termed as physical level. It describes how the
data are actually stored on the storage medium. At this
level, complex low-level data structures are described
in detail.
Data Independence
Data Independence
The ability to modify a schema definition in one level
without affecting a scheme definition in the next higher
level is called DATA INDEPENDENCE

• Physical Data Independence

• Logical Data Independence


Physical Data Independence

It refers to the ability to modify the scheme followed at the


physical level without affecting the scheme followed at the
conceptual level.

The application programs remain the same even though the


scheme at the physical level gets modified.

Modifications at the physical level are occasionally necessary in


order to improve performance of the system.
Logical Data Independence

It refers to the ability to modify the conceptual scheme without


causing any changes in the schemes followed at view levels.

The logical data independence ensures that the application


programs remain the same.

Modifications at the conceptual level are necessary whenever


logical structures of the database get altered because of some
unavoidable reasons.

By Jismy Joseph
Data models, Schemas , and
Instances
Data models
Data Model
• Three data models that are used for
database management are: 
1. The Relational Data Model
2. The Hierarchical Data Model
3. The Network Data Model
4. Entity-Relationship Model
The Relational Data Model
• In this model,the data is organized into
tables (ie., rows and columns). These
tables are called relations.
• A row in a table represents a relationship
among a set of values.
Consider a sample database with three
tables (relations):Suppliers, Items,
Quantities:
  Suppliers (sup-no#,sup-name,status,
city)
Items ( item-no#, item-name, price)
Quantities (sup-no#, item-no#, Qty)
Suppliers
Sup-no# Sup-Name Status City
S1 Britannia 10 Delhi
S2 New 30 Mumbai
S3 Cockg 10 Delhi

Items
Item-no# Item-name Price
I1 Milk 15.00
I2 Cake 5.00
I3 Bread 9.00
I4 Biscuit 14.00
I5 Ice cream 6.00
I6 Jam 10.00

Quantities
Sup-no# Item-no# Qty
S1 I2 10
S1 I3 20
S1 I6 20
S2 I4 20
S2 I5 10
S3 I1 10
 Rows of relations are generally referred to
as tuples or records and the columns are
usually referred to as attributes or
field.
 No two tuples are identical and their
ordering is not important.

 A relationship is represented by combining


the primary key of the relations.

 various operations can be performed on


relations such as insert new tuples, delete
tuples and modify tuples.

 There are several languages for expressing


these operations. One such language is
relational query language.
The Network Data Model
 In this model, data is represented by
collections of records and relationships
among data are represented by links. Ie.,
the collection of records which are
connected to one another by means of links.
A record is a collection of fields
(attributes), each of which contains only
one data value.
 A link is an association between precisely
two records.
 The structure of the database is shown as
an arbitrary graph in which the records
form the nodes and links form the edges.
 There is no concept of a root node.
Consider the structure of the above sample
database of suppliers, items and quantities.

S1 Britannia 10 Delhi S2 New 30 Mumbai S3 Cockg 10 Delhi

10 20 20 20 10 10

I1 milk 15 I2 cake 5 I3 bread 9 I4 biscuit 14 I5 icecream 6 I6 jam 10


 The operations on a network database are
performed through a data manipulation
language for network model.

 The operations that can be performed on


a network database include find, insert,
delete, modify etc.

 The inserting or removing records


include connect, disconnect and reconnect
operations.
The Hierarchical Data Model
 Same as network model. The only difference
is that in the hierarchical model, records
are organized as trees rather than arbitrary
graphs.
 The record type at the top of the tree is
usually known as root.
 In general, the root may have any number of
dependents and each of these dependents may
have any number of low level dependents and
so on.
Consider the hierarchical view of the above
sample database of suppliers, items and
quantities.
S1 Britannia 10 Delhi

I2 Cake 5
I3 Bread 9
10
I6 Jam 10
20
20

S2 New 30 Mumbai

I4 Biscuit 14
I5 Icecream 6
20
10

S3 Cockg 10 Delhi

I1 Milk 15

10
In this tree structure supplier record type
is the root node.
 Here the relationship is expressed in the
form of a tree with all the edges
pointing to the leaf.
 The operations on a hierarchical database
are performed through a data manipulation
language for hierarchical data model.
 The various operations include retrieval,
insertions , deletions and modifications
of records.
Entity-Relationship (ER) Model
• Entity-Relationship (ER) Model is based on the notion of real-world entities and relationships among
them.
• ER Model is best used for the conceptual design of a database.
• 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.
• Mapping cardinalities −
one to one
one to many
many to one
many to many
Schemas and Instances

By Jismy Joseph
Schemas versus Instances
• Database Schema:
• The description of a database.
• Includes descriptions of the database structure, data types, and the
constraints on the database.
• Schema Diagram:
• An illustrative display of (most aspects of) a database schema.
• Schema Construct:
• A component of the schema or an object within the schema, e.g., STUDENT,
COURSE.

Slide 2- 46
By Jismy Joseph
continue…
Sales Officer Inventory Controller

View 1 View 2
External Item_Name Item_Name
Schema Price Stock

Conceptual
Conceptual Item_Number Character (6)
Item_Name Character(30)
Schema Price Numeric(5,2)
Stock Numeric(4)

Physical
Stored_Item Length=50
Physical Item # Type = Byte(6), offset = 0, Index = Ix
Name Type = Byte(30), offset = 6
Schema Price Type = Byte(8), offset = 36
Stock Type = Byte(4), offset = 44

By Jismy Joseph
Example of a Database Schema

Slide 2- 49
Schemas versus Instances
• Database State:
• The actual data stored in a database at a particular moment in time. This
includes the collection of all the data in the database.
• Also called database instance (or occurrence or snapshot).
• The term instance is also applied to individual database components, e.g. record
instance, table instance, entity instance

Slide 2- 50
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 state when it is initially loaded into the system.
• Valid State:
• A state that satisfies the structure and constraints of the database.

Slide 2- 51
Example of a database state

Slide 2- 52
Database Schema
vs. Database State (continued)
• Distinction
• The database schema changes very infrequently.
• The database state changes every time the database is updated.

• Schema is also called intension.


• State is also called extension.

Slide 2- 53
DBMS Languages
DBMS Languages
Structured Query Language(SQL)
• SQL is a Language designed for managing data in relational database
management system(RDBMS).
• SQL is a relational database language, not a programming language like C, C++.
• It is flexible, simple and powerful.
Components of SQL – SQL has three components. They are:
• DDL - Data Definition Language
• DML - Data Manipulation Language
• DCL - Data Control Language
The Data Definition Language
(DDL)
The Data Definition Language (DDL):
• DDL commands are used to deal with the schema (structure) definition of the RDBMS.
• DDL command are used to create, modify and remove database objects such as tables,
views and.
• Integrity constraints can be defined on tables, either when the table is created or later.
• For eg: CREATE, ALTER, DROP commands
The Data Definition Language
(DDL)
The Data Definition Language (DDL):
• Used by the DBA and database designers to specify the conceptual
schema of a database.
• In many DBMSs, the DDL is also used to define internal and external
schemas (views).
• In some DBMSs, separate storage definition language (SDL) and view
definition language (VDL) are used to define internal and external
schemas.
The Data Manipulation Language
(DML)
The Data Manipulation Language (DML):
• DML command enhances efficient user interaction with the database
system by providing a set of commands.
• DML permits users to insert data into the table, retrieve existing data,
delete data from tables and modify the stored data.
• The common DML commands are SELECT, INSERT, UPDATE and DELETE.
The Data Manipulation Language
(DML)
The Data Manipulation Language (DML):
• DML commands (data sublanguage) can be embedded in a
general-purpose programming language (host language),
such as COBOL, C, C++, or Java.
• Alternatively, stand-alone DML commands can be applied
directly (called a query language).
Types of DML
• High Level or Non-procedural Language:
• To specify complex database operations.
• Many DBMS allow high-level DML statements either to be entered
interactively from display monitor or terminal or to be embedded in a general
purpose programming language.
• For example, the SQL relational language
• Are “set”-oriented and specify what data to retrieve rather than how to
retrieve it.
• Also called declarative languages.
• Low Level or Procedural Language:
• Low Level DML must be embedded in a general purpose programming
language.
• Retrieve data one record-at-a-time;
• Constructs such as looping are needed to retrieve multiple records, along with
positioning pointers.
The Data Control Language
(DCL)
The Data Control Language (DCL):
• DCL is used to control access to the database, which is very essential to a database
system with respect to security concern.
• DCL commands that control a database, including administering privileges and
committing data.
• The commands GRANT and REVOKE are used as a part of DCL.
The Database System
Environment
DBMS component Modules
Typical DBMS Component Modules
• The top part of the figure refers to the various
users of the database and their interfaces.
• The lower part shows internal modules of the
DBMS responsible for storage of data and
processing of transaction.
• The database and database catalog are
usually stored on disk
• Access of disk is primarily controlled by the
OS.
Users
DBMS Software
Data store
Hardware

You might also like