cs3270 - database system - lecture (2)

38
CS3270 DATABASE – I Mr. Dilawar Lecturer, Computer Science Faculty, Bakhtar University Kabul, Afghanistan.

Upload: dilawar-khan

Post on 11-Apr-2017

44 views

Category:

Education


1 download

TRANSCRIPT

Page 1: CS3270 - DATABASE SYSTEM - Lecture (2)

CS3270DATABASE – I

Mr. Dilawar

Lecturer,Computer Science Faculty,

Bakhtar UniversityKabul, Afghanistan.

Page 2: CS3270 - DATABASE SYSTEM - Lecture (2)

Previous Lecture Outline• Introduction

• Traditional File-Based Systems

• Database Approach

• Roles in the Database Environment

• History of DBMS

• Advantages and Disadvantages of DBMSs

Page 3: CS3270 - DATABASE SYSTEM - Lecture (2)

Database EnvironmentChapter – 2

Page 4: CS3270 - DATABASE SYSTEM - Lecture (2)

Chapter Outline• The Three-Level ANSI-SPARC Architecture

• Database Languages

• Data Models and Conceptual Modeling

• Functions of DBMS

• Components of DBMS

• Multi-User DBMS Architecture

Page 5: CS3270 - DATABASE SYSTEM - Lecture (2)

Lecture Outline• The Three-Level ANSI-SPARC Architecture

• Database Languages

• Data Models and Conceptual Modeling

Page 6: CS3270 - DATABASE SYSTEM - Lecture (2)

The Three-Level ANSI-SPARC Architecture• Identifies three levels of abstraction.

• Three distinct levels at which data items can be described.

• The three-level architecture comprising an external, a conceptual, and an internal level as shown in the figure.• The way users observes the data is called external level.• The way DBMS and OS observes data is called the

internal level.• Where the data is actually stored using the data structures

and file organizations.

• Conceptual level provides both the mapping and the desired independence between external and internal levels.

Page 7: CS3270 - DATABASE SYSTEM - Lecture (2)

The Three-Level ANSI-SPARC Architecture• The objective of three-level architecture is to separate each user’s view of the

database from the way the database is physically represented.

• There are several reasons why this is desirable.• All users should be able to access same data but have a different customized view.• A user’s view is safe 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

such as changeover to a new storage device.• DBA should be able to change conceptual structure of database without affecting all users.

Page 8: CS3270 - DATABASE SYSTEM - Lecture (2)

The Three-Level ANSI-SPARC Architecture• External Level• The users’ view of the database. It Describes that part of database that is

relevant to a each user.• The external level consists of a number of different external views of the

database.• Each user has a view of the ‘real world’ represented in a form that is familiar for that

user.

• Different views may have different representation of same data (e.g. different date formats, age derived from DOB etc.).

Page 9: CS3270 - DATABASE SYSTEM - Lecture (2)

The Three-Level ANSI-SPARC Architecture• Conceptual Level• Community view of the database. It describes what data is stored in database

and the relationships among the data.• It is a complete view of the data requirements of the organization that is

independent of any storage considerations.• It represents

• All entities, their attributes, and their relationships.

• The constraints on the data.

• Semantic information about the data.

• Security and integrity information.

Page 10: CS3270 - DATABASE SYSTEM - Lecture (2)

The Three-Level ANSI-SPARC Architecture• Internal Level• Physical representation of the database on the computer. This level describes

how the data is stored in the database.• It covers the physical implementation of the database to achieve optimal

runtime performance and storage space utilization.• It covers data structures and file organizations used to store data on storage

devices.• Interfaces with the operating system access methods to place the data on the

storage devices, build the indexes, retrieve the data, and so on.

Page 11: CS3270 - DATABASE SYSTEM - Lecture (2)

The Three-Level ANSI-SPARC Architecture

Page 12: CS3270 - DATABASE SYSTEM - Lecture (2)

The Three-Level ANSI-SPARC ArchitectureSchemas

• The overall description of the database is called the database schema.

• There are three schemas as per three-level architecture.• External Schema• Conceptual Schema• Internal Schema

Page 13: CS3270 - DATABASE SYSTEM - Lecture (2)

The Three-Level ANSI-SPARC Architecture• External Schemas • Also called subschemas.• Corresponds to different views of data.• Multiple schemas per database.

• Conceptual Schema• Describes all the entities, attributes, and relationships together with integrity

constraints• Only one schema per database.

Page 14: CS3270 - DATABASE SYSTEM - Lecture (2)

The Three-Level ANSI-SPARC Architecture• Internal Schema• A complete description of the internal model, containing the definitions of

stored records, the methods of representation, the data fields, and the indexes and storage structures used.• Only one schema per database.

Page 15: CS3270 - DATABASE SYSTEM - Lecture (2)

The Three-Level ANSI-SPARC ArchitectureMapping

• The DBMS is responsible for mapping between these three types of schema:• The DBMS must check that each external schema is derivable from the

conceptual schema, and it must use the information in the conceptual schema to map between each external schema and the internal schema.

• Types of mappings• Conceptual/Internal mapping• External/Conceptual mapping

Page 16: CS3270 - DATABASE SYSTEM - Lecture (2)

The Three-Level ANSI-SPARC Architecture• Conceptual/Internal Mapping• Enables the DBMS to find the actual record or combination of records in

physical storage that establishes a logical record in the conceptual schema, together with any constraints to be enforced on the operations for that logical record.• It also allows any differences in entity names, attribute names, attribute

order, data types, and so on, to be resolved.

• External/Conceptual Mapping• Enables the DBMS to map names in the user’s view on to the relevant part of

the conceptual schema.

Page 17: CS3270 - DATABASE SYSTEM - Lecture (2)

