Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Dbms Units Notes

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 20

UNIT -1

INTRODUCTION TO BASIC CONCEPTS OF DATABASE SYSTEMS:

What is Data?

The raw facts are called as data. The word “raw” indicates that they have not been processed.

Ex: For example 89 is the data.

What is information?

The processed data is known as information.

Ex: Marks: 89; then it becomes information.

Ex: If I want to find how much rain falls in a week. Data is the one, that I record amount of
rainfall/day.

Information is the knowledge gathered from data on an average how much rain has occurred
in a week.

What is Knowledge?

1. Knowledge refers to the practical use of information.

2. Knowledge necessarily involves a personal experience.

DATA/INFORMATION PROCESSING:

The process of converting the data (raw facts) into meaningful information is called as
data/information processing.

When When
Data Information Knowledge
Processed Processed

Note: In business processing knowledge is more useful to make decisions for any organization.
DIFFERENCE BETWEEN DATA AND INFORMATION:

DATA INFORMATION

1.Processed data
1.Raw facts

2. It is in unorganized form 2. It is in organized form

3. Data doesn’t helps 3.Information helps in


in Decision making process Decision making process

Database -
 Database is a collection of interrelated and organized data.
 A database is a collection of information that is organized so that it can
be easily accessed, managed and updated.
 In general, it is a collection of files (tables).
 A database can be of any size and varying complexity.
 A database may be generated and manipulated manually or it may be
computerized.
Example:
Customer database consists the fields as cname, cno, and ccity

Cname Cno Ccity

Database Management System:

A database-management system (DBMS) is a collection of interrelated data and a set


of programs to access those data.

The DBMS is a general purpose software system that facilitates the process of
defining constructing and manipulating databases for various applications.

Goals of DBMS:

The primary goal of a DBMS is to provide a way to store and retrieve database
information that is both convenient and efficient

It is general purpose software that facilitates the following:


1. Defining: Specifying data types and structures, and constraints for data to be
stored.
2. Constructing: Storing data in a storage medium.
3. Manipulating: Involves querying, updating and generating reports.
4. Sharing: Allowing multiple users and programs to access data simultaneously.
Eg. Of DBMS- Access, dBase, FileMaker Pro, and FoxBASE, ORACLE etc.

Need of DBMS:

1. Before the advent of DBMS, organizations typically stored information using a “File
Processing Systems”.

Example of such systems is File Handling in High Level Languages like C, Basic and
COBOL etc., these systems have Major disadvantages to perform the Data Manipulation. So
to overcome those drawbacks now we are using the DBMS.

2. Database systems are designed to manage large bodies of information.

3. In addition to that the database system must ensure the safety of the information stored,
despite system crashes or attempts at unauthorized access. If data are to be shared among
several users, the system must avoid possible anomalous results.

1.1 Database Systems Applications:

The following are the various kinds of applications/organizations uses databases for their
business processing activities in their day-to-day life. They are:

1. Banking: For customer information, accounts, and loans, and banking transactions.

2. Airlines: For reservations and schedule information. Airlines were among the first to
. use

databases in a geographically distributed manner—terminals situated around the world


accessed the central database system through phone lines and other data networks.

3. Universities: For student information, course registrations, and grades.

4. Credit Card Transactions: For purchases on credit cards and generation of monthly
statements.

5. Telecommunication: For keeping records of calls made, generating monthly bills,


maintaining balances on prepaid calling cards, and storing information about the
communication networks.

6. Finance: For storing information about holdings, sales, and purchases of financial
instruments such as stocks and bonds.

7. Sales: For customer, product, and purchase information.


8. Manufacturing: For management of supply chain and for tracking production of
items in factories, inventories of items in warehouses/stores, and orders for items.

9. Human resources: For information about employees, salaries, payroll taxes and
benefits, and for generation of paychecks.

10. Railway Reservation Systems: For reservations and schedule information.

11. Web: For access the Back accounts and to get the balance amount.

12. E –Commerce: For Buying a book or music CD and browse for things like watches,
mobiles from the Internet.

1.2 PURPOSE OF DATABASE SYSTEMS

FILE ORIENTED APPROACH:

The earliest business computer systems were used to process business records and
produce information. They were generally faster and more accurate than equivalent manual
systems. These systems stored groups of records in separate files, and so they were called file
processing systems.

1. File system is a collection of data. Any management with the file system, user has
to write the procedures

2. File system gives the details of the data representation and Storage of data.

3. In File system storing and retrieving of data cannot be done efficiently.

4. Concurrent access to the data in the file system has many problems like a Reading
the file while other deleting some information, updating some information

5. File system doesn’t provide crash recovery mechanism.


Eg. While we are entering some data into the file if System crashes then content of
the file is lost.

6. Protecting a file under file system is very difficult.

