+ All Categories
Home > Documents > Database Environment Chapter 2 AIT632 Sungchul Hong.

Database Environment Chapter 2 AIT632 Sungchul Hong.

Date post: 29-Dec-2015
Category:
Upload: loren-payne
View: 215 times
Download: 1 times
Share this document with a friend
Popular Tags:
42
Database Environment Chapter 2 AIT632 Sungchul Hong
Transcript
Page 1: Database Environment Chapter 2 AIT632 Sungchul Hong.

Database Environment

Chapter 2

AIT632

Sungchul Hong

Page 2: Database Environment Chapter 2 AIT632 Sungchul Hong.

Last Class

• Database related definitions• Traditional file system• Database approach• Components of the DBMS environment

– Hardware, software, data, procedure, people

• Roles in the database environment– DA, DBA, DB designer, application developer, end users

• Advantages & disadvantages of DBMS• History

Page 3: Database Environment Chapter 2 AIT632 Sungchul Hong.

This Class

• Three level ANSI-SPARC Architecture– External level, conceptual level, internal level

• Schemas• Mapping• DDL, DML• Data modeling and conceptual modeling• Functions of DBMS• Components of a DBMS• Multi-User DBMS architecture

Page 4: Database Environment Chapter 2 AIT632 Sungchul Hong.

The Three-Level ANSI-SPARC Architecture

• External

• Conceptual

• Internal

• American National Standard

• Institute

• Standards Planning and

• Requirements Committee

Page 5: Database Environment Chapter 2 AIT632 Sungchul Hong.

Separation of Logical and Physical Presentation

• Each user should be able to access the same data, but have a different customized view of the data.

• Users should not have to deal directly with physical database storage details.

• DBA should be able to change the database storage structures without affecting the users’ views.

• The internal structure of the database should be unaffected by changes to the physical aspects of storage.

• The DBA should be able to change the conceptual structure of the database without affecting all users.

Page 6: Database Environment Chapter 2 AIT632 Sungchul Hong.

External Level

• Users’ view of the database. This level describes that part of the database that is relevant to each user.

• External views• Different views may have different representations of

the same data.

Page 7: Database Environment Chapter 2 AIT632 Sungchul Hong.

What will be happen if we have two base tables in stead of views?

Page 8: Database Environment Chapter 2 AIT632 Sungchul Hong.

Conceptual Level

• The community view of the database. This level describes what data is stored in the database and the relationships among the data.

• Logical structure of entire database– All entities, their attributes, and their relationships

– The constraints on the data

– Semantic information about the data

– Security and integrity information

Page 9: Database Environment Chapter 2 AIT632 Sungchul Hong.

Internal Level

• The physical representation of the database on the computer. This level describes how the data is stored in the database.– Storage space allocation for data and indexes.

– Record descriptions for storage.

– Record placement

– Data compression and data encryption techniques.

Page 10: Database Environment Chapter 2 AIT632 Sungchul Hong.

Schemas

• The overall description of the database• Database schema

– External schemas (subschema)• Different views of the data

– Conceptual schema• Describes all the entities, attributes,and relationships together

with integrity constraints.

– Internal schema• Complete description of the internal model, containing the

definitions of stored records, the methods of representation, the data fields, and the indexes and hashing schemes used.

Page 11: Database Environment Chapter 2 AIT632 Sungchul Hong.
Page 12: Database Environment Chapter 2 AIT632 Sungchul Hong.

Mappings

• The DBMS is responsible for mapping between these three types of schema.

• Check consistency.• Conceptual/internal mapping

– Find the actual record of a logical record

• External/conceptual mapping– Map names in the user’s view on to the relevant part of the

conceptual schema

Page 13: Database Environment Chapter 2 AIT632 Sungchul Hong.

Mappings

Page 14: Database Environment Chapter 2 AIT632 Sungchul Hong.

Database Instance

• Database schema is not expected to change frequently.

• Database instance– The data in the database at any particular point

in time.

Page 15: Database Environment Chapter 2 AIT632 Sungchul Hong.

Instance

Schema

Page 16: Database Environment Chapter 2 AIT632 Sungchul Hong.

Data Independence

• Upper levels are unaffected by changes to lower level.

• Logical data independence– Refers to the immunity of the external schemas

to changes in the conceptual schema.

• Physical data independence– Refers to the immunity of the conceptual

schema to changes in the internal schema.

Page 17: Database Environment Chapter 2 AIT632 Sungchul Hong.

Data Definition Language

• A language that allows the DBA or user to describe and name the entities, attributes,and relationships required for the application, together with any associated integrity and security constraints.

• System catalog (meta data, data dictionary)

Page 18: Database Environment Chapter 2 AIT632 Sungchul Hong.

22

Example 6.1 - CREATE TABLE

CREATE TABLE PropertyForRent (propertyNo VARCHAR NOT NULL,rooms Number NOT NULL DEFAULT 4, rent Number NOT NULL, DEFAULT 600, ownerNo VARCHAR NOT NULL, staffNo VARCHARbranchNo VARCHAR NOT NULL,PRIMARY KEY (propertyNo),FOREIGN KEY (staffNo) REFERENCES Staff ON DELETE SET NULL ON UPDATE CASCADE);

Page 19: Database Environment Chapter 2 AIT632 Sungchul Hong.

Data Definition Language (DDL)

• The DDL us used to define a schema or to modify an existing one.

• System catalog

• Data dictionary

Page 20: Database Environment Chapter 2 AIT632 Sungchul Hong.

The Data Manipulation Language (DML)

