Database concepts and Archeticture Ch2 with in class Activities

35
1 Instructor: Zainab Almugbel Database Concep

Transcript of Database concepts and Archeticture Ch2 with in class Activities

Page 1: Database concepts and Archeticture Ch2 with in class Activities

1

Instructor: Zainab Almugbel

Database Concepts

Page 2: Database concepts and Archeticture Ch2 with in class Activities

2

Database Concepts and Architecture

Chapter 2- session 1

Page 3: Database concepts and Archeticture Ch2 with in class Activities

OBJECTIVES

By the end of this session, student should be able to: Distinguish the different database architecture Define some basic concepts List the Three Schema Architecture Define Data Independence Identify DBMS Languages

3

Page 4: Database concepts and Archeticture Ch2 with in class Activities

The early DBMS designed as a monolithic systems The whole DBMS software packages work on one machine

The modern DBMS designed as modular package (Client/Server Architecture) Client module runs on a user workstation. it contains application program

Server module contains the data itself; it handles data storage, access, and search

4

INTRODUCTION

Page 5: Database concepts and Archeticture Ch2 with in class Activities

Activity 1: InterviewInterviewerWhat does this picture represent (see slide 5)?Identify the client and the server in the picture? GuestClient server architectureClient: laptop, mobile phone, tabletServer: internet

Page 6: Database concepts and Archeticture Ch2 with in class Activities

Data ModelsSchemaInstances

6

BASIC CONCEPTS

Page 7: Database concepts and Archeticture Ch2 with in class Activities

DATA MODELS

Data models supports achieving data abstraction.

Advantages of Data abstractionSuppression of details of data organization and storage

Highlighting of the essential features for an improved understanding of data

7

Page 8: Database concepts and Archeticture Ch2 with in class Activities

DATA MODELS(CONT’D.)

Data models supports achieving data abstraction.

A set of concepts that can be used to describe the structure of the database:Data TypesRelationshipsConstraints

Most data models also include a set of basic operations for specifyingRetrievalsUpdates

8

Page 9: Database concepts and Archeticture Ch2 with in class Activities

DATA MODELS CATEGORIES

Data Models are categorized according to the types of concepts used to describe the database structure into: Conceptual Data Model

High Level (provide concepts of how users perceive data) Physical Data Model

Low Level (describe how data is stored in the storage media)

Representational Data Model Implementation Easily understood by end users Also similar to how data organized in computer storage

9

Page 10: Database concepts and Archeticture Ch2 with in class Activities

CONCEPTUAL DATA MODEL

Describe the components of the system from the users point of view without any details. Ex: Entity-Relationship model

The elements of this model: Entity

Represent a real world object such as employee, or project Attribute

Represents the property of the entity such as the name of employee

Relationship Represent an association among two or more entities such

as WORKS_ON relationship between employee and projects

10

Page 11: Database concepts and Archeticture Ch2 with in class Activities

REPRESENTATIONAL DATA MODEL

Represent data by using record structures, sometimes called record based data models. Ex: object data model

It is used directly in implementing the database

11

Page 12: Database concepts and Archeticture Ch2 with in class Activities

PHYSICAL DATA MODEL

Describe how data is stored as files in the computer

It concerns with: Record Formats (a format for encoding data for storage on a storage medium)

Record Orderings Access Path (a structure that improve search efficiency, ex: index allows direct access to data using an index term or a keyword)

12

Page 13: Database concepts and Archeticture Ch2 with in class Activities

SCHEMA

Database Schema The description of a database. It includes:

1. descriptions of the database structure 2. the constraints that should hold on the database.

It is not expected to change.Schema Diagram

A diagram displays some aspect of the database schema (the structure of each record type).

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

13

Page 14: Database concepts and Archeticture Ch2 with in class Activities

SCHEMA DIAGRAM EXAMPLE

14

Page 15: Database concepts and Archeticture Ch2 with in class Activities

INSTANCE

Database Instance The actual data stored in a database at a particular moment in time. Also called database state

Database State (snapshot) The current set of instances in the database We get a new database state for each update operation.

15

Page 16: Database concepts and Archeticture Ch2 with in class Activities

INSTANCE(CONT’D.)

Initial Database State Refers to the database when it is loaded before initial database state, the database state is the empty state with no data.

Valid State A state that satisfies the structure and constraints specified in the schema.

DBMS is partly responsible for ensuring that every state of the database is a valid state.

DBMS stores the descriptions of the schema construct and constraints (meta-data) in the DBMS catalog.

16

Page 17: Database concepts and Archeticture Ch2 with in class Activities

DATABASE SCHEMA VS. DATABASE STATE

The database schema is not expected to change frequently but changes applied to schema as application requirements change.

The database state changes every time the database is updated.

Schema is also called intension whereas state is called extension

17

Page 18: Database concepts and Archeticture Ch2 with in class Activities

18Mark Zuckerbergs

Activity 2: Scenario:

Mark is a CS guy. He is the developer of Facebook. You can check his website via link www.facebook.com (see slide 18)- Design the conceptual data model for this scenario? - Draw the schema diagram for this scenario?

Page 19: Database concepts and Archeticture Ch2 with in class Activities

THREE-SCHEMA ARCHITECTURE

DBMS has three important characteristics:1. Self-descriping nature (using Catalog)2. Insulation of program and data3. Support multiple user views

The goal of the three-schema architecture is to achieve these characteristics.