The Three-Level ANSI-SPARC Architecture

Page 18: CS3270 - DATABASE SYSTEM - Lecture (2)

The Three-Level ANSI-SPARC Architecture• Database Schema

• Description of database (also called intension).

• Specified during design phase.

• Remain almost static.

• Database Instance• Data in the database at any particular point in time.

• Dynamic (changes with the time).

• Also called an extension (or state) of database.

Page 19: CS3270 - DATABASE SYSTEM - Lecture (2)

The Three-Level ANSI-SPARC ArchitectureData Independence

• A major objective for the three-level architecture is to provide data-independence.• Upper levels are unaffected by changes to lower levels.

• There are two kinds of data-independence:• Logical Data Independence

• Physical Data Independence

Page 20: CS3270 - DATABASE SYSTEM - Lecture (2)

The Three-Level ANSI-SPARC Architecture• Logical Data Independence• Refers to protection 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.

Page 21: CS3270 - DATABASE SYSTEM - Lecture (2)

The Three-Level ANSI-SPARC Architecture• 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, storage devices etc.).

• Should not require change to conceptual or external schemas.

Page 22: CS3270 - DATABASE SYSTEM - Lecture (2)

The Three-Level ANSI-SPARC Architecture

Page 23: CS3270 - DATABASE SYSTEM - Lecture (2)

Database Languages• Data sublanguage consist of two parts:• DDL (Data Definition Language)• DML (Data Manipulation Language)

• Data sublanguage• Does not include constructs for all computing needs such as iterations or

conditional statements, which are provided by HLL.• Many DBMSs provide embedding the sublanguage in a high level

programming language e.g. C, C++, Java etc.• In this case , these high level languages are called host languages.

Page 24: CS3270 - DATABASE SYSTEM - Lecture (2)

Database Languages• Data Definition Language• Allows the DBA or user to describe and name entities, attributes, and

relationships required for the application• Plus any associated integrity and security constraints.

• The result is a set of tables stored in special files collectively called the System catalog (data dictionary, data directory).• Metadata (data about data, data description, data definitions).

Page 25: CS3270 - DATABASE SYSTEM - Lecture (2)

Database Languages• Data Manipulation Language• Provides basic data manipulation operations on data held in the database.

• Procedural DML

• Non-Procedural DML

Page 26: CS3270 - DATABASE SYSTEM - Lecture (2)

Database Languages• Data Manipulation Language• Procedural DML allows user to tell system exactly how to manipulate data.

• Operate on records individually.

• Typically, embedded in a high level language.

• More work is done by user (programmer).

• Network or hierarchical DMLs.

Page 27: CS3270 - DATABASE SYSTEM - Lecture (2)

Database Languages• Data Manipulation Language• Non-Procedural DML Allows user to state what data is needed rather than

how it is to be retrieved• Operate on set of records.

• Relational DBMS include e.g. SQL, QBE etc.

• Easy to understand and learn than procedural DML .

• More work is done by DBMS than user.

• Also called declarative languages.

Page 28: CS3270 - DATABASE SYSTEM - Lecture (2)

Database Languages• Fourth Generation Languages• No clear agreement

• Forms generators

• Report generators

• Graphics generators

• Application generators

• Examples : SQL and QBE

Page 29: CS3270 - DATABASE SYSTEM - Lecture (2)

Data Models• A set of concepts to describe the structure of a database, the

operation for manipulating these structures, and certain constraints.• Represents the organization itself.• To represent data in an understandable way.

• Should provide the basic concepts and notations that will allow database designers and end-users to accurately communicate their understanding of the organizational data.

Page 30: CS3270 - DATABASE SYSTEM - Lecture (2)

Data Models• A data model comprises:• A structural part

• Consisting of a set of rules according to which databases can be constructed.

• A manipulative part• Operations that are allowed on the data.

• Possibly a set of integrity rules• Which ensures that the data is accurate.

Structure Constraints

Operations

Data Model describes

Page 31: CS3270 - DATABASE SYSTEM - Lecture (2)

Data Models• ANSI-SPARC architecture related models• External data model (Universe of Discourse)

• Represent each user’s view of the organization.

• Conceptual data model (DBMS independent)• Represent the community view that is DBMS independent.

• Internal data model• Represent the conceptual schema in such a way that it can be understood by the DBMS.

Page 32: CS3270 - DATABASE SYSTEM - Lecture (2)

Data Models• Categories of data models include:

• Object-based• Entity-Relationship

• Semantic

• Functional

• Object-Oriented

• Record-based• Relational Data Model

• Network Data Model

• Hierarchical Data Model

• Physical

Relational Systems adopt a declarative approach to database processing (that is, they specify what data is to be retrieved).

Network and hierarchical systems adopt a navigational approach (that is, they specify how the data is to be retrieved).

Page 33: CS3270 - DATABASE SYSTEM - Lecture (2)

Data Models• Relational Model

Page 34: CS3270 - DATABASE SYSTEM - Lecture (2)

Data Models• Network Model

Page 35: CS3270 - DATABASE SYSTEM - Lecture (2)

Data Models• Hierarchical Model

Page 36: CS3270 - DATABASE SYSTEM - Lecture (2)

Conceptual Modeling• Conceptual modeling is process of developing a model of information

use in an enterprise that is independent of implementation details.• Should be complete and accurate representation of an organization’s data

requirements.• Conceptual schema is the core of a system supporting all user views.

• Conceptual vs. logical data model

Page 37: CS3270 - DATABASE SYSTEM - Lecture (2)

Summery• The Three-Level ANSI-SPARC Architecture

• Database Languages

• Data Models and Conceptual Modeling

Page 38: CS3270 - DATABASE SYSTEM - Lecture (2)

Thank YouFor your Patience