55
Database Management Systems MIT 22033 Lesson 01 - Introduction By S. Sabraz Nawaz

Database Management Systems MIT 22033

Embed Size (px)

DESCRIPTION

Introduction A database management system (DBMS) is a software package designed to create and maintain databases (examples?) MIT 22033, By: S.Sabraz Nawaz B.Sc in MIT, SEUSL

Citation preview

Page 1: Database Management Systems MIT 22033

Database Management Systems

MIT 22033Lesson 01 - Introduction

By S. Sabraz Nawaz

Page 2: Database Management Systems MIT 22033

Introduction

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

2B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz

Page 3: Database Management Systems MIT 22033

Introducing the Database

• What is a database? A database is a collection of related data (University Database, Credit Card Processing Systems, Airline Reservation Systems, Banking System, etc.)

• A database is a shared, integrated computer structure that stores a collection of: End-user data, that is, raw facts of interest to the end user.

• Efficient data management typically requires the use of a computer database.

• Metadata, or data about data, through which the end-user data are integrated and managed.

B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz 3

Page 4: Database Management Systems MIT 22033

Database Management System (DBMS)

• A is a collection of programs that manages the database

structure and controls access to the data stored in the database.

In a sense, a database resembles a very well-organized

electronic filing cabinet in which powerful software, known as

a database management system, helps manage the cabinet’s

contents.

B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz 4

Page 5: Database Management Systems MIT 22033

DBMS: Role and Advantages

• The DBMS serves as the intermediary between the user and the database. The database structure itself is stored as a collection of files, and the only way to access the data in those files is through the DBMS.

B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz 5

Page 6: Database Management Systems MIT 22033

DBMS: Role

B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz 6

Page 7: Database Management Systems MIT 22033

DBMS: Role…

• The DBMS receives all application requests and translates them into the complex operations required to fulfill those requests. The DBMS hides much of the database’s internal complexity from the application programs and users.

• The application program might be written by a programmer using a programming language such as Visual Basic.NET, Java, or C#, or it might be created through a DBMS utility program.

B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz 7

Page 8: Database Management Systems MIT 22033

DBMS: Advantages

• Having a DBMS between the end user’s applications and the

database offers some important advantages. o First, the DBMS enables the data in the database to be shared among

multiple applications or users.

o Second, the DBMS integrates the many different users’ views of the

data into a single all-encompassing data repository.

B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz 8

Page 9: Database Management Systems MIT 22033

DBMS: Advantages - Improved data sharing

• The DBMS helps create an environment in which end users have better access to more and better-managed data. Such access makes it possible for end users to respond quickly to changes in their environment

• Concurrent accesses are scheduled by DBMS: users can think of the data as being accessed by one user at a time

B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz 9

Page 10: Database Management Systems MIT 22033

DBMS: Advantages - Improved data security

• The more users access the data, the greater the risks of data security breaches. Corporations invest considerable amounts of time, effort, and money to ensure that corporate data are used properly. A DBMS provides a framework for better enforcement of data privacy and security policies.

B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz 10

Page 11: Database Management Systems MIT 22033

DBMS: Advantages - Better data integration

• Wider access to well-managed data promotes an integrated view of the organization’s operations and a clearer view of the big picture. It becomes much easier to see how actions in one segment of the company affect other segments.

B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz 11

Page 12: Database Management Systems MIT 22033

DBMS: Advantages - Minimized data inconsistency

• Data inconsistency exists when different versions of the same data appear in different places.

• The probability of data inconsistency is greatly reduced in a properly designed database.

B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz 12

Page 13: Database Management Systems MIT 22033

DBMS: Advantages - Improved data access

• The DBMS makes it possible to produce quick answers to ad hoc queries.

• From a database perspective, a query is a specific request issued to the DBMS for data manipulation—for example, to read or update the data.

• Simply put, a query is a question, and an ad hoc query is a spur-of-the-moment question. The DBMS sends back an answer (called the query result set) to the application.

• Example?

B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz 13

Page 14: Database Management Systems MIT 22033

DBMS: Advantages - Improved decision making

