Top Banner
1 Jerry Post Copyright © 2003 Database Management Database Management Systems Systems Chapter 1 Introduction
41

Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

Jan 04, 2016

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

1

Jerry PostCopyright © 2003

Database Management Database Management SystemsSystems

Chapter 1

Introduction

Page 2: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

2

DDAATTAABBAASSEE

Goal: Build a Business Application

Tools:Database DesignSQL (queries)Programming

Des

ign

SQ

L

Pro

gram

Des

ign

SQ

L

Pro

gram

Best:Spend your timeon design and SQL.

Worst:Compensate for poor designand limited SQL with programming.

Page 3: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

3

DDAATTAABBAASSEE

DBMS: Database Management System

DatabaseA collection of data stored in a standardized format,

designed to be shared by multiple users.

Database Management SystemSoftware that defines a database, stores the data, supports

a query language, produces reports, and creates data entry screens.

Page 4: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

4

DDAATTAABBAASSEE

Application Development

Feasibility Identify scope, costs, and schedule

Implementation Transfer data, install, train, review

Development Create forms, reports, and help; test

Design Define tables, relationships, forms, reports

Analysis Gather information from users

tasks

time

Page 5: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

5

DDAATTAABBAASSEE

1. Identify business rules.

2. Define tables and relationships.

3. Create input forms and reports.

4. Combine as applications for users.

DBMS Application Design

Page 6: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

6

DDAATTAABBAASSEE

DBMS Features/Components Database engine

StorageRetrievalUpdate

Query Processor Data dictionary Utilities Security

Report writer Forms generator (input

screens) Application generator Communications 3GL Interface

Page 7: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

7

DDAATTAABBAASSEE

DBMS Engine, Security, Utilities

DataTables

DatabaseEngine

ProductItemID Description887 Dog food946 Cat food

OrderOrderID ODate9874 3-3-979888 3-9-97

CustomerCustomerID Name1195 Jones2355 Rojas

ProductItemID Integer, UniqueDescription Text, 100 charCustomerCustomerID Integer, UniqueName Text, 50 char

SecurityUser IdentificationAccess Rights

Utilities

Concurrency andLock Manager

Backup andRecovery

Administration

DataDictionary

Page 8: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

8

DDAATTAABBAASSEE

Database Tables (Access)

Page 9: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

9

DDAATTAABBAASSEE

Database Tables (Oracle)

Page 10: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

10

DDAATTAABBAASSEE

Field Category AnimalID

Table Animal Animal

Totals Group By Count

Sort Descending

Criteria

Or

AnimalIDNameCategoryBreed

Animal

DBMS Query ProcessorAll Data

Database EngineData Dictionary

Query Processor

Category CountOfAnimalID

Dog 100

Cat 47

Bird 15

Fish 14

Reptile 6

Mammal 6

Spider 3

Page 11: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

11

DDAATTAABBAASSEE

DBMS Report WriterAll Data

Database EngineData Dictionary

Query Processor

Report Writer

ReportFormat

and Query

Page 12: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

12

DDAATTAABBAASSEE

Report Writer (Oracle)

Page 13: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

13

DDAATTAABBAASSEE

DBMS Input FormsAll Data

Database EngineData Dictionary

Query Processor

Form Builder

InputForm

Design

Page 14: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

14

DDAATTAABBAASSEE

DBMS Components

All Data

Database EngineData Dictionary

Security

Query Processor

FormBuilder

ReportWriter

CommunicationNetwork

3GLConnector

Program

ApplicationGenerator

Page 15: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

15

DDAATTAABBAASSEE

Advantages of Database Approach

Minimal data redundancy. Data consistency. Integration of data. Sharing of data. Enforcement of standards. Ease of application development. Uniform security, privacy and integrity. Data independence.

Page 16: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

16

DDAATTAABBAASSEE

Database Management Approach Data is most important

Data defined firstStandard format

Access through DBMSQueries, Reports, FormsApplication Programs3GL Interface

Data independenceChange data definition

without changing codeAlter code without

changing dataMove/split data without

changing code

All Data

DBMS

Program1 Program2QueriesReports

Page 17: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

17

DDAATTAABBAASSEE

Modifying Data with DBMS

Add cell number to employee tableOpen table definitionAdd data element If desired, modify reports

Use report writerNo programming

Existing reports, queries, code will all run as before with no changes.

Field Name Data Type Description

EmployeeID Number Autonumber..TaxpayerID Text Federal IDLastName TextFirstName Text . . . Phone Text . . .

CellPhone Text Cellular . . .

Page 18: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

18

DDAATTAABBAASSEE

Drawbacks of old File methods

Uncontrolled DuplicationWastes spaceHard to update all files

Inconsistent data Inflexibility

Hard to change dataHard to change programs

Limited data sharing Poor enforcement of standards Poor programmer productivity Excessive program maintenance

Page 19: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

19