The typical file-oriented system is supported by a conventional operating system.


Permanent records are stored in various files and a number of different application programs
are written to extract records from and add records to the appropriate files.
Page 6
DISADVANTAGES OF FILE-ORIENTED SYSTEM:

The following are the disadvantages of File-Oriented System:

Data Redundancy and Inconsistency:

Since files and application programs are created by different programmers over a long
period of time, the files are likely to be having different formats and the programs may be written
in several programming languages. Moreover, the same piece of information may be duplicated
in several places. This redundancy leads to higher storage and access cost. In addition, it may
lead to data inconsistency.

Difficulty in Accessing Data:

Suppose that one of the bank officers needs to find out the names of all customers who
live within a particular postal-code area. The officer asks the data-processing department to
generate such a list. Because there is no application program to generate that. The bank officer
has now two choices: either obtain the list of all customers and extract the needed information
manually or ask a system programmer to write the necessary application program. Both
alternatives are obviously unsatisfactory.
The conventional file processing environments do not allow needed data to be retrieved
in a convenient and efficient manner. Better data retrieval system must be developed for general
use.

Data Isolation:

Since data is scattered in various files, and files may be in different formats, it is difficult
to write new application programs to retrieve the appropriate data.

Concurrent Access Anomalies:

In order to improve the overall performance of the system and obtain a faster response
time, many systems allow multiple users to update the data simultaneously. In such an
environment, interaction of concurrent updates may result in inconsistent data.
Consider bank account A, containing $500. If two customers withdraw funds (say $50
and $100 respectively) from account A at about the same time, the result of the concurrent
executions may leave the account in an incorrect (or inconsistent) state. Suppose that the
programs executing on behalf of each withdrawal read the old balance, reduce that value by the
amount being withdrawn, and write the result back. If the two programs run concurrently, they
may both read the value $500, and write back $450 and $400, respectively. Depending on which
one writes the value last, the account may contain $450 or $400, rather than the correct value of
$350. To guard against this possibility, the system must maintain some form of supervision. But
supervision is difficult to provide because data may be accessed by many different application
programs that have not been coordinated previously.

Security Problems:

Not every user of the database system should be able to access all the data. For example,
in banking system, payroll personnel need only that part of the database that has information
about various bank employees. They do not need access to information about customer accounts.
It is difficult to enforce such security constraints.

Integrity Problems:

The data values stored in the database must satisfy certain types of consistency constraints.
For example, the balance of a bank account may never fall below a prescribed amount. These
constraints are enforced 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. The problem is compounded when constraints involve several data items for different files.

Atomicity Problem:

A computer system like any other mechanical or electrical device is subject to failure. In
many applications, it is crucial to ensure that once a failure has occurred and has been detected,
the data are restored to the consistent state existed prior to the failure

Example:

Consider part of a savings-bank enterprise that keeps information about all customers and
savings accounts. One way to keep the information on a computer is to store it in operating
system files. To allow users to manipulate the information, the system has a number of
application programs that manipulate the files, including:

A program to debit or credit an account A

program to add a new account

A program to find the balance of an account A

program to generate monthly statements


Programmers wrote these application programs to meet the needs of the bank. New
application programs are added to the system as the need arises. For example, suppose that the
savings bank decides to offer checking accounts.
As a result, the bank creates new permanent files that contain information about all the
checking accounts maintained in the bank, and it may have to write new application programs to
deal with situations that do not arise in savings accounts, such as overdrafts. Thus, as time goes
by, the system acquires more files and more application programs. The system stores permanent
records in various files, and it needs different

ADVANTAGES OF A DBMS OVER FILE SYSTEM:

Using a DBMS to manage data has many advantages:

Data Independence:

Application programs should be as independent as possible from details of data


representation and storage. The DBMS can provide an abstract view of the data to insulate
application code from such details.

Efficient Data Access:

A DBMS utilizes a variety of sophisticated techniques to store and retrieve data efficiently.
This feature is especially important if the data is stored on external storage devices.
Data Integrity and Security:

If data is always accessed through the DBMS, the DBMS can enforce integrity
constraints on the data. For example, before inserting salary information for an employee, the
DBMS can check that the department budget is not exceeded. Also, the DBMS can enforce
access controls that govern what data is visible to different classes of users.

Concurrent Access and Crash Recovery:

A database system allows several users to access the database concurrently. Answering
different questions from different users with the same (base) data is a central aspect of an
information system. Such concurrent use of data increases the economy of a system.

An example for concurrent use is the travel database of a bigger travel agency. The
employees of different branches can access the database concurrently and book journeys for their
clients. Each travel agent sees on his interface if there are still seats available for a specific
journey or if it is already fully booked.
A DBMS also protects data from failures such as power failures and crashes etc. by the
recovery schemes such as backup mechanisms and log files etc.

