You are on page 1of 73

Database Management System

MCA Department G.H.Raisoni Institute of information Technology, Nagpur

Database Management System

Unit-I
Database Concepts Introduction Data, Information, Metadata Terminology of file Association between fields Entities and their attributes, Relationship Records and files Abstraction and data integration Association between files (record types) Conventional file processing systems Database System    

Components of Database Management system-(Classification of DBMS users, DBMS facilities, Structure of a DBMS, Database access), Advantages and Disadvantages of DBMS, Three level architecture proposal for DBMS, Mapping between views, Data Independence.

Unit-I

Database Management System

Data
Data refers to a collection of facts usually collected as the result of experience, observation or experiment, or processes within a computer system, or a set of premises. This may consist of numbers, words or images, particularly as measurements or observations of a set of variables. Data is often viewed as a lowest level of abstraction from which information and knowledge are derived.

Unit-I

Database Management System

Metadata
Metadata (meta data, or sometimes metainformation) is "data about data", of any sort in any media. An item of metadata may describe an individual content item, or a collection of data including multiple content items and hierarchical levels, for example a database schema. In data processing, metadata is definitional data that provides information about or documentation of other data managed within an application or environment Metadata is structured data which describes the characteristics of a resource. It shares many similar characteristics to the cataloguing that takes place in libraries, museums and archives. The term "meta" derives from the Greek word denoting a nature of a higher order or more fundamental kind. A metadata record consists of a number of pre-defined elements representing specific attributes of a resource, and each element can have one or more values. Each metadata schema will usually have the following characteristics: a limited number of elements the name of each element the meaning of each element

Unit-I

Database Management System

Information
The information is processed data. Data and information are interrelated . Data can be an information and viceversa. The meaningful data is also called as an information. Knowledge can be achieved from processed data i.e. information.

Unit-I

Database Management System

Terminology of File
Data Raw facts that have little meaning unless they have been organized in some logical manner. The smallest piece of data that can be recognized by the computer is a single character, such as the letter A, the number 5, or some symbol such as; ? > * +. A single character requires one byte of computer storage. A character or group of characters (alphabetic or numeric) that has a specific meaning. A field might define a telephone numbers, a birth date, a customer name, a year-to-date (YTD) sales value, and so on. A logically connected set of one or more fields that describes a person, place, or thing. For example, the fields that comprise a record for a customer named J. D. Rudd might consist of J. D. Rudds name, address, phone number, date of birth, credit limit, unpaid balance, and so on. A collection of related records. For example, a file might contain data about ROBCOR Companys vendors; or, a file might contain the records for the students currently enrolled at Gigantic University.
Database Management System 6

Field

Record

File

Unit-I

Simple File System

Unit-I

Database Management System

Database System Vs. File System

Unit-I

Database Management System

Association between fields


1. One-to-one association (1:1 < ----- >) 2. One-to-many association (1:M < ------ >>) 3. Many-to-many association (M:M <<--- >>) 4. Many-to-one association (M:1 << ---->) 5. One-to-one conditional association (<----o--- >)

Unit-I

Database Management System

Entities and their attributes


Entity --> What is this table about?
Entity

Attribute (Field) --> What items of information are necessary to keep concerning this entity?
ID, name, department, year, advisor
Attribute

Unit-I

Database Management System

10

Entity = thing or object. Entity set = collection of similar entities.




Similar to a class in object-oriented languages.

Attribute = property of (the entities of) an entity set.




Attributes are simple values, e.g. integers or character strings, not structs, sets, etc.

Unit-I

Database Management System

11

Relationships
Relationship set is used in data modeling to represent an association between entity set. This association could have certain properties represented by the attributes of the relationship set. In is denoted by diamond.
Entity Set

Entity Set

Relationship

Unit-I

Database Management System

12

Records and Files


Record: The physical representation of an entity set is made by aggregating the attributes used to model the entity set. Such a representation is called a record type. An instance of a record type is a record occurrence. FILE: a collection of pages, each containing a collection of records. Must support:
  

insert/delete/modify record read a particular record (specified using record id) scan all records (possibly with some conditions on the records to be retrieved)

Unit-I

Database Management System

13

Example
Entity : Employee Attributes: Emp_id, Ename, Salary, Dept, Desig

