DBMS Data Models

  • Upload
    harry

  • View
    223

  • Download
    0

Embed Size (px)

Citation preview

  • 7/28/2019 DBMS Data Models

    1/26

    Schemas versus Instances

    Database Schema: The description of adatabase which is specified during databasedesign and is not expected to change frequently.Includes descriptions of the database structureand the constraints that should hold on thedatabase.

    Schema Diagram: A diagrammatic display of(some aspects of) a database schema.

    Schema Construct: A component of theschema or an object within the schema, e.g.,STUDENT, COURSE.

  • 7/28/2019 DBMS Data Models

    2/26

    Physical schema: database design at thephysical level

    Logical schema: database design at the

    logical level

    Database Instance: The actual datastored in a database at aparticularmoment in time. Also called databasestate (oroccurrence or snapshot).

  • 7/28/2019 DBMS Data Models

    3/26

    The goal of the three-schema architecture is to separate

    the user applications and the physical database.

    The schemas can be divided into three levels:

    internal levelhas an internal schema, which describes

    the physical storage structure of the database Conceptual levelhas a conceptual schema hides the

    details of physical storage structures and concentrates

    on describing entities, data types, relationships, user

    operations and constraints.

    External or view levelincludes a number of external

    schemas or user views.

  • 7/28/2019 DBMS Data Models

    4/26

    Data Independence

    Data independence can be defined as the capacity tochange the schema at one level of a database system

    without having to change the schema at the next

    higher level.

    Two types of data independences are :

    Logical data independence: is the capacity to change

    the conceptual schema without having to change

    external schemas or application programs. Physical data independence: is the capacity to change

    the internal schema without having to change the

    conceptual schema.

  • 7/28/2019 DBMS Data Models

    5/26

    52-2

    Data Model: A set of concepts to describe the structure of a

    database, and certain constraints that the database should obey.

    data types

    relationships

    Provide data abstraction

    Data Model Operations: Operations for specifying database

    retrievals and updates by referring to the concepts of the data

    model.

    generic operation: insert, delete, modify, retrieve

    user-defined operations

    Data Models, Schemas, and Instances

  • 7/28/2019 DBMS Data Models

    6/26

    62-2

    Categories of Data Models:

    - Conceptual (high-level, semantic) data models: Provide concepts that

    are close to the way many users perceive data.(Also called entity-based or object-based data models.)

    entity attribute relationship

    - Physical (low-level, internal) data models: Provide concepts thatdescribe details of how data is stored in the computer.

    record formats record ordering access paths

    - Implementation (record-oriented) data models: Provide concepts that

    fall between the above two, balancing user views with some computer

    storage details.

    relational network hierarchical

  • 7/28/2019 DBMS Data Models

    7/26

    Conceptual Models

    High level

    Example: Entity-relationship diagrams

    Uses concepts such as Entity: Real-world thing that is described in

    the database

    Attribute: Property of an entity

    Relationship: Association between entities

  • 7/28/2019 DBMS Data Models

    8/26

    Logical Models

    More specific than conceptual models

    Follow rules of a particular method of

    implementing a databaseMost common: Relational model

    Others Hierarchical

    Network

    Object-oriented

  • 7/28/2019 DBMS Data Models

    9/26

    Physical Data Models

    Low-level

    Describe how the database is actually

    stored on the system

    DBMS takes care of much of this detail

  • 7/28/2019 DBMS Data Models

    10/26

    Three Schema Architecture

    Logicalindependence

    Physical

    independence

  • 7/28/2019 DBMS Data Models

    11/26

    Entity-Relationship Model

    Example of schema in the entity-

    relationship model

  • 7/28/2019 DBMS Data Models

    12/26

    122-4a

    Schema diagram forUNIVERSITY database

    schema construct

    Known data:

    name of record types, data items

  • 7/28/2019 DBMS Data Models

    13/26

    132-4

    Figure 1.2

    UNIVERSITY Database

  • 7/28/2019 DBMS Data Models

    14/26

    142-3

    define

    empty state

    initial state

    load

    state

    update

    updatevalid state

    satisfy database schema

  • 7/28/2019 DBMS Data Models

    15/26

    152-5

    2.2 DBMS Architecture and Data Independence

    Proposed to support DBMS characteristics of:

    - Insulation of programs and data/program and operations

    (program-data and program-operation independence)

    - Support of multiple views of the data.

    - Use of catalog (database description)

    Defines DBMS schema at three levels: (see 2-9)

    - Internal schema at the internal level to describe data storage structures and access

    paths. Typically uses aphysicaldata model.

    - Conceptual schema at the conceptual level to describe the structure and constraints

    for the whole database. Uses a conceptualor an implementation data model.- External schema at the external level to describe the various user views. Usually

    uses the same data model as the conceptual level or high-level data model.

    Mappings among schema levels are also needed. Programs refer to an external schema,

    and are mapped by the DBMS to the internal schema for execution

    2.2.1 Three-Schema Architecture

  • 7/28/2019 DBMS Data Models

    16/26

    162-6

    Figure 2.2 The Three-schema architecture 2-6

  • 7/28/2019 DBMS Data Models

    17/26

    172-7

    2.2.2 Data Independence

    Logical Data Independence: The capacity to change the conceptual schema withouthaving to change the external schemas and their application programs.

    Physical Data Independence: The capacity to change the internal schema without

    having to change the conceptual schema.

    When a schema at a lower level is changed, only the mappings between this

    schema and higher-lever schemas need to be changed in a DBMS that fully supports

    data independence. The higher-level schemas themselves are unchanged. Hence, the

    application programs need not be changed since they refer to the external schemas.

    By adding or removing a record type or data

    item to

    expand the database (2-11)

    reduce the database

    Reorganize physical files to improve performance

    e.g. List all sections offered in Fall 1998

    Disadvantages of two levels of mappings:

    Overhead during compilation or execution of a query or program

  • 7/28/2019 DBMS Data Models

    18/26

    182-7a

    UNIVERSITY Conceptual Schema

    STUDENT (Name, Student Number, Class, Major)

    COURSE (Course Name, Course Number, Credit, Dept)

    PREREQUISITE (Course Number, Prerequisite Number)

    SECTION (Section Id, Course Number, Semester, Year, Instructor)GRADE_REPORT(Student Number, Section Id , Grade)

    UNIVERSITY External Schema

    TRANSCRIPT(Student Name, Course Number, Grade, Semester, Year, Section Id)

    derived from STUDENT, SECTION, GRADE_REPORTPREREQUISITES(Course Name, Course Number, Prerequisites)

    derived from PREREQUISITE, COURSE

    Change GRADE-REPORT Schema Construct

    GRADE_REPORT (Student Number, Student Name, Section Id, Course Number, Grade)

    Change Mapping (& View Definition)

    TRANSCRIPT derived from SECTION, GRADE_REPORT

  • 7/28/2019 DBMS Data Models

    19/26

    192-8

    2.3 Database Languages and Interfaces

    Data Definition Language (DDL): Used by the DBA and database designers to

    specify the conceptual schema of a database. In many DBMSs, the DDL is also

    used to define internal and external schemas (views). In some DBMSs, separate

    storage definition language (SDL) and view definition language (VDL) are

    used to define internal and external schemas.

    Data Manipulation Language (DML): Used to specify database retrievals and

    updates (insertion, deletion, modifications)

    - DML commands (data sublanguage) can be embedded in a general-purpose

    programming language (host language).

    - Alternatively, stand-alone DML commands can be applied directly (query

    language).

    provide appropriate languages and interfaces for each category of users.

    2.3.1 DBMS Languages

    DDL Compiler

  • 7/28/2019 DBMS Data Models

    20/26

    202-9

    Types of DML

    -Procedural DML:

    Also called record-at-a-time (record-oriented) or low-level DML

    Must be embedded in a programming language.

    Searches for and retrieves individual database records and uses looping

    and other constructs of the host programming language to retrieve multiple

    records.

    -Declarative or non-procedural DML: Also called set-at-a-time (set-oriented) or high-level DML.

    Can be used as a stand-alone query language or can be embedded in a

    programming language.

    Searches for and retrieves information from multiple related database

    records in a single command.

    - host language: general-purpose language

    - data sublanguage: DML

    - C++

  • 7/28/2019 DBMS Data Models

    21/26

    212-10

    2.3.2 DBMS Interfaces

    - Stand-alone query language interfaces. (casual end user)

    - Programmer interfaces for embedding DML in programming

    languages: (programmer)

    -Pre-compiler Approach

    -Procedure (Subroutine) Call Approach

    - User-friendly interfaces:

    -Menu-based Interfaces for Browsing.-Forms-based Interfaces.

    -Graphical User Interfaces.

    -Natural language Interfaces

    -Combination of the above

    -Interfaces for Parametic Users (using function keys)

    - Interfaces for the DBA:

    -Creating accounts, granting authorizations

    -Setting system parameters-Changing schemas or access path

  • 7/28/2019 DBMS Data Models

    22/26

    222-11

    2.4.1 DBMS Component Modules

    2.4 The Database System Environment

    Figure 2.3

  • 7/28/2019 DBMS Data Models

    23/26

    232-12

    2.4.2 Database System Utilities

    To perform certain functions such as:

    -Loadingdata stored in files into a database. Conversion tool

    -Backing up the database periodically on storage.-File reorganizingdatabase file structures.

    -Report generation utilities.

    -Performance monitoringutilities.

    - Other functions, such assorting, user monitoring,data compression, etc.

  • 7/28/2019 DBMS Data Models

    24/26

    242-12

    Data dictionary utility:

    - Used to store schema descriptions and other information such as design

    decisions, application program descriptions, user information, usage

    standards, etc. (comment)

    -Active data dictionary is accessed by DBMS software and users/DBA.

    -Passive data dictionary is accessed by users/DBA only.

    Communications Facilities- Allow users at locations remote from the database system site to access

    the database.

    DB (DBMS)/DC (Data Communication System)

    2.4.3 Tools, Application Environments, and

    Communications Facilities

  • 7/28/2019 DBMS Data Models

    25/26

    252-13

    2.5 Classification of Database Management Systems

    Based on the data model used:

    Data models

    -Traditional: Relational, Network (see 2-19), Hierarchical

    - Emerging: Object-oriented, Semantic, Entity- Relationship, other.

    Other classifications:

    Number of users : Single-user (typically used with personal computers) vs.

    multi-user (most DBMSs)

    Number of sites:

    Centralized (uses a single computer) vs. distributed (uses multiple computers).

    Homogeneous vs. Heterogeneous

    Cost of DBMS software. $10,000~100,000

    $100~3,000Types of access paths used. (inverted file structures, )

    Purpose general purpose

    special purpose

    e.g. airline reservations, telephone directory, on-line transaction

    processing system

  • 7/28/2019 DBMS Data Models

    26/26

    262-14

    Figure 2.4 A Network Schema