Data Administration:

When several users share the data, centralizing the administration of data can offer
significant improvements. Experienced professionals, who understand the nature of the data
being managed, and how different groups of users use it, can be responsible for organizing the
data representation to minimize redundancy and fine-tuning the storage of the data to make
retrieval efficient.

Reduced Application Development Time:

DBMS supports many important functions that are common to many applications
accessing data stored in the DBMS. This, in conjunction with the high-level interface to the data,
facilitates quick development of applications. Such applications are also likely to be more robust
than applications developed from scratch because many important tasks are handled by the
DBMS instead of being implemented by the application.

1.3 VIEW OF DATA:

Abstraction is one of the main features of database systems. Hiding irrelevant details from
user and providing abstract view of data to users, helps in easy and efficient user-database
interaction. That is the system hides certain details of how data are stored and maintained.

To understand the view of data, you must have a basic knowledge of data abstraction and
Instance & schema.

1. Data abstraction
2. Instance and schema

LEVELS OF ABSTRACTION IN A DBMS:

Hiding certain details of how the data are stored and maintained. A major purpose of
database system is to provide users with an “Abstract View” of the data. In DBMS there are 3
levels of data abstraction. The goal of the abstraction in the DBMS is to separate the users
request and the physical storage of data in the database.
..
THREE LEVELS OF DATA ABSTRACTION

Levels of Abstraction:

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:

This level of data Abstraction describes “What” data are to be stored in the database and
what relationships exist among those data.

Database Administrators use the logical level of abstraction.

View Level:

It is the highest level of data Abstracts that describes only part of entire database.
Different users require different types of data elements from each database.

The system may provide many views for the some database.
 Describes part of the database for a particular group of users.
 Can be many different views of a database.
 E.g. tellers in a bank get a view of customer accounts, but not of payroll data.

Example: Let’s say we are storing customer information in a customer table. At physical level
these records can be described as blocks of storage (bytes, gigabytes, terabytes etc.) in memory.
These details are often hidden from the programmers.

At the logical level these records can be described as fields and attributes along with their data
types, their relationship among each other can be logically implemented. The programmers
generally work at this level because they are aware of such things about database systems.

At view level, user just interact with system with the help of GUI and enter the details at the
screen, they are not aware of how the data is stored and what data is stored; such details are
hidden from them.

THREE SCHEMA ARCHITECTURE:

Schema:

The overall design of the database is called the “Schema” or “Meta Data”. A database
schema corresponds to the programming language type definition.

The data stored in database at a particular moment of time is called instance of


database. Database schema defines the variable declarations in tables that belong to a particular
database; the value of these variables at a moment of time is called the instance of that database.
The value of a variable in programming language corresponds to an “Instance” of a database

Schema.
EX:SCHEMA

STUDENT

SID SNAME PHNO

EX:INSTANCE

STUDENT

Sid Name phno


1201 Venkat 9014901442
1202 teja 9014774422

Three Schema Architecture:

The goal of this architecture is to separate the user applications and the physical
database. In this architecture, schemas can be defined at the following three levels:

1. The internal level has an internal schema, which describes the physical storage structure of
the database. The internal schema uses a physical data model and describes the complete
details of data storage and access paths for the database.

2. The conceptual level has a conceptual schema, which describes the structure of the whole
database for a community of users. The conceptual schema hides the details of physical
storage structures and concentrates on describing entities, data types, relationships, user
operations, and constraints. A high-level data model or an implementation data model can be
used at this level.
3. The external or view level includes a number of external schemas or user views. Each
external schema describes the part of the database that a particular user group is interested in
and hides the rest of the database from that user group. A high-level data model or an
implementation data model can be used at this level.

DATA INDEPENDENCE:

A very important advantage of using DBMS is that it offers Data Independence.

The ability to modify a scheme definition in one level without affecting a scheme
definition in a higher level is called data independence.

There are two kinds:

1. Physical Data Independence


2. Logical Data Independence

Physical Data Independence:

The ability to modify the physical schema without causing application programs to be
rewritten
Modifications at this level are usually to improve performance.

Fig: Data Independence

Logical Data Independence:

The ability to modify the conceptual schema without causing application programs to be
rewritten
Usually done when logical structure of database is altered
Logical data independence is harder to achieve as the application programs are usually
heavily dependent on the logical structure of the data.

Data models are a collection of conceptual tools for describing data, data relationships, data
semantics and data constraints. There are three different groups:

Object-based Logical Models

- Describe data at the conceptual and view levels.

1. The E-R Model


2. The Object-Oriented Model

Record-based Logical Models

- Record based logical Models – Like Object based model, they also describe
data at the conceptual and view levels. These models specify logical structure of database
with records, fields and attributes.