A file is a collection of identical record type occurrence pertaining to an entity set and is labeled to identify the entity set.
Emp_id 101 102 Ename Sam Allen Salary 10000 15000 Dept Sales
Accounting

Desig Manager Project Leader

Record

Unit-I

Database Management System

14

Data Abstraction
Major aim of a DBMS is to provide users with an abstract view of data Hides certain details of how the data are stored & maintained DBMS must retrieve data efficiently Need for efficiency has led designers to use complex data structures to represent the data in the database Most DB users are not computer trained, developers hide complexity through several levels of abstraction to simplify users interaction with the systems
Unit-I Database Management System 15

3 levels of Data Abstraction


Physical or Internal Level
 

Lowest level of abstraction describes how data are actually stored Describes complex low-level data structures in detail Describes what data are stored in the DB & what relationships exist among those data Describes the entire DB in terms of relatively simpler structures Highest level of abstraction which describes only a part of the DB Users view of the DB. This level describes that part of the DB that is relevant to each user
Database Management System 16

Logical or Conceptual Level


 

View or External Level


 

Unit-I

3 levels of Data Abstraction


Logical or Conceptual Level  Describes what data are stored in the DB & what relationships exist among those data  Describes the entire DB in terms of relatively simpler structures  Implementation of these simple structures at this level may involve complex physical-level structures  Users of the logical level need not be aware of this complexity  DBAs, who decide what information to keep in DB, use the logical level of abstraction
Unit-I Database Management System 17

Levels of Abstraction

Unit-I

Database Management System

18

Levels of Abstraction
Many views, single conceptual (logical) schema and physical schema.


View 1

View 2

View 3

Conceptual Schema Physical Schema

Views describe how users see the data. Conceptual schema defines logical structure Physical schema describes the files and indexes used.

Unit-I

Database Management System

19

What is Data Integration?


The problem of providing uniform (sources transparent to users) access to (query) multiple (even 2 is a problem) autonomous (not affect the behavior of sources) heterogeneous (different data models, schemas) structured (at least semistructured) data sources (not only databases)
Unit-I Database Management System 20

Association between Files


1. 2. 3. 4. 5. 6. 7. One-to-one association One-to-many association Many-to-many association Many-to-one association Multiple Association One-to-one conditional association Recursive association i) One-to-many recursive association ii) Many-to-many recursive association

Unit-I

Database Management System

21

Multiple Association

On Issues: On Receipts:
Unit-I

SOH = SOH - Quantity of Issue SOH=SOH +Quantity of receipt


Database Management System 22

One to one Conditional Association

Unit-I

Database Management System

23

Recursive Association

Unit-I

Database Management System

24

Conventional File Processing System


The conventional file processing system deals with the files handling. All the operations such as insertion, deletion, updations are performed on files which faces problems due to some drawbacks.

Unit-I

Database Management System

25

Example of Conventional File Processing System


Patients

Registration
Out patient treatment file

Society

Patient file

Out-Patient

In-Patient

Account Section
Cured Patients Invoice File

Unit-I

In-Patient Treatment file

Database Management System

26

Drawbacks of conventional file processing System


Uncontrolled redundancy of data Inconsistency of data Inflexibility of the system to meet future demand Limiting data sharing Poor enforcement of standards Excessive programming maintenance Low programming productivity

Unit-I

Database Management System

27

What is DBMS?
A database is a collection of non-redundant data which can be shared by different application systems  stresses the importance of multiple applications, data sharing  the spatial database becomes a common resource for an agency implies separation of physical storage from use of the data by an application program, i.e. program/data independence  the user or programmer or application specialist need not know the details of how the data are stored  such details are "transparent to the user" changes can be made to data without affecting other components of the system. e.g.  change format of data items (real to integer, arithmetic operations)  change file structure (reorganize data internally or change mode of access)  relocate from one device to another, e.g. from optical to magnetic storage, from tape to disk
Unit-I Database Management System 28

The DBMS
The Database


A shared collection of logically related data and its data description, defined once but used simultaneously by many applications and users

The DBMS


A single tool for:


Data definition (Data Definition Language) Data manipulation (Data Manipulation Language).

Unit-I

Database Management System

29

Database Management System

Unit-I

Database Management System

30

The ultimate purpose of a database management system?

Is to transform

Data

Information

Knowledge

Action

Unit-I

Database Management System

31

Components of DBMS Environment

Unit-I

Database Management System

32

Hardware