DDAATTAABBAASSEE

File Method Problems

Files defined in programCannot read file without

definitionHard to find definitionEvery time you alter file,

you must rewrite codeChange in a program/file

will crash other codeCannot tell which

programs use each file

Multiuser problemsConcurrencySecurity

AccessBackup & Restore

Efficiency IndexesProgrammer talent

System Application

Page 20: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

20

DDAATTAABBAASSEE

Old File Method/3GL

Data Definition File 1 … File 2 …

Data Definition File A File 2 File C …

Pay History

Benefits

Employee

EmployeeChoices

FilesProgramsPayroll

Benefits

Page 21: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

21

DDAATTAABBAASSEE

Example of File Method v DBMS

File Division01 Employees 02 ID 02 Name 02 Address

01 Department 02 ID 02 . . .

COBOL

112 Davy Jones 999 ElmStreet . . . 113 Peter Smith101 Oak St . . .

Employee File

More programsFile Division01 Employees...

Add to file (e.g.Cell phone)Write code to copy employee file

and add empty cell phone slot.Find all programs that use

employee file.Modify file definitions.Modify reports (as needed)Recompile, fix new bugs.

Easier: Keep two employee files?

02 Cell Phone

Page 22: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

22

DDAATTAABBAASSEE

Examples of Commercial Systems

Oracle Informix (Unix) DB2, SQL/DS (IBM) Access (Microsoft) SQL Server (Microsoft +) Many older (Focus, IMS, ...) mySQL ProgresSQL

Page 23: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

23

DDAATTAABBAASSEE

Hierarchical DatabaseCustomers

Orders

Item Description Quantity998 Dog Food 12764 Cat Food 11

Items

Customer

Order

Items Ordered

To retrieve data, you must start at the top (customer). When you retrieve a customer, you retrieve all nested data.

Page 24: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

24

DDAATTAABBAASSEE

Network Database

Customer

OrderItems

Ordered

Items

Entry point

Entry point

Page 25: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

25

DDAATTAABBAASSEE

Relational Database