• Better-managed data and improved data access make it possible to generate better-quality information, on which better decisions are based. The quality of the information generated depends on the quality of the underlying data.

• Data quality is a comprehensive approach to promoting the accuracy, validity, and timeliness of the data. While the DBMS does not guarantee data quality, it provides a framework to facilitate data quality initiatives.

B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz 14

Page 15: Database Management Systems MIT 22033

DBMS: Advantages - Increased end-user productivity

• The availability of data, combined with the tools that transform data into usable information, empowers end users to make quick, informed decisions that can make the difference between success and failure in the global economy.

B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz 15

Page 16: Database Management Systems MIT 22033

DBMS: Advantages- 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

• Note: The advantages of using a DBMS are not limited to the few just listed. In fact, you will discover many more advantages as you learn more about the technical details of databases and their proper design.

16B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz

Page 17: Database Management Systems MIT 22033

Types of Databases

• A DBMS can support many different types of databases. Databases can be classified according to the number of users, the database location(s), and the expected type and extent of use.

B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz 17

Page 18: Database Management Systems MIT 22033

Types of Databases: Number of Users

• A single-user database supports only one user at a time. In other words, if user A is using the database, users B and C must wait until user A is done. A single-user database that runs on a personal computer is called a desktop database.

• A multiuser database supports multiple users at the same time. When the multiuser database supports a relatively small number of users (usually fewer than 50) or a specific department within an organization, it is called a workgroup database.

• When the database is used by the entire organization and supports many users (more than 50, usually hundreds) across many departments, the database is known as an enterprise database.

B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz 18

Page 19: Database Management Systems MIT 22033

Types of Databases: Location

• A database that supports data located at a single site is called a centralized database.

• A database that supports data distributed across several different sites is called a distributed database.

B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz 19

Page 20: Database Management Systems MIT 22033

Types of Databases: Time and Usage

• Based on how DBMS are used and on the time sensitivity of the information gathered from them:o Operational Database (Transactional or production database)o Data warehouse

B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz 20

Page 21: Database Management Systems MIT 22033

Types of Databases: Time and Usage Operational Database

• Transactions such as product or service sales, payments, and supply purchases reflect critical day-to-day operations. Such transactions must be recorded accurately and immediately

• A database that is designed primarily to support a company’s day-to-day operations is classified as an operational database (sometimes referred to as a transactional or production database).

B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz 21

Page 22: Database Management Systems MIT 22033

Types of Databases: Time and Usage data warehouse

• A data warehouse focuses primarily on storing data used to generate information required to make tactical or strategic decisions. Such decisions typically require extensive “data massaging” (data manipulation) to extract information to formulate pricing decisions, sales forecasts, market positioning, and so on.

• Most decision support data are based on data obtained from operational databases over time and stored in data warehouses. Additionally, the data warehouse can store data derived from many sources. To make it easier to retrieve such data, the data warehouse structure is quite different from that of an operational or transactional database.

B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz 22

Page 23: Database Management Systems MIT 22033

Example of a database: University DB

• University database maintaining information concerning:o Studentso Courses, andoGradeso…

23B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz

Page 24: Database Management Systems MIT 22033

24

An example of a database that stores students and their grades of followed courses

STUDENT Name StudentNumber Class Major

  Smith 17 1 CSBrown 8 2 CS

COURSE CourseName CourseNumber CreditHouse Department

  Intro to Computer Science CS 1310 4 CS

Data Structures CS 3320 4 CS

Discrete Mathematics MATH 2410 3 MATH

Database CS 3380 3 CS

SECTION Sectionaldentifier CourseNumber Semester Year Instructor

  85 MATH 2410 Fall 98 King92 CS 1310 Fall 98 Anderson

102 CS 3320 Spring 99 Knuth112 MATH 2410 Fall 99 Chang119 CS 1310 Fall 99 Anderson

135 CS 3380 Fall 99 Stone

GRADE_REPORT StudentNumber Sectionaldentifier Grade   17 112 B

17 119 C8 85 A8 92 A8 102 B8 135 A