Can range from a PC to a network of computers. DBMS, operating system, network software (if necessary) and also the application programs. Used by the organization and a description of this data called the schema.

Software


Data


Unit-I

Database Management System

33

Procedures


Instructions and rules that should be applied to the design and use of the database and DBMS. It includes various types users.

People


Unit-I

Database Management System

34

Components of DBMS
        
Unit-I

DDL Compiler Data Manager File Manager Disk Manager Query Processor Telecommunication System Data Files Data Dictionary Access Aids
Database Management System 35

Database Users/Perspectives
Inital Role Continuing Role Systems analysts/ Programmers  Software engineers

Database Designers

DBA

End-users

 Your role in the project

 Head DBA  Multiple Staff DBAs

 Multiple Levels of End Users

Unit-I

Database Management System

36

Types of Users
  

Nave Users
E.g. Bank-teller, Shop Assistant

Specialized Users
CAD, Expert systems, Geographic data

Sophisticated Users
Analysts creating & submitting queries OLAP and Data Mining

 

Application Programmers
Use DML, Scripting, Report Generators

Database Administrator
Use DDL for Schema Definition; Storage structure and access definition; Physical organisation; Authorization & security; Routine Maintenance

Unit-I

Database Management System

37

Classification of DBMS Users


The users of the database system can be classified in the following groups, depending on their degree of expertise or the mode of their interactions with the DBMS. 1. Nave users 2. Online Users 3. Application Programmers 4. Database administrator
Unit-I Database Management System 38

Nave Users
Naive users who need not have aware of the present of the database system or any other system.. A user of an automatic teller falls under this category. The user is instructed through each step of a transaction; he or she responds by pressing a coded key or entering a numeric value. The operations that can be performed by this calls of users are very limited and affect a precise portion of the database; in case of the user of the automatic teller machine, only one or more of her or his own accounts. Other such naive users are where the type and range of response is always indicated to the user. Thus, a very competent database designer could be allowed to use a particular database system only as a naive user.

Unit-I

Database Management System

39

Online and Application Users


Online users: There are users who may communicate with the database directly via an online terminal or indirectly via a user interface and application program. These users are aware of the presence of the database system and may have acquired a certain amount of expertise in the limited interaction they are permitted with the database through the intermediate application program. The more sophisticated of these users may also use a data manipulation language to manipulate the database directly. On-line users can also be naive users requiring help such as menus. Application Programmers: Professional programmers who are responsible for developing application programs or user interfaces utilized by the naive and online users fall into this category. The application programs could be written in a general purpose programming language such as Assembler C, COBOL, FORTRAN, PASCAL, or PL/I and include the commands required to manipulate the database.
Unit-I Database Management System 40

Database Administrator
Centralized control of the database is exerted by a person or group of persons under the supervision of a high level administrator. This person or group is referred to as the database administrator (DBA). They are users who are the most familiar with the database and are responsible for creating, modifying and maintaining its three levels. The DBA us the custodian of the data and controls the database structure. The DBA administers the three levels of the database and in consultation with the overall user community, sets up the definition of the global view or conceptual level of the database. The DBA further specifies the external view of the various users and applications and is responsible for definition and implementation of the internal level, including the storage structure and access methods to be used for the optimum performance of the DBMS.
Unit-I Database Management System 41

DBMS Facilities
The two main types of facilities that are provided by the DBMS are 1. The data definition facility or the Data Definition Language (DDL) 2. The data manipulation facility or the Data Manipulation Language (DML)

Unit-I

Database Management System

42

Data Definition Language


The Data Definition Language (DDL) is used to create and destroy databases and database objects. These commands will primarily be used by database administrators during the setup and removal phases of a database project. Let's take a look at the structure and usage of four basic DDL commands:
  

CREATE ALTER DROP

Unit-I

Database Management System

43

Data Manipulation Language


Data Manipulation is:
   

retrieval of information from the database insertion of new information into the database deletion of information in the database modification of information in the database

A DML is a language which enables users to access and manipulate data. The goal is to provide efficient human interaction with the system. There are two types of DML:
 

procedural: the user specifies what data is needed and how to get it nonprocedural: the user only specifies what data is needed
Easier for user May not generate code as efficient as that produced by procedural languages

A query language is a portion of a DML involving information retrieval only. The terms DML and query language are often used synonymously.
Unit-I Database Management System 44

