Top Banner
Database Management Systems MIT 22033 Introduction By S. Sabraz Nawaz
42

Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Mar 18, 2018

Download

Documents

hanhi
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Database Management

Systems

MIT 22033

Introduction

By S. Sabraz Nawaz

Page 2: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Recommended Reading…

Database Management Systems – 3rd Edition, Ramakrishnan,

Gehrke

Murach’s SQL Server 2008 for Developers

Any book that is on SQL Server development as well as any book that is on

database

2 B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz

Page 3: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Introduction

• What is a database?

A database is a collection of related data

(examples???)

• A database management system (DBMS) is a software package designed to create and maintain databases

(examples?)

3 B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz

Page 4: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Introduction (contd…)

The DBMS is a general-purpose software system facilitates the processes of

Defining

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

Constructing

The process of storing the data itself on some storage medium that is controlled by the DBMS.

Manipulating

Manipulating a database includes such functions as querying the database to retrieve specific data, updating the database to reflect changes, and generating reports from the data.

4 B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz

Page 5: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Examples

Today, DBMSs are an essential part of any Enterprise Information System

University Database

Credit Card Processing Systems

Airline Reservation Systems

Banking System

5 B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz

Page 6: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Example: University DB

University database maintaining information concerning: Students,

Courses, and

Grades

6 B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz

Page 7: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Example: University DB (contd…)

It shows the database structure and a few sample data.

It is organized as five files.

The STUDENT file – data on each student,

The COURSE file – data on each course,

The SECTION file – data on each section of a course,

The GRADE_REPORT file – data on grades that students

receive in the various sections they have completed, and

The PREREQUISITE file – data on prerequisite of each course.

7 B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz

Page 8: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Need for a DBMS

Traditional File System provided by the Operating System is

insufficient to meet the requirements of enterprise applications

scenario:

A company has a large collection (500 GB) of data on database.

This data is accessed concurrently by several employees.

Questions about the data must be answered quickly, changes

made to the data by different users must be applied

consistently, and access to certain parts of the data must be

restricted.

8 B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz

Page 9: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Advantages of using a DBMS

Data independence

Efficient data access

Data integrity and security

Easy data administration

Concurrent access, recovery from crashes

Reduced application development time

9 B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz

Page 10: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Levels of Abstraction in a DBMS(contd)

DBMS is described at three levels of abstraction:

External Schema many views describe how

users see the data

Conceptual Schema defines logical structure

Physical Schema describes the files and indexes used

Note:

Information about the schemas is stored

in the system catalog

10

Physical Schema

Conceptual Schema

View 1 View 2 View 3

DISK

B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz

Page 11: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Levels of Abstraction in a DBMS(contd)

Conceptual schema

describes the stored data in terms of the data model of the

DBMS

in a relational DBMS, the conceptual schema describes all relations that are stored in the database

11 B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz

Page 12: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Levels of Abstraction in a DBMS(contd)

Physical schema

describe storage details

summarizes how the relations described in the conceptual schema are actually stored on secondary storage devices such as disks and tapes

decide what file organizations used to store the relations

create indexes to speed up data retrieval operations

12 B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz

Page 13: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Levels of Abstraction in a DBMS(contd)

External schemas

allow data access to be customized (and authorized) at the level of individual users or groups of users

any given database has exactly one conceptual schema and one physical schema because it has just one set of stored relations, but it may have several external schemas

13 B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz

Page 14: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Data independence

Application programs are independent of data

representation and storage details.

The structure of data files is stored in the DBMS catalog

separately from the access programs.

E.g. a file access program may be written in such a

way that it can access only STUDENT records of the

structure.

B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz 14

Page 15: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Data independence (cont)

To add another piece of data to each STUDENT record, say

Birthdate,

need to change the description of STUDENT records in the catalog to

reflect the inclusion of the new data item Birthdate; no program

changed.

The next time a DBMS program refers to the catalog, the new structure

of STUDENT records will be accessed and used.

15 B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz

Page 16: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Efficient data access

DBMS utilises sophisticated techniques to store and

retrieve data efficiently, including support for very large

files, index structures and query optimisation.

Storage methods can be improved without changing the

application programs

16 B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz

Page 17: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Data integrity and security

DBMS can enforce integrity constraints on the data

e.g., checking salary increase against dept budget

Access controls govern what data is visible to different class of

users

17 B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz

Page 18: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Easy data administration

Centralising administration of data shared among many users

- data managed by professionals

Organise data to

- meet user needs

- minimise redundancy

Fine tuning of storage for efficient retrieval

18 B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz

Page 19: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Concurrent access and Crash recovery

Concurrent accesses are scheduled by DBMS

- users can think of the data as being accessed by one user at

a time

DBMS protects users from the effects of system failure

19 B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz

Page 20: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Reduced application development time

DBMS supports many functions common to applications that

access the database

These applications are likely to be more robust than

applications developed from scratch because many important

tasks are handled by DBMS instead of being implemented by

the application

20 B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz

Page 21: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

When NOT to use a DBMS

High initial investment (DBMS is an expensive software package)

Applications use small amounts of data

Lack of resources (disk space, memory, etc.) to support a database

Single-user applications

Overhead for flexible querying, security, concurrent access & crash recovery is not required

21 B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz

Page 22: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Describing & Storing Data in a DBMS

A data model is a collection of high-level data description

constructs used to model the application domain

Data model hides the low-level storage details

Most commercial database systems are based on the

relational data model

22 B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz

Page 23: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Describing & Storing Data in a DBMS

However, it is easier to use a semantic data model to model

an application domain. A well-known semantic data model is

the Entity Relationship (ER) Model

23 B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz

Page 24: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Describing & Storing Data in a DBMS

In relational data model, the main construct is a relation.

A relation has fields that belong to it which contain the name & data type of each field

A description of data in terms of a data model is called the schema.

Every relation has a schema, which describes the name of the relation, name of each attribute (field or column), and the type of each column.

e.g.

Students(sid: string, name: string, login: string,

age: integer, gpa: real)

24 B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz

Page 25: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

An example instance of the Students relation

B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz 25

SID Name Login Age GPA

53666 SaNa [email protected] 33 3.9

53668 Kumar [email protected] 29 3.2

53670 Sanath [email protected] 41 3.8

Page 26: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Describing & Storing Data in a DBMS

In addition to relational data model… Hierarchical model

Network model

Object oriented model

Object relational model

26 B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz

Page 27: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Queries In A DBMS

• With reference to a fictitious university database

1. What is the name of the student with student ID 123456?

2. What is the average salary of lecturers who teach the

course with course ID CS564?

3. How many students are enrolled in course CS564?

4. Is there any student with a GPA less than 3.0 enrolled in

course CS564?

• These questions involving the data stored in a DBMS are

called queries

B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz 27

Page 28: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Queries In A DBMS…

• A DBMS provides a specialized language, called the query

language in which queries can be posed

• Relational calculus is a formal query language based on

mathematical logic

• Relational algebra is another formal query language, based

on a collection of operators for manipulating relations, which

is equivalent in power to the calculus

B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz 28

Page 29: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Database Design Process

MIT 22033, S. Sabraz Nawaz 29 B.Sc in MIT, SEUSL

Page 30: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Database Design Process

Requirements Analysis

Conceptual Database

Design

Logical Database

Design

Schema Refinement

Physical Database

Design

Security Design

Database design process can be divided into 6 major steps: (given in Raghu’s text book)

MIT 22033, S. Sabraz Nawaz 30 B.Sc in MIT, SEUSL

Page 31: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Requirements Analysis

• This step answers the following

question: “What users want from the database?”

- what is going to be stored in the database

- what applications are going to be built on top

the database

- what are the most frequently asked queries

Requirements Analysis

MIT 22033, S. Sabraz Nawaz 31 B.Sc in MIT, SEUSL

Page 32: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Requirements Analysis…

Result:

A well-written concise

document enumerating the

user’s requirements

Requirements Analysis

MIT 22033, S. Sabraz Nawaz 32 B.Sc in MIT, SEUSL

Page 33: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Requirements Analysis…

For example: a library database…

Data to be stored can be…

• Record of all books in the library

• Record of members of the library o Students

o Faculty

o Other members

• Record members’ borrowing information

Requirements Analysis

MIT 22033, S. Sabraz Nawaz 33 B.Sc in MIT, SEUSL

Page 34: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Requirements Analysis…

Some applications on top of

the database can be…

• Renewal service (may be on-

line)

• Borrowing-Lending service

• Resource reservation system

(may be on-line)

• Resource request service

(may be on-line)

Requirements Analysis

MIT 22033, S. Sabraz Nawaz 34 B.Sc in MIT, SEUSL

Page 35: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Conceptual Database Design

The information gathered in

the requirements analysis

phase is used to create a

high-level description of

the data in a conceptual

data model. (Semantic Data

Model, e.g. E-R Diagram )

Requirements Analysis

Conceptual Database

Design

MIT 22033, S. Sabraz Nawaz 35 B.Sc in MIT, SEUSL

Page 36: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Logical Database Design

In this step, we determine the DBMS to implement the database & also the data model

We utilize the conceptual schema created in the previous step and convert it into a schema of a particular data model (e.g. Relational Database Schema)

Requirements Analysis

Conceptual Database

Design

Logical Database

Design

MIT 22033, S. Sabraz Nawaz 36 B.Sc in MIT, SEUSL

Page 37: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Schema Refinement

The schema created

by the logical

database design

phase is further

refined for potential

problems such as

redundancies (e.g.

Normalization)

Requirements Analysis

Conceptual Database Design

Logical Database Design

Schema Refinement

MIT 22033, S. Sabraz Nawaz 37 B.Sc in MIT, SEUSL

Page 38: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Physical Database Design

In this step, performance

criteria are taken into

consideration and further

enhancements to the schema

& creation of indexes are

considered

Requirements Analysis

Conceptual Database

Design

Logical Database

Design

Schema Refinement

Physical Database

Design

MIT 22033, S. Sabraz Nawaz 38 B.Sc in MIT, SEUSL

Page 39: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Security Design

In this step, different user groups and their roles are identified. Appropriate levels of access are then provided to the data ensuring that users have access to only the necessary data.

Requirements Analysis

Conceptual Database

Design

Logical Database

Design

Schema Refinement

Physical Database

Design

Security Design

MIT 22033, S. Sabraz Nawaz 39 B.Sc in MIT, SEUSL

Page 40: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

The story is…

Requirements Analysis

Conceptual Database

Design

Logical Database

Design

Schema Refinement

Physical Database

Design

Security Design

ER Diagram

Conceptual Schema or Logical Schema

MIT 22033, S. Sabraz Nawaz 40 B.Sc in MIT, SEUSL

Page 41: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Assignment #01

1. What is a data model? Describe the data models with

example

2. Clearly explain the architecture of a DBMS

• Submission Deadline 07/12/2012

• Use IEEE Referencing Style

B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz 41

Page 42: Database Management Systems - sabraz · PDF fileLevels of Abstraction in a DBMS(contd) DBMS is described at three levels of abstraction: External Schema many views describe how users

Questions

? 42 B.Sc in MIT, SEUSL MIT 22033, S. Sabraz Nawaz