24
Winter 2007 Ron McFadyen ACS- 3902 1 Database system concepts and architecture •Database schema •Database system architecture •Data independence concept •Database language •Database application •Interfaces •Database environment Ch 2

Database system concepts and architecture Winter 2007Ron McFadyen ACS-39021 Database schema Database system architecture Data independence concept Database

  • View
    223

  • Download
    2

Embed Size (px)

Citation preview

Winter 2007 Ron McFadyen ACS-3902 1

Database system concepts and architecture

•Database schema

•Database system architecture

•Data independence concept

•Database language

•Database application

•Interfaces

•Database environment

Ch 2

Winter 2007 Ron McFadyen ACS-3902 2

Database system concepts and architecture

Schema: a description of a database -- meta data

•the intension of the database

Schema evolution: if the database definition changes, we say it evolves.

Database State: the data in the database at a particular point in time

•the extension of the schema

Winter 2007 Ron McFadyen ACS-3902 3

Database system concepts and architecture

Sample database

Student Name StNo Class Major

Smith 17 1 CS

Brown 8 2 CS

Course CName CNo CrHrs Dept

Database 8803 3 CS

C 2606 3 CS

Section SId CNo Semester Yr Instructor

32 8803 Spring 2000 Smith

25 8803 Winter 2000 Smith

43 2606 Spring 2000 Jones

Grade StNo SId Grade

17 25 A

17 43 B

Winter 2007 Ron McFadyen ACS-3902 4

Database system concepts and architecture

University database schema:

Course

Cnamestring(20)

CNo string(20)

CrHrs integer

Dept.String(20)

GradeStNo integer

SId integer

GradeString(20)

Student

Name string(20)

StNo integer

Class integer

Major String(20)

SectionSID integer

CNo string(20)

Semester integer

Yr integer

Instructor string(20)

Winter 2007 Ron McFadyen ACS-3902 5

Database system concepts and architecture

Schema evolution:

Course

Cnamestring(20)

CNostring(20)

CrHrs integer

Dept.String(20)

Student

Name string(20)

StNo integer

Class integer

Major String(20)

PrerequisiteCNo string(20)

Pre-CNo string(20)… ...

new table added

Winter 2007 Ron McFadyen ACS-3902 6

Database system concepts and architecture

Schema evolution:

Course

Cnamestring(20)

Cnostring(20)

CrHrs integer

Dept.String(20)

Student

Name string(20)

StNo integer

Class integer

Major String(20)

Age integer

Sex string(20)… ...

new attributes added

Winter 2007 Ron McFadyen ACS-3902 7

Database system concepts and architecture

Sample database

Student Name StNo Class Major

Smith 17 1 CS

Brown 8 2 CS

Course CName CNo CrHrs Dept

Database 8803 3 CS

C 2606 3 CS

Section SId CNo Semester Yr Instructor

32 8803 Spring 2000 Smith

25 8803 Winter 2000 Smith

43 2606 Spring 2000 Jones

Grades StNo Sid Grade

17 25 A

17 43 B

Winter 2007 Ron McFadyen ACS-3902 8

Database system concepts and architecture

Database state changed:

Student Name StNo Class Major

Smith 17 1 CS

Brown 8 2 CS

Course CName CNo CrHrs Dept

Database 8803 3 CS

C 2606 3 CS

Section SId CNo Semester Yr Instructor

32 8803 Spring 2000 Smith

25 8803 Winter 2000 Smith

Grades StNo Sid Grade

17 25 A

17 43 B

Winter 2007 Ron McFadyen ACS-3902 9

Database system concepts and architecture

Definition

Manipulation

Construction

We define the database

database state is the empty state with no data

initial state when database is populated (loaded)

current state changes with each insert, delete, update

hopefully, the database goes from one correct/valid state to another

Winter 2007 Ron McFadyen ACS-3902 10

Database system concepts and architecture

Three-schema architecture

Externalview

Externalview

Conceptualschema

Internalschema

Physical storage structures and details

Describes the whole database for all users

A specific user or groups view of the database

Winter 2007 Ron McFadyen ACS-3902 11

Database system concepts and architecture

Data independence

Ability to change the database at one level with no impact to the next higher level