Structure of DBMS
Structure of a DBMS A typical DBMS has a layered architecture. The figure does not show the concurrency control and recovery components. This is one of several possible architectures; each system has its own variations. Query Optimization and Execution Relational Operators

These layers must consider concurrency control and recovery

Files and Access Methods Buffer Management Disk Space Management

DB

Unit-I

Database Management System

45

Unit-I

Database Management System

46

Database Activities
Database Activities (in order)

Define

Specify data types, structures and constraints for the data to be stored in the database

Construct

Storing the data on some storage medium that is controlled by the DBMS

Manipulate
Unit-I

Querying, updating and generating reports from the data


Database Management System 47

Steps in Database Access


Any access to the stores data is done by the data manager. Steps in data access

Users Query

Request specific record

Request specific block (s)

Input/Output Block(s)

DBMS-user interface

Data Manager

File Manager

Disk Manager

Database

Response to user

Requested record

Requested block (s)

Block(s) from secondary storage

Unit-I

Database Management System

48

Procedure of Database access


A block is a unit of physical input/output operations between primary and secondary storage. The disk manager retrieves the block and sends it to the file manager, which sends the required record to the data manager.

Unit-I

Database Management System

49

Procedure of Database access


A users request for data is received by the data manager, which determines the physical record required. The decision as to which physical record is needed may require some preliminary consultation of the database and/or the data dictionary prior to the access of the actual data itself. The data manager sends the request for a specific physical record to the file manger. The file manager decides which physical block of the secondary storage device contains the required record and sends the request for the appropriate block to the disk manager.
Unit-I Database Management System 50

Advantages and Disadvantages of DBMS


Control of data redundancy. Data consistency More information from the same amount of data. Sharing of data. Improved data integrity. Improved security. Enforcement of standards. Economy of scale.
Unit-I Database Management System 51

Advantages
Control of data redundancy. Data consistency More information from the same amount of data. Sharing of data. Improved data integrity. Improved security. Enforcement of standards. Economy of scale.
Unit-I Database Management System 52

Disadvantages
Complexity Size Cost of DBMS Additional hardware costs Cost of conversion Performance Higher impact of a failure

Unit-I

Database Management System

53

Three-Level Architecture of DBMS


The architecture of a database management system can be broadly divided into three levels : a. External level b. Conceptual level c. Internal level

Unit-I

Database Management System

54

Three-level architecture

Unit-I

Database Management System

55

Objectives of Three-Level Architecture


All users should be able to access same data. A user's view is immune to changes made in other views. Users should not need to know physical database storage details. DBA should be able to change database storage structures without affecting the users' views. Internal structure of database should be unaffected by changes to physical aspects of storage. DBA should be able to change conceptual structure of database without affecting all users.
Unit-I Database Management System 566

Instances & Schemas


Is independent of the DBMS, application programs, & physical considerations Conceptual schema is translated into a schema that is compatible with the chosen DBMS Relationships between entities as reflected in the conceptual schema may not be implement able with the chosen DBMS Version of the conceptual schema that can be presented to the DBMS is called the Logical Schema In a RDBMS, the logical schema describes all relations stored in the DB
Unit-I Database Management System 57

Instances & Schemas


Users are presented with the subsets, called subschema, of the logical schema Subschema are also in terms of the data model of the DBMS Allow data access to be customized & authorized at the level of individual users or group of users Each subschema consists of a collection of one or more views & relations from the logical schema Logical schema is mapped to physical storage such as disk or tape
Unit-I Database Management System 58

Three Schema Architecture


End Users Describes part of the database relevant to a user May be different representations of the same data External View External May include derived or calculated dataView

External Level

Describes what data is store & its relationships: entities, their attributes and relationships Conceptual Schema constraints on the data security and integrity information
mapping

mapping

Conceptual Level

Allocating storage space for data and indexes Describing the formsInternal will take when stored records Record placement Schema Data compression and encryption Managed by the operating system The mechanics of storing data on a device
Unit-I

Internal Level

Physical Data Organisation


59

Stored Database

Database Management System

External view 1 Sno Fname Lname Age Salary

External view 2 StaffNo Surname Branch

S-Id

Fname

Lname

DoB

Salary

Location

Conceptual Level