B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz

Page 25: Database Management Systems MIT 22033

Example: University DB (contd…)

• It shows the database structure and a few sample data.• It is organized as five files.

o The STUDENT file – data on each student,o The COURSE file – data on each course,o The SECTION file – data on each section of a course,o The GRADE_REPORT file – data on grades that students

receive in the various sections they have completed, ando The PREREQUISITE file – data on prerequisite of each course.

25B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz

Page 26: Database Management Systems MIT 22033

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.

26B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz

Page 27: Database Management Systems MIT 22033

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

27B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz

Page 28: Database Management Systems MIT 22033

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

28B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz

Page 29: Database Management Systems MIT 22033

Describing & Storing Data in a DBMS (cont.…)

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

o e.g. Students(sid: string, name: string, login: string, age: integer, gpa: real)

29B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz

Page 30: Database Management Systems MIT 22033

An example instance of the Students relation

B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz 30

SID Name Login Age GPA

53666 SaNa [email protected] 33 3.8

53668 Kumar [email protected] 29 3.2

53670 Sanath [email protected] 41 3.9

Page 31: Database Management Systems MIT 22033

Describing & Storing Data in a DBMS (cont.….)

• In addition to relational data model…o Hierarchical modelo Network modelo Object oriented modelo Object relational model

31B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz

Page 32: Database Management Systems MIT 22033

Levels of Abstraction in a DBMS

• To illustrate the meaning of data abstraction, consider the example of automotive

design.

• A car designer begins by drawing the concept of the car that is to be produced. Next,

engineers design the details that help transfer the basic concept into a structure that can

be produced. Finally, the engineering drawings are translated into production

specifications to be used on the factory floor.

• As you can see, the process of producing the car begins at a high level of abstraction

and proceeds to an ever-increasing level of detail. The factory floor process cannot

proceed unless the engineering details are properly specified, and the engineering

details cannot exist without the basic conceptual framework created by the designer.

32B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz

Page 33: Database Management Systems MIT 22033

Levels of Abstraction in a DBMS

B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz 33

Page 34: Database Management Systems MIT 22033

Levels of Abstraction in a DBMS

• DBMS is described at four levels of abstraction:

o External Model

o Conceptual Model

o Internal Model

o Physical Model

34B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz

Page 35: Database Management Systems MIT 22033

Levels of Abstraction in a DBMS:

External Model• The external model is the end users’ view of the data environment. The term

end users refers to people who use the application programs to manipulate the data and generate information. End users usually operate in an environment in which an application has a specific business unit focus.

• Companies are generally divided into several business units, such as sales, finance, and marketing. Each business unit is subject to specific constraints and requirements, and each one uses a data subset of the overall data in the organization.

• Therefore, end users working within those business units view their data subsets as separate from or external to other units within the organization.

• A specific representation of an external view is known as an external schema.

• Because data are being modeled, ER diagrams will be used to represent the external views.

B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz 35

Page 36: Database Management Systems MIT 22033

Levels of Abstraction in a DBMS:

Conceptual Model• The conceptual model represents a global view of the entire database as viewed

by the entire organization. That is, the conceptual model integrates all external

views (entities, relationships, constraints, and processes) into a single global

view of the data in the enterprise.

• Also known as a conceptual schema, it is the basis for the identification and

high-level description of the main data objects (avoiding any database model–

specific details).

• The most widely used conceptual model is the ER model.

• Generally, the term logical design is used to refer to the task of creating a

conceptual data model that could be implemented in any DBMS.

36B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz

Page 37: Database Management Systems MIT 22033

• Once a specific DBMS has been selected, the internal model maps the conceptual model to

the DBMS.

• The internal model is the representation of the database as “seen” by the DBMS. In other

words, the internal model requires the designer to match the conceptual model’s

characteristics and constraints to those of the selected implementation model.

• An internal schema depicts a specific representation of an internal model, using the

database constructs supported by the chosen database.

• Because the internal model depends on specific database software, it is said to be software-

dependent. Therefore, a change in the DBMS software requires that the internal model be