19

Page 20: Database concepts and Archeticture Ch2 with in class Activities

THREE-SCHEMA ARCHITECTURE

The schema architecture is three levels: Internal Level / Internal Schema

Describe physical storage structures and access paths. It uses a physical data model.

Conceptual Level Describes the structure (ex: entities, data types, etc.)

for the whole database for a community of users. Uses a conceptual data model.

External Schema /View Level Describe the various user views. Uses a representational data model.

20

Page 21: Database concepts and Archeticture Ch2 with in class Activities

THREE-SCHEMA ARCHITECTURE

21

Page 22: Database concepts and Archeticture Ch2 with in class Activities

THREE-SCHEMA ARCHITECTURE

The three schema are only descriptions of data, the stored data that actually exists is at the physical level.

The DBMS does not separate the 3 schema levels completely.

The DBMS must transform a request specified on an external schema into a request against a conceptual schema, and then into a request on the internal schema for processing over the database.

The retrieved data that are extracted from the stored database must be reformatted to match the user’s external view.

22

Page 23: Database concepts and Archeticture Ch2 with in class Activities

THREE-SCHEMA ARCHITECTURE

sNo fName lName age salary

23

staffNo lName branchNo

External View 1

External View 2

Conceptual Level staffNo fName lName DOB salary branchNo

Internal Level

Struct STAFF { Int staffNo; Int brancNo; Char fName[15]; Char lNAme[15]; Struct date dateOFBirth; Float salary; Struct STAFF * next};Index stafNo;index branchNo;

Page 24: Database concepts and Archeticture Ch2 with in class Activities

24

Activity 3: Interview

InterviewerWhat does this picture represent (see slide 24)? How does it related to our learning objectives? GuestFriend list in face bookIt shows the external level of the three database schema architecture

Page 25: Database concepts and Archeticture Ch2 with in class Activities

DATA INDEPENDENCE

The three-schema architecture can be used to explain the concept of data independence

Data independence The capacity to change the schema at one level of the database system without having to change the schema at the next higher level

When a schema at a some level is changed, the schema at the next higher-level schema remains unchanged Only the mappings between the two levels is changed.

25

Page 26: Database concepts and Archeticture Ch2 with in class Activities

DATA INDEPENDENCE

Hence, the application programs that refer to the external schema does not change

Two types of data independence Logical data independence Physical data independence

26

Page 27: Database concepts and Archeticture Ch2 with in class Activities

LOGICAL DATA INDEPENDENCE

The capacity to change the conceptual schema without having to change the external schemas and their application programs

Change conceptual schema includes Add data items Change constraints Remove data items

27

Page 28: Database concepts and Archeticture Ch2 with in class Activities

LOGICAL DATA INDEPENDENCE EXAMPLE

Grade_Report

28

SID SName SectionID CourseID Grade

External Schema

Based ON Conceptual Schema

SID SectionID Grade

SName CourseID Grade Semester Year SectionID

Student Name SID Class MajorSID CourseID Semester Year InstructorSection

Conceptual Schema ChangedGrade_Report

Page 29: Database concepts and Archeticture Ch2 with in class Activities

PHYSICAL DATA INDEPENDENCE

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

Change internal schema includes Some physical files where reorganized by creating additional access structure to improve performance of the retrieval the data

The queries at the conceptual schema should not be changed , although it would be executed more efficiently

29

Page 30: Database concepts and Archeticture Ch2 with in class Activities

Activity 4: Use case:

Assuming that all Mark’s personal information is recorded in one table; consider the following situations:

1- Redesign the database schema, so Mark personal information will be in two tables.What type of data independence is discussed here?

2- Moving the database into a different location.What type of data independence is discussed here?

Page 31: Database concepts and Archeticture Ch2 with in class Activities

DATABASE LANGUAGES & INTERFACES

DBMS must provide appropriate languages and interfaces for each category of users.

DBMS Languages:1.Data Definition Language (DDL)

define the conceptual and internal levels of schemas. used by DBA and Database Designers

2.Storage Definition Language (SDL) to specify the internal schema

31

Page 32: Database concepts and Archeticture Ch2 with in class Activities

DATABASE LANGUAGES(CONT’D.)

3. View Definition Language (VDL) Is used to specify user views and their mappings to the conceptual schema.

4. Data Manipulation Languages (DML)Is used to manipulate the database

Retrieval Insertion Deletion Modification

32

Page 33: Database concepts and Archeticture Ch2 with in class Activities

DATA DEFINITION LANGUAGE (DDL)

The first Step in implementing the database is to specify conceptual and internal schemas for the database.

many DBMS do not offer the complete separation between conceptual and internal levels. Thus, one language, called Data Definition Language (DDL ) is used by DBA and by database designers to define both schema.

33

Page 34: Database concepts and Archeticture Ch2 with in class Activities

DATA MANIPULATION LANGUAGE (DML)

Two Main Types of DML High Level (none-procedural)

Interactively from a terminals Can be used on its own to specify complex database operations

concisely. Example, SQL, specifies what data to retrieve than how to retrieve.

Also called declarative languages or set-oriented. Used by casual end users

Low Level (procedural) Must be embedded in a general-purpose programming languages

(PL) needs PL to specify how to retrieve data and include constructs

such as looping. Also called Record-at-a-time Used by programmers

34

Page 35: Database concepts and Archeticture Ch2 with in class Activities

35