Anda di halaman 1dari 13

DATABASE MANAGEMENT SYSTEMS

Unit-I

Database:

A database is a collection of data of some given enterprise, which can be


processed through one or more application programs by multiple users.

For Example, a university database might contain information about the


following:

• Entities such as students, faculty, and courses.

• Relationships between entities, such as students’ enrollment in


courses, faculty teaching courses.

Database Management System:

A Database Management System (DBMS) is defined as “A software that


provides an environment that is both convenient and efficient to use in
storing and retrieving the data of an enterprise.”

In short, A Database Management System means a system managing the


database of a particular enterprise in both the convenient and efficient
manner.

Database-System Applications:

• Banking: For customer information, accounts, loans, and banking


transactions.

• Airlines: For reservations and schedule information.

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

• Credit card transactions: For purchases on credit cards and generation


of monthly statements.

• Telecommunications: For keeping records of calls made, generating


monthly bills and maintaining balances on prepaid calling cards.

• Internet Interactions: For online shopping, you select an item from the
database and then send your credit card number to buy the product.
• Computer Horoscope: We enter our name, date of birth, and our likes
and dislikes in a form presented to us. All these details are compared
against a database to search for a perfect match and our future is
predicted.

Database System Vs File System:

The alternative to using a DBMS is to store the data in files, but file-
processing system has a number of disadvantages:

• Data Redundancy and Inconsistency: Since different programmers


create the files and application programs over a long period, the same
information may be duplicated in several files.

For example, the address and telephone number of a particular


customer may appear in a savings-account file and in a checking-
account file. This redundancy leads to wastage of storage and access
cost.

In addition, it may lead to data inconsistency. For example, a


changed customer address may be reflected in savings-account file but
not in checking-account file.

• Data Isolation: Because data are scattered in various files, and files
may be in different formats, an application developer needs to write
software to convert the files to some common format to facilitate
processing. Again this can be time-consuming and expensive.

• Integrity problems: The data values stored in the database must


satisfy certain types of constraints. For example, the balance of bank
account may never fall below Rs.500/-.

Developers enforce these constraints in the various application


programs. However, when new constraints are added, it is difficult to
change the programs to enforce them.

• Atomicity problems: In many applications, it is crucial that, if a


system failure occurs, the data to be restored to the consistent state
that existed prior to the failure.
For example, consider a program to transfer Rs.500/- from account A
to account B. If a system failure occurs during the execution of the
program, it is possible that the Rs.500/- was deducted from account A
but was not credited to account B, resulting in an inconsistent
database state. That is, the funds transfer must be atomic-it must
happen in its entirety or not at all.

Advantages of DBMS:

• Data Independence: Application programs should not ideally be


exposed to details of data representation and storage. The DBMS
provides an abstract view of the data that hides such details.

• Efficient Data Access: A DBMS utilizes a variety of sophisticated


techniques to store and retrieve the data efficiently.

• Data Administration: When several users share the data,


centralizing the administration of data can minimize the redundancy.

• Reduced Application Development Time: The DBMS supports


important functions that are common to many applications accessing
data in the DBMS.

View of Data:

A major purpose of a database system is to provide users with an abstract


view of the data.

Data Abstraction:

The designers use complex data structures to represent data in the database
for the sake of efficiency. Since many database users are not computer
trained, developers hide the complexity from users through several levels of
abstraction:
View View Level View
View 1
2 n

Logical
Level

Physical
Level

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.

• The logical level describes the entire database in terms of simple


structures.

• The user of the logical level need not aware of the complexity at
physical level.

• Database Administrators, who must decide what information to keep in


the database, use the logical level of abstraction.

View Level:

• The highest level of abstraction describes only part of the entire


database.

• Many users of the database system do not need all the information
stored in a large database, instead, they need only a part of the
database.
• The view level of abstraction exists to simplify user interaction with the
system.

• The system may provide many views for the same database.

Instances and Schemas:

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.

For simple explanation, let us take the example of declaring the variable in C
language:

int a=2;

A database schema corresponds to the declaration of a variable. And the


database instance corresponds to the value of a variable at given instant.

Example:

The Schema for students relation appear as,

Students(sid:string, name:string, age:integer, gpa:real)

The instance of the students relation appear as,

Sid Name Age Gpa

50000 Dave 19 3.3

53666 Jones 18 3.4

53831 Smith 19 2.8


Data Models:

A data model is a collection of conceptual tools for describing data, data


relationships, and consistency constraints.

A data model provides a way to describe the design of a database at the


physical, logical and view level.

The data models can be classified in to four different categories:

• 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.

The relational model is an example of record-based model. Because


each table contains records of a particular type.

The relational model is the most widely used data model and majority
of the today’s database systems are based on the relational model.

• The Entity-Relationship Model:

The Entity-Relationship (E-R) data model is based on real world


perception.

The E-R model consists of a collection of objects, called entities, and of


relationships among these objects.

The entity-relationship model is widely used in database design.

• Object-Based Data Model:

The object-oriented model can be seen as an extension to E-R model


with notions of encapsulation, methods and object identity.

• Semi-Structured Data Model:

The semi-structured data model permits the specification of data,


where individual data items of same type may have different sets of
attributes. This is in contrast to the above models, where every data
item of a particular type must have the same set of attributes.

The XML is widely used to represent semi-structured data.


Database Languages:

A DBMS provides two types of languages:

1. Data Definition Language (DDL) - to define the data in the database.

2. Data Manipulation Language (DML) - to manipulate the data in the