struct STAFF { int StaffNum; int BranchNo; char Fname[15]; char Lname[15]; struct DATE DateOfBirth; float Salary; char branch[3]; struch STAFF *next; // pointer to next record };

Internal Level

Unit-I

Database Management System

60

External Level
This is the highest level, one that is closest to the user. It is also called the user view. The user view is different from the way data is stored in the database. This view describes only a part of the actual database. Because each user is not concerned with the entire database, only the part that is relevant to the user is visible. For example, end users and application programmers get different external views.

Unit-I

Database Management System

61

Each user uses a language to carry out database operations. The application programmer uses either a conventional thirdgeneration language, such as COBOL or C, or a fourthgeneration language specific to the DBMS, such as visual FoxPro or MS Access. The end user uses a query language to access data from the database. A query language is a combination of three subordinate language : Data Definition Language (DDL) Data Manipulation Language (DML) Data Control Language (DCL) The data definition language defines and declares the database object, while the data manipulation language performs operations on these objects. The data control language is used to control the users access to database objects.
Unit-I Database Management System 62

Conceptual Level
This level comes between the external and the internal levels. The conceptual level represents the entire database as a whole, and is used by the DBA. This level is the view of the data as it really is. The users view of the data is constrained by the language that they are using. At the conceptual level, the data is viewed without any of these constraints.

Unit-I

Database Management System

63

Internal Level
This level deals with the physical storage of data, and is the lowest level of the architecture. The internal level describes the physical sequence of the stored records

Unit-I

Database Management System

64

Mapping between views


Mapping determines the correspondence between one level an another. There are two levels of mapping involved in this architecture. One is between the external and the conceptual levels, while the other is between the conceptual and the internal levels. The external-conceptual mapping determines the correspondence between the conceptual and the user views. This specifies how a user views the conceptual data. The conceptual-internal mapping determines the correspondence between the conceptual and internal views. It specifies how the conceptual data is stored.

Unit-I

Database Management System

65

Data Independence
The first step in designing a database is to define the conceptual level. The conceptual level is then mapped to the external level. Each user view and the requirement is taken into consideration. Next, the conceptual-internal mapping is done. The way data is stored is derived from the conceptual level. Thus three-level architecture of a DBMS helps achieve data independence.

Unit-I

Database Management System

66

Data Independence
Logical Data Independence


The capacity to change the conceptual schema without having to change the external schema or application programs

Physical Data Independence




The capacity to change the internal schema without having to change the conceptual schema

Unit-I

Database Management System

67

Data Independence
Logical Data Independence  Refers to immunity of external schemas to changes in conceptual schema.  Conceptual schema changes e.g. addition/removal of entities.  Should not require changes to external schema or rewrites of application programs.

Unit-I

Database Management System

68 12

Data Independence
Physical Data Independence  Refers to immunity of conceptual schema to changes in the internal schema.  Internal schema changes e.g. using different file organizations, storage structures/devices.  Should not require change to conceptual or external schemas.

Unit-I

Database Management System

69 13

Advantages and disadvantages




The three -Schema Architecture can make it easier to achieve true data independence Mappings create an overhead during compilation or execution of a query or a program Not implemented fully by DBMSs

Unit-I

Database Management System

70

Nave Users

Application Programmers

Sophisticated Users

Database Administrator

Application Interfaces

Application Programs

Query Tools

Administration Tools

Query Processor

Compiler and Linker Application program object code Query Evaluation Engine

DML Queries

DDL Interpreter

DML Compiler and organiser

Storage Manager

Buffer Manager

File Manager

Authorisation & Integrity Manager

Transaction Manager

Disk Storage

Indices

Data dictionary

Application Data

Statistical data

Unit-I

Database Management System

71

Assignment
Q.1 Explain the differences between conventional file processing system and database system. Q.2 Define following terms  Data  Metadata  Information Q.3 What are different components of DBMS environment. Q.4 What do you mean by Data Abstraction and Data Integration. Q.5 How Data Independence is achieved in DBMS? Q.6 Define Entity, Attribute and Relationship with example. Q.7 What do you mean by association? What are different types of associations between files. Q.8 What are different types of association between fields Explain Q.9 Explain in detail about architecture of DMBS with all aomponents. Q.10 What are different facilities provided by DBMS? Q.11 Explain in detail about procedure of data access in DBMS.
Unit-I Database Management System 72

Assignment

Last Date of Submission 26th Deco8

Unit-I

Database Management System

73