•physical data independence - the ability to change the physical schema without affecting the conceptual schema

•typical example: add a new index

•logical data independence - the ability to change the conceptual schema without affecting existing external views or application programs

•typical example: add an attribute

Winter 2007 Ron McFadyen ACS-3902 12

Database system concepts and architecture

DBMS Languages

Data definition language (DDL): used to define the database schema. Ideally one schema definition language per level

•in practice there might be one DDL for all levels

Winter 2007 Ron McFadyen ACS-3902 13

Database system concepts and architecture

DBMS Languages

Data Manipulation language (DML): Used to manipulate data.

•typical systems provide a general purpose language for inserting, updating, deleting, and retrieving data

•two distinctions: set-oriented and row-at-a-time

Winter 2007 Ron McFadyen ACS-3902 14

Database system concepts and architecture

EXEC SQL DECLARE C1 CURSOR FORSELECT au_fname, au_lname FROM authors FOR BROWSE;EXEC SQL OPEN C1;while (SQLCODE == 0){EXEC SQL FETCH C1 INTO :fname, :lname;}

Database applicationsIf an application program that accesses the database embeds DML commands within it, then we have a host language and a data sublanguage.

Winter 2007 Ron McFadyen ACS-3902 15

Database system concepts and architecture

Record-at-a-time

•procedural - need loops, etc

•navigate through data obtaining 1 record at a time

•note that SQL does permit this via cursors

Set-oriented operations

•select Name, StNo from student where Name like “M%”

•EXEC SQL DELETE FROM authors WHERE au_lname = 'White'

Winter 2007 Ron McFadyen ACS-3902 16

Database system concepts and architecture

DBMS interfaces

•menu-based

•forms-based

•GUI

•natural language

•for dba

Winter 2007 Ron McFadyen ACS-3902 17

Database system concepts and architecture

Example of a menu-based interface: from MS Access

Winter 2007 Ron McFadyen ACS-3902 18

Database system concepts and architecture

DBMS environment

see figure 2.3•stored data manager

A module to control access to DBMS information that is stored on disk, whether it is part of the database or the catalog.

•DDL compiler

A module to process schema definition, specified in the DDL, and store description of the schema (meta-data) in the DBMS catalog.

•DML compiler

It translates the DML commands into object code for database access.•run-time database processor

It handles database access at run time; it receives retrieval or update operations and carries them out on the database.

Winter 2007 Ron McFadyen ACS-3902 19

Database system concepts and architecture

DBMS environment

•query compiler

It handles high-level queries that are entered interactively. It parses, analyzes, and compiles or interprets a query by creating database access code, and then generates calls to the rum-time processor for executing the code.

•pre-compiler

It extracts DML commands from an application program which is written in host programming language like C, Pascal, etc.

Winter 2007 Ron McFadyen ACS-3902 20

Database system concepts and architecture

DBMS utilities•loading

loading existing files - such as text files or sequential files - into the database.

•backup

creating a backup copy of the database, usually by dumping the entire database into tape.

•file reorganization

reorganizing a database file into a different file organization to get a better performance.

•performance monitoring

monitoring database usage and providing statistics to the DBA.

Winter 2007 Ron McFadyen ACS-3902 21

Database system concepts and architecture

DBMS Architectures

•centralized

•client/server

2-tier

3-tier

Winter 2007 Ron McFadyen ACS-3902 22

Database system concepts and architecture

DBMS Architectures

•centralized

Displaymonitor

Displaymonitor

hardware

Software: dbms, applications, …

OS

Winter 2007 Ron McFadyen ACS-3902 23

Database system concepts and architecture

DBMS Architectures

Client Server

ApplicationServer

Db Server Client

2-tier client/server: software components are distributed across two systems

3-tier client/server

User interface

Application or web server

DBMS

Winter 2007 Ron McFadyen ACS-3902 24

Database system concepts and architecture

Classifying DBMSs

data model:

relational / object-oriented / hierarchical / network / object-relational

users: single-user / multi-user

location: distributed / centralized

cooperation: homogeneous / heterogeneous

OLTP: on-line transaction processing

•used to run the day-to-day operations of a business

•event-oriented: take an order, make a reservation, payment for goods, withdraw cash, ...