1. The Relational Model


2. The Network Model
3. The Hierarchical Model

Physical Data Models

-These models describe data at the lowest level of abstraction.

ER MODEL:
ER Model is a diagrammatic representation of entire Database tables. It represents a High Level
Database Design.

The entity-relationship model is based on a perception of the world as consisting of a collection


of basic objects (entities) and relationships among these objects. The main components of E-R
model are: entity set and relationship set.
 An entity is a thing or object in the real world and is distinguishable object that exists.
 Each entity has associated with it a set of attributes describing it.
 E.g. number and balance for an account entity.
 In a banking environment, entities are CUSTOMERS, BANK SUPPLIERS etc.
 For example, in a school database, students, teachers, classes and courses offered can be
considered as entities. Entities are represented by means of rectangles.
 A relationship is an association among several entities.
 e.g. A cust_acct relationship associates a customer with each account he or she has.
 For example an employee works at a department, a student enrolls in a course. Here,
works at and enrolls are called relationship. Relationships are represented by diamond-
shaped box.

Attributes

Entities are represented by means of their properties, called attributes. All attributes have
values. For example, a student entity may have name, class, and age as attributes. Attributes are
represented by means of ellipses. Every ellipse represents one attribute and is directly connected
to its entity (rectangle).

 The set of all entities or relationships of the same type is called the entity set or
relationship set.

Entity Entity Type Entity Set


An entity set is a set of entities
of the same type that share the
Entity is a person, place, thing, An entity type defines the
same properties at any point in
event, or even a concept. It collection of entities that have
time (or) It is the collection of
may be tangible or intangible. the same attributes.
entities of an entity type at a
point of time.
For Example, Entity is e1 or e2
Entity set is a bucket of apple,
or e3 or an apple For example, entity type is
banana, mango etc. or
where e1 e2 e3 are employees EMPLOYEE or Fruit
{e1,e2……}
and an apple is a fruit.

 Example :

Entity Type Employee


Attributes Name, Age, Pay
e1
(Rakesh, 40, 10000)
Entity Set e2
(extension) (Arun, 55, 8500)
e3
(Sandeep, 30, 14000)

Here are the geometric shapes and their meaning in an E-R Diagram –
Rectangle: Represents Entity sets.
Ellipses: Attributes
Diamonds: Relationship Set
Lines: They link attributes to Entity Sets and Entity sets to Relationship Set
Double Ellipses: Multivalued Attributes
Dashed Ellipses: Derived Attributes
Double Rectangles: Weak Entity Sets
Double Lines: Total participation of an entity in a relationship set
A sample E-R Diagram:
Relational Model
The relational model uses a collection of tables to represent both data and the relationships
among those data. Each table has multiple columns, and each column has a unique name as
follows: Each table is a group of column and rows, where column represents attribute of an
entity and rows represents records.

Sample relationship Model: Student table with 3 columns and four records.

Stu_Id Stu_Name Stu_Age


111 Ashish 23
123 Saurav 22
169 Lester 24
234 Lou 26
Hierarchical Model

In Hierarchical model data elements are linked as an inverted tree structure (root at the top with
branches formed below). Below the single root data element are subordinate elements each of
which in turn has its own subordinate elements and so on, the tree can grow to multiple levels.
Data elements have parent child relationship as in a family tree.

For Example in an organization employees are categorized by their department and within a
department they are categorized by their job function such as managers, engineers, technicians
and support staff.
Network model

This model is the extension of hierarchical data model. In this model also there exist a parent
child relationship but a child data element can have more than one parent element or no parent at
all. The main difference of the network model from the hierarchical model is its ability to handle
many –to – many (n: n) relationships or in other words it allows a record to have more than one
parent.

Example of Network model is given below where there are relationships among courses offered
and students enrolled for each course in a college. Each student can be enrolled for several
courses and each course may have a number of students enrolled for it. The students enrolled for
English are Miya and Priyanka and Miya has taken three courses English, Math and Science.The
example also shows a child element that has no parent element i.e he has not taken any course in
this semester, he might be a research student.

Object Oriented Model

Object oriented models were introduced to overcome the shortcomings of conventional models
like Relational, Hierarchical and network model. An object oriented database is collection of
objects whose behavior, state, and relationships are defined in accordance with object oriented
concepts (such as objects, class, class hierarchy etc. )

The following diagram represents an example of object oriented database structure. Here Class
vehicle is root of a class composition hierarchy including classes VehicleSpecs, Company and
Employee. Class Vehicle is also root of a class Hierarchy involving classes. Two Wheeler and
FourWheeler. Class Company is in turn, root of a class hierarchy with subclasses Domestic
Company and ForeignCompany. It is also root of a class composition hierarchy involving class
Employee.

You might also like