Customer(CustomerID, Name, …

Order(OrderID, CustomerID, OrderDate, …

ItemsOrdered(OrderID, ItemID, Quantity, …

Items(ItemID, Description, Price, …

Page 26: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

26

DDAATTAABBAASSEE

Object-Oriented DBMSCustomer

CustomerIDName… Add CustomerDrop CustomerChange Address

OrderOrderIDCustomerID… NewOrderDeleteOrder…

OrderItemOrderIDItemID… OrderItemDropOrderItem…

ItemItemIDDescription… New ItemSell ItemBuy Item …

GovernmentCustomer

ContactNameContactPhoneDiscount, …

NewContact

CommercialCustomer

ContactNameContactPhone…

NewContact

Page 27: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

27

DDAATTAABBAASSEE

Base Data Types Numbers

Integers Reals

Text Length International

Date/Time Images

Bitmap Vector

Sound Samples MIDI

Video

Numbers,Text, andDates

Images

Sound

Video

Input Process Output

12 + 8 = 20000001100000001000----------------000010100 20

001000000000000000001000000000000010010110000011000011011011111111111100111111111111111110111111111111111100011111

8 9 20 7 8 19 5 6 15000001000 000001001 000010100 .....

pitch,volume

time

0010101011111010101010010101010101111010001100101011011

0010101011111010101010010101010101111010001100101011011

0010101011111010101010010101010101111010001100101011011

0010101011111010101010010101010101111010001100101011011

0010101011111010101010010101010101111010001100101011011

Page 28: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

28

DDAATTAABBAASSEE

Objects Object Definition--

encapsulation.Object NamePropertiesMethods

Most existing DBMS do not handle inheritance.Combine into one table.Use multiple tables and

link by primary key.More efficient.Need to add rows to

many tables.

Customer

CustomerIDAddressPhone

AddCustomerDropCustomer

Class name

Properties

Methods

Commercial

ContactVolumeDiscount

ComputeDiscount

Government

ContactBalanceDue

BillLateFeesAddCustomer

Inheritance

Polymorphism

Page 29: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

29

DDAATTAABBAASSEE

Objects in a Relational Database

CustomerIDAddressPhone

Customer

CustomerIDContactVolumeDiscount

CommercialCustomer

CustomerIDContactBalanceDue

GovernmentCustomer

Separate inherited classes. Link by primary key. Adding a new customer

requires new rows in each table.

Definitely need cascade delete.

Page 30: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

30

DDAATTAABBAASSEE

OO Difficulties: Methods

Database Object

CustomerMethod:

Add New CustomerApplication

CustomerNameAddressPhone

Personal Computer

Unix Server

IBM Server

Program code

Database Object

How can a method run on different computers?

Different processors use different code.

Possibility: Java

Page 31: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

31

DDAATTAABBAASSEE

SQL 99: OO Features

Abstract data type User defined data types. Equality and ordering

functions. Encapsulation: Public,

Private, Protected. Inheritance.

Sub-tables that inherit all columns from another table.

Persistent Stored Modules (Programming Language). Create methods. SQL and extensions. External language.

User defined operators. Triggers for events. External language support

Call-Level Interface (CLI)Direct access to DBMS

Embedded SQLSQL commands in an

external language.

Page 32: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

32

DDAATTAABBAASSEE

Abstract Data Types

GeoPointLatitudeLongitudeAltitude

GeoLineNumberOfPointsListOfGeoPoints

Procedure: DrawRegion{

Find region components.SQL: Select …

For each component {Fetch MapLineSet line attributesMapLine.Draw

}}

Page 33: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

33

DDAATTAABBAASSEE

SQL 99 Sub-Tables

CREATE SET TABLE CommercialCustomer(

Contact VARCHAR,VolumeDiscount NUMERIC(5,2)

)UNDER Customer;

CREATE SET TABLE Customer(

CustomerID INTEGER,Address VARCHAR,Phone CHAR(15)

)

CustomerIDAddressPhone

Customer

ContactVolumeDiscount

CommercialCustomer

Inherits columnsfrom Customer.

Page 34: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

34

DDAATTAABBAASSEE

SQL 99: Programming

Database

Data Types Tables, …

Persistent Stored ModulesSQLExtended SQL codeExternal language code

External Programs

Embedded SQLCall-Level Interface

CURSOR … SELECT … FETCH …

Page 35: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

35

DDAATTAABBAASSEE

OODBMS Vendors

GemStone Systems, Inc. Hewlett-Packard, Inc. (OpenODB) IBEX Corporation, SA. Illustra (Informix, Inc.) Matisse Software, Inc. O2 Technology, Inc. Objectivity, Inc. Object Design, Inc. ONTOS, Inc. POET Software Corporation UniSQL Unisys Corporation (OSMOS) Versant Object Technology

Page 36: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

36

DDAATTAABBAASSEE

Why don’t all developers use a DBMS?

Most new projects (in last 5 years) do use a DBMS Need specialized personnel

ProgrammersDesigners/AnalystsDatabase administrators

Need to define data for organization Cost

PC: $400 - $2000Large: $100,000 +

Page 37: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

37

DDAATTAABBAASSEE

How do you sell a DBMS approach?

Applications change a lot, but same data. Need for ad hoc questions and queries. Need to reduce development times. Need shared data. Improve quality of data. Enable users to do more development.

Page 38: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

38

DDAATTAABBAASSEE

Building the Right System: Feasibility Costs

Up-front/one-time Software ($ millions !) Hardware Communications Data conversion Studies and Design Training

On-going costs Personnel Software upgrades Supplies Support Software & Hardware

maintenance

Benefits Cost Savings

Software maintenance Fewer errors Less data maintenance Less user training

Increased Value Better access to data Better decisions Better communication More timely reports Faster reaction to change New products & services

Strategic Advantages Lock out competitors

Easy to estimate Hard to value

Page 39: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

39

DDAATTAABBAASSEE

Economic Feasibility: NPVYear Benefits Costs Net

0 0 50000 -500001 18000 5000 130002 18000 5000 130003 18000 5000 130004 18000 5000 130005 18000 5000 13000

Discount Rate0.05 0.07 0.10

NPV $6,283.20 $3,302.57 ($719.77)

=NPV(B14,$D$7:$D$11)+$D$6

=NPV(rate, range) + starting

Page 40: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

40

DDAATTAABBAASSEE

Exercise: Build a First DatabaseEmployee(EmployeeID, LastName, FirstName, Address, DateHired)

332 Ant Adam 354 Elm 5/5/1964442 Bono Sonny 765 Pine 8/8/1972553 Cass Mama 886 Oak 2/2/1985673 Donovan Michael 421 Willow 3/3/1971773 Moon Keith 554 Cherry 4/4/1972847 Morrison Jim 676 Sandalwood 5/5/1968

Client(ClientID, LastName, FirstName, Balance, EmployeeID)1101 Jones Joe 113.42 4422203 Smith Mary 993.55 6732256 Brown Laura 225.44 3324456 Dieter Jackie 664.90 4425543 Wodkoski John 984.00 8476673 Sanchez Paula 194.87 7737353 Chen Charles 487.34 3327775 Hagen Fritz 595.55 6738890 Hauer Marianne 627.39 7739662 Nguyen Suzie 433.88 5539983 Martin Mark 983.31 847

Page 41: Jerry Post Copyright © 2003 1 Database Management Systems Chapter 1 Introduction.

41

DDAATTAABBAASSEE

Exercise: Report

Ant, Adam 5/5/1964Brown, Laura 225.24Chen, Charles 487.34

712.58

Bono, Sonny 8/8/1972Dieter, Jackie 664.90Jones, Joe 114.32

779.22