• A language that provides a set of operations to support the basic data manipulation operations on the data held in the database.– Insertion, modification, retrieval, deletion of

data– Query language– Procedural DMLs– Non-procedural DML (SQL)

Page 21: Database Environment Chapter 2 AIT632 Sungchul Hong.

Staff

staffNofName lName position sex DOB salary branchNo

SL21 John White Manager M Oct/1/45 30000 B005

SG37 Ann Beech Assistant F Nov/10/60 12000 B003

SG14 David Ford Supervisor M Mar/24/58 18000 B003

SA9 Mary Howe Assistant F 19/Feb/70 9000 B007

SG5 Susan Brand Manager F Jun/3/40 24000 B003

SL41 Julie Lee Assistant F Jun/13/65 9000 B005

SELECT staffNo, fName, lName, position, salaryFROM StaffWHERE salary > 10000;

Page 22: Database Environment Chapter 2 AIT632 Sungchul Hong.

staffNo fName lName position salary

SL21 John White Manager 30000

SG37 Ann Beech Assistant 12000

SG14 David Ford Supervisor 18000

SG5 Susan Brand Manager 24000

Result Table

Page 23: Database Environment Chapter 2 AIT632 Sungchul Hong.

Fourth-Generation Languages (4GLs)

• What v.s. How

• Forms generator

• Report generators

• Graphics generators

• Application generators

Page 24: Database Environment Chapter 2 AIT632 Sungchul Hong.

Data Models and Conceptual Modeling

• Data model– An integrated collection of concepts for describing and

manipulating data, relationships between data, and constraints on the data in a organization.

– Structural part

– Manipulation part

– Set of integrity rules

– Relational, network, hierarchical, Object-Oriented

Page 25: Database Environment Chapter 2 AIT632 Sungchul Hong.

Relational Data Model

Page 26: Database Environment Chapter 2 AIT632 Sungchul Hong.

Network Data Model

Page 27: Database Environment Chapter 2 AIT632 Sungchul Hong.

Hierarchical Data Model

Page 28: Database Environment Chapter 2 AIT632 Sungchul Hong.

Conceptual Modeling

• The process of constructing a model of the information use in an enterprise that is independent of implementations details such as the target DBMS, application programs, programming languages, or any other physical considerations.

Page 29: Database Environment Chapter 2 AIT632 Sungchul Hong.

Functions of a DBMS (1/2)

• Data storage, retrieval, and update

• A user-accessible catalog (meta data)

• Transaction support (update salary)

• Concurrency control services

• Recovery service

• Authorization service

• Support for data communication

Page 30: Database Environment Chapter 2 AIT632 Sungchul Hong.

Functions of a DBMS (2/2)

• Integrity services

• Services to promote data independence

• Utility service– Import, monitoring, statistical analysis, index

reorganization, garbage collection.

Page 31: Database Environment Chapter 2 AIT632 Sungchul Hong.

Components of a DBMS (1/2)

• Query processor

• Database manager

• File manager

• DML preprocessor

• DDL compiler

• Catalog manager

• Authorization control

Page 32: Database Environment Chapter 2 AIT632 Sungchul Hong.

Components of a DBMS (2/2)

• Command processor

• Integrity checker

• Query optimizer

• Transaction manager

• Scheduler

• Recovery manager

• Buffer manager

Page 33: Database Environment Chapter 2 AIT632 Sungchul Hong.
Page 34: Database Environment Chapter 2 AIT632 Sungchul Hong.
Page 35: Database Environment Chapter 2 AIT632 Sungchul Hong.

Multi-User DBMS Architectures

• Teleprocessing• File-Server

– There is a large amount of network traffic– A full copy of the DBMS is required on each

workstation.– Concurrency, recovery, and integrity control

are more complex.

• Client-Server

Page 36: Database Environment Chapter 2 AIT632 Sungchul Hong.

•File-Server

Page 37: Database Environment Chapter 2 AIT632 Sungchul Hong.

Client-Server

• It enables wider access to existing databases.• Increased performance.

– Different types of computers works in parallel.

• Hardware cost are reduced.• Communication costs are reduced.• Increased consistency – single server• It maps on to open-systems architecture naturally.

Page 38: Database Environment Chapter 2 AIT632 Sungchul Hong.

•Client-Server

Page 39: Database Environment Chapter 2 AIT632 Sungchul Hong.

import java.sql.*;import java.io.*;import java.util.*;//import javax.servlet.*;//import javax.servlet.http.*;

public class Total1 {

public static void main (String[] arg)

{ //ServletOutputStream out = res.getOutputStream();

//Load the oracle JDbc driver }

Page 40: Database Environment Chapter 2 AIT632 Sungchul Hong.

try {

Class.forName ("oracle.jdbc.driver.OracleDriver"); } catch (Exception e) { System.out.println("Could not load driver"); }

// Connect to the database

try { Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@orion.towson.edu:1521:cosc", “user_name",“password"); Statement stmt = conn.createStatement ();

Page 41: Database Environment Chapter 2 AIT632 Sungchul Hong.

ResultSet rset=null;

try {

rset= stmt.executeQuery("SELECT * from department");

ResultSetMetaData rsmd=rset.getMetaData();

while (rset.next()) { System.out.println(" " + rset.getString(1) + " " + rset.getString(2) + " " + rset.getString(3) +" "); }

Page 42: Database Environment Chapter 2 AIT632 Sungchul Hong.

catch (SQLException e){ System.out.println("writetolog: error in SQL "+e+"<br>"); } } catch (SQLException e) { System.out.println("Something wrong " + e.toString());

}}}


Recommended