database.

In practice, the DDL and DML are not two separate languages, instead, they
are parts of a single database language, such as SQL.

Data Definition Language (DDL):

The language used to specify the database schema or to define the data in
the database is called as DDL.

In simple words, DDL is used to:

• Create the database schema

• Alter the database schema

• Delete the database schema

The DDL statements are compiled by DDL compiler and output generated
are the metadata and will be stored in special file called data dictionary.

There is another type of DDL, called, Data Storage and Definition Language,
used to specify the storage structure and access methods. These statements
define the implementation details of the database schemas, which are
hidden from the users.

Here is an example of SQL query to define the account table:

CREATE TABLE account (accno char (10), balance integer);

Data Manipulation Language (DML):

The language used to manipulate the data in the database is called DML.

In simple words, DML is used to:

• Retrieve information stored in the database

• Insert information in to the database


• Delete information from the database

• Modify information stored in the database

There are two types of DMLs:

1) Procedural DMLs: Require a user to specify what data are


needed and how to get those data.

2) Declarative DMLs (Non-Procedural): Require a user to


specify what data are needed without specifying how to get
those data.

Declarative DMLs are usually easier to learn and use than procedural DMLs.

But procedural DMLs are more efficient than declarative DMLs, because they
specify the procedure to retrieve the data.

Here is an example of SQL query to find the names of all customers who
reside in Hyderabad:

SELECT customer_name

FROM customer

WHERE customer_city=’hyderabad’;

Database Users and Administrators:

People who work with a database can be categorized as database users and
database administrators.

Database Users:

There are four different types of database-system users, differentiated by


the way they interact with the system:

• Naïve Users:

Naïve users are un-sophisticated users who interact with the system by
invoking the application programs that have been written previously.

For example, a bank teller who needs to transfer Rs.500/- from account
A to account B invokes a program called transfer. This program asks
the teller for the amount of money to be transferred, the account from
which the money is to be transferred, and the account to which the
money is to be transferred.

The typical user interface for naïve users is a form interface.

• Application Programmers:

Application Programmers are computer professionals who write


application programs.

They can use Rapid Application Development (RAD) tools to


develop user interfaces.

• Sophisticated Users:

Sophisticated users interact with the system without writing programs.


Instead, they submit their requests in a database query language.

Analysts who submit queries to explore data in the database fall in this
category.

• Specialized Users:

Specialized users are sophisticated users who write specialized


database applications like computer-aided design systems, knowledge-
base and expert systems, and systems that store data with complex
data types (audio, video, graphics data).

Database Administrators:

A person who has central control over the database system is called a
database administrator (DBA). The functions of the DBA are:

• Schema definition:

The DBA creates the original database schema by executing set of DDL
statements.

• Storage structure and access method definition:

The DBA defines the implementation details of the database schemas,


which are usually hidden from the users.

• Schema and physical-organization modification:


The DBA carries out changes to the schema and physical organization
to improve the performance.

• Granting of authorization for data access:

By granting different types of authorization to various users, the DBA


can enforce access controls on different parts of the database.

• Routine Maintenance:

1. The DBA periodically back-up the database, to prevent loss of


data in case of disasters.

2. The DBA ensures that there is enough free disk space is available
for normal operations.

3. The DBA monitors all the jobs running on the database and
ensures that performance is not degraded.

Database Architecture:

A DBMS is divided in to two modules:

1. Query Processor

2. Storage Manager

The Query Processor:

The Query Processor components in DBMS accepts SQL commands


generated from variety of user interfaces, produces query evaluation plans,
executes these plans with the database and returns the answers. The query
processor components are:

• DDL Interpreter:

This interprets DDL statements and records the definitions in the


data dictionary.

• DML Compiler:

This translates DML statements in query language into low-level


instructions that the query evaluation engine understands.

• Embedded DML Pre-compiler:


SQL commands can be embedded in application programs, which can
be converted into DML statements by this embedded DML pre-
compiler.

The pre-compiler must interact with the DML compiler to generate


the appropriate code.

• Query Evaluation Engine:

This executes low-level instructions generated by the DML compiler.

• Application Programs Object Code:

This is the executable code of the application programs, which the


query evaluation engine understands and executes them.

Naïve App. Sophisticated DBA


Users Programmers Users

App. App. Query DB


Interfaces Programs Tools Schema

App. Embedded DML DDL


Program DML Pre- Compiler Interpreter
Object Code Compiler

Query Processor

Query
Evaluation
Engine
Buffer File Authorization Transactio
Manager Manager & Integrity n Manager
Manager Storage Manager

Indices
Data
Disk Storage
Data Files Dictionary

The Storage Manager:

The storage manager is a program module that provides the interface


between the physical-level data stored in the database and the
programs/queries requesting the stored data from the database.

The storage manager components are:

• Authorization and Integrity Manager:

This tests for the satisfaction of integrity constraints and checks the
authority of users to access data.

• Transaction Manager:

This ensures that database remains in a consistent state despite the


system failures, and that concurrent execution proceed without
conflicting.

• File Manager:
This manages the allocation of space on disk storage and the data
structures used to represent information stored on disk.

• Buffer Manager:

This is responsible for fetching the data from disk storage to main
memory, and decides what data to cache in main memory.

In addition, the storage manager implements several data structures:

• Data Files:

This stores the database itself.

• Data Dictionary:

This stores metadata about the structure of the database.

• Indices:

This can provide fast access to data items.

Anda mungkin juga menyukai