changed to fit the characteristics and requirements of the implementation database model.

B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz 37

Levels of Abstraction in a DBMS:

Internal Model

Page 38: Database Management Systems MIT 22033

• The physical model describes the way data are saved on storage media such as disks or tapes. The

physical model requires the definition of both the physical storage devices and the (physical) access

methods required to reach the data within those storage devices, making it both software- and

hardware- dependent.

• The storage structures used are dependent on the software (the DBMS and the operating system) and

on the type of storage devices that the computer can handle.

o Describes storage details

o Summarizes how the relations described in the conceptual schema are actually stored on

secondary storage devices such as disks and tapes

o Decide what file organizations used to store the relations

o Create indexes to speed up data retrieval operations

38B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz

Levels of Abstraction in a DBMS:

Physical Model

Page 39: Database Management Systems MIT 22033

How does a DBMS do all this?• DBMS is a complex software package and the major components of a

DBMS are shown

39B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz

Page 40: Database Management Systems MIT 22033

Queries In A DBMS

• With reference to a fictitious university database1. What is the name of the student with student ID

SEU/IS/98/MG/16?2. What is the average salary of lecturers who teach the

course with course ID MIT22033?3. How many students are enrolled in course MIT22033?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, SEUSLMIT 22033, By: S.Sabraz Nawaz 40

Page 41: Database Management Systems MIT 22033

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, SEUSLMIT 22033, By: S.Sabraz Nawaz 41

Page 42: Database Management Systems MIT 22033

MIT 22033, By: S.Sabraz Nawaz 42

Database Design Process

B.Sc in MIT, SEUSL

Page 43: Database Management Systems MIT 22033

MIT 22033, By: S.Sabraz Nawaz 43

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)

B.Sc in MIT, SEUSL

Page 44: Database Management Systems MIT 22033

MIT 22033, By: S.Sabraz Nawaz 44

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

B.Sc in MIT, SEUSL

Page 45: Database Management Systems MIT 22033

MIT 22033, By: S.Sabraz Nawaz 45

Requirements Analysis…

Result:

A well-written concise document enumerating the user’s requirements

Requirements Analysis

B.Sc in MIT, SEUSL

Page 46: Database Management Systems MIT 22033

MIT 22033, By: S.Sabraz Nawaz 46

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 Studentso Facultyo Other members

• Record members’ borrowing information

Requirements Analysis

B.Sc in MIT, SEUSL

Page 47: Database Management Systems MIT 22033

MIT 22033, By: S.Sabraz Nawaz 47

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

B.Sc in MIT, SEUSL

Page 48: Database Management Systems MIT 22033

MIT 22033, By: S.Sabraz Nawaz 48

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

B.Sc in MIT, SEUSL

Page 49: Database Management Systems MIT 22033

MIT 22033, By: S.Sabraz Nawaz 49

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

B.Sc in MIT, SEUSL

Page 50: Database Management Systems MIT 22033

MIT 22033, By: S.Sabraz Nawaz 50

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

B.Sc in MIT, SEUSL

Page 51: Database Management Systems MIT 22033

MIT 22033, By: S.Sabraz Nawaz 51

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

B.Sc in MIT, SEUSL

Page 52: Database Management Systems MIT 22033

MIT 22033, By: S.Sabraz Nawaz 52

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

B.Sc in MIT, SEUSL

Page 53: Database Management Systems MIT 22033

MIT 22033, By: S.Sabraz Nawaz 53

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

Normalization B.Sc in MIT, SEUSL

Page 54: Database Management Systems MIT 22033

Assignment #01

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

2. Clearly explain the architecture of a DBMS

• Submission Deadline 31st December 2013

B.Sc in MIT, SEUSLMIT 22033, By: S.Sabraz Nawaz 54

Page 55: Database Management Systems MIT 22033

MIT 22033, By: S.Sabraz Nawaz 55

Reference:Ramakrishnan, R., & Gehrke, J. (2003). Database management systems. Osborne/McGraw-Hill. (Pp. 03– 23)

B.Sc in MIT, SEUSL