Vous êtes sur la page 1sur 41

Database Management Systems

Chapter 1
Introduction

Jerry Post
Copyright © 2003
1
D Goal: Build a Business Application
A Tools:
Database Design
T SQL (queries)
Programming

Program
Design

SQL
B Best:
Spend your time
A on design and SQL.
Program
Design

SQL

S Worst:

E Compensate for poor design


and limited SQL with programming.

2
D DBMS: Database Management System
A
 Database
T  A collection of data stored in a standardized format,
designed to be shared by multiple users.
A  Database Management System
 Software that defines a database, stores the data, supports
B a query language, produces reports, and creates data entry
screens.
A
S
E
3
D tasks Application Development
A Feasibility

T
Identify scope, costs, and schedule

Analysis
Gather information from users
A Design
Define tables, relationships, forms, reports
B Development
Create forms, reports, and help; test

A Implementation
Transfer data, install, train, review

S time

E
4
D DBMS Application Design
A 1. Identify business rules.

T
A
B 2. Define tables and relationships.

A 3. Create input forms


and reports.

S
4. Combine as
E applications for users.

5
D DBMS Features/Components
A  Database engine
 Storage
 Report writer
 Forms generator (input
T  Retrieval
 Update
screens)
 Application generator
A  Query Processor  Communications
 Data dictionary
B  Utilities
 3GL Interface

A  Security

S
E
6
D DBMS Engine, Security, Utilities
A Order
Product
ItemID Description
887 Dog food

T
OrderID ODate
Customer
9874
946 Cat food
3-3-97
CustomerID Name
Data
9888 3-9-97
1195 Jones Tables
A
2355 Rojas

Database
B
Product
Customer
ItemID Integer, Unique Engine
CustomerID
Description Integer,
Text, 100
Unique
char
A Name Text, 50 char Data
Dictionary

S User Identification
Access Rights
Security Concurrency and
Lock Manager

E Backup and
Recovery
Utilities
Administration

7
D Database Tables (Access)
A
T
A
B
A
S
E
8
D Database Tables (Oracle)
A
T
A
B
A
S
E
9
D DBMS Query Processor
A All Data
Database Engine
T Data Dictionary

A Animal
Query Processor

B
AnimalID
Name Category CountOfAnimalID
Category
Dog 100
Breed

A Field Category AnimalID


Cat
Bird
47
15
Table Animal Animal

S Totals
Sort
Group By Count
Descending
Fish
Reptile
14
6

E
Mammal 6
Criteria
Or Spider 3

10
D DBMS Report Writer
All Data
A Database Engine
T Data Dictionary
Query Processor
A Report Writer

B
A Report
Format
S and Query

E
11
D Report Writer (Oracle)
A
T
A
B
A
S
E
12
D DBMS Input Forms
A All Data
Database Engine
T Data Dictionary

A Query Processor
Form Builder
B
A Input
S Form
Design
E
13
D DBMS Components
A
All Data
T
A Communication
Database Engine
Data Dictionary 3GL
B Network Security Connector
Query Processor
A Form Report
Program
Builder Writer
S Application
Generator
E
14
D Advantages of Database Approach
A
 Minimal data redundancy.
T  Data consistency.

A  Integration of data.
 Sharing of data.
B  Enforcement of standards.
 Ease of application development.
A  Uniform security, privacy and integrity.

S  Data independence.

E
15
D Database Management Approach
A  Data is most important
 Data defined first

T  Standard format
 Access through DBMS
A  Queries, Reports, Forms
 Application Programs
All Data

B  3GL Interface
DBMS
 Data independence
A  Change data definition
without changing code Queries
S  Alter code without
changing data
Program1
Reports
Program2

E  Move/split data without


changing code

16
D Modifying Data with DBMS
A Field Name Data Type Description
 Add cell number to
T employee table EmployeeID
TaxpayerID
Number
Text
Autonumber..
Federal ID
 Open table definition
A
LastName Text
 Add data element FirstName Text
...
 If desired, modify reports
B
Phone Text
 Use report writer ...
 No programming
A
CellPhone Text Cellular . . .
 Existing reports,
queries, code will all run
S as before with no
changes.
E
17
D Drawbacks of old File methods
A
 Uncontrolled Duplication
T  Wastes space
 Hard to update all files
A  Inconsistent data
 Inflexibility
B  Hard to change data

A  Hard to change programs


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

18
D File Method Problems
A
 Files defined in program  Multiuser problems
T  Cannot read file without
definition
 Concurrency
 Security
A  Hard to find definition
 Every time you alter file,
 Access
 Backup & Restore
B you must rewrite code
 Change in a program/file
 Efficiency
 Indexes

A will crash other code


 Cannot tell which
 Programmer talent
System

S programs use each file Application

E
19
D Old File Method/3GL
A Programs
Payroll
Files

T Data Definition
File 1
Pay History

A

File 2

B Benefits
Benefits

A Data Definition
File A Employee
File 2
S File C
… Employee
E Choices

20
D Example of File Method v DBMS
A COBOL
File Division
Employee File
112 Davy Jones 999 Elm
01 Employees
T 02 ID
02 Name
Street . . . 113 Peter Smith
101 Oak St . . .

A 02 Address
02 Cell Phone
 Add to file (e.g.Cell phone)
 Write code to copy employee file
B 01 Department
02 ID and add empty cell phone slot.
 Find all programs that use
02 . . .
A More programs
employee file.
 Modify file definitions.
File Division
S 01 Employees
...
 Modify reports (as needed)
 Recompile, fix new bugs.
 Easier: Keep two employee
E files?

21
D Examples of Commercial Systems
A
 Oracle
T  Informix (Unix)

A  DB2, SQL/DS (IBM)


 Access (Microsoft)
B  SQL Server (Microsoft +)
 Many older (Focus, IMS, ...)
A  mySQL

S  ProgresSQL

E
22
D Hierarchical Database
A Customers
Customer
T Order

A Items Ordered

B Orders

A To retrieve data, you


must start at the top
Items
S Item Description
998 Dog Food
Quantity
12
(customer). When you
retrieve a customer, you
E 764 Cat Food 11
retrieve all nested data.

23
D Network Database
A Entry point

T Customer
A
B Order
Items
Ordered
A
S Items
Entry point

E
24
D Relational Database
A
T Customer(CustomerID, Name, …

A Order(OrderID, CustomerID, OrderDate, …

B ItemsOrdered(OrderID, ItemID, Quantity, …

A Items(ItemID, Description, Price, …

S
E
25
D Object-Oriented DBMS
A Order
OrderID
Customer
CustomerID Government
T CustomerID

Name

Customer
Commercial
ContactName
Customer
NewOrder Add Customer ContactPhone
A
ContactName
DeleteOrder Drop Customer Discount, …
ContactPhone
… Change Address …
B OrderItem Item
NewContact
NewContact

A OrderID
ItemID
ItemID
Description

S OrderItem
DropOrderItem

New Item
Sell Item
E … Buy Item …

26
D Base Data Types
A  Numbers
 Integers

T  Reals
 Text

A  Length
 International Input Process Output
Numbers,
B  Date/Time
 Images
Text, and
Dates
12 + 8 = 20
000001100
000001000
----------------
000010100 20
A
0010000000000000000
 Bitmap 0100000000000001001
0110000011000011011
0111111111111001111
Images 1111111111111011111
1111111111100011111
 Vector
pitch,

S
volume
 Sound Sound 8 9 20 7 8 19 5 6 15
time
 Samples 000001000 000001001 000010100 .....

 MIDI
00101010111
00101010111

E
00101010111

Video
11010101010
11010101010
11010101010
01010101010
01010101010 01010101010
11110100011
11110100011
11110100011
00101011011
00101011011 00101011011
00101010111
00101010111

 Video
11010101010
11010101010
01010101010
01010101010
11110100011
11110100011
00101011011
00101011011

27
D Objects
A  Object Definition--
encapsulation.
Class name Customer
CustomerID

T  Object Name
 Properties
Properties Address
Phone

A  Methods Methods AddCustomer


DropCustomer
 Most existing DBMS do
B not handle inheritance. Inheritance
 Combine into one table.
A
Commercial Government
 Use multiple tables and Contact Contact
link by primary key. VolumeDiscount BalanceDue

S  More efficient.
 Need to add rows to ComputeDiscount BillLateFees

E many tables.
Polymorphism
AddCustomer

28
D Objects in a Relational Database
A  Separate inherited classes.
 Link by primary key.
T  Adding a new customer
requires new rows in each

A table.
 Definitely need cascade
Customer
CustomerID
Address
B delete.
Phone

A CommercialCustomer GovernmentCustomer

S CustomerID
Contact
CustomerID
Contact
VolumeDiscount BalanceDue
E
29
D OO Difficulties: Methods
A IBM Server

T Unix Server
Database Object
A Personal Computer

B Database Object How can a method


run on different
A Customer
Method:
Add New Customer
Application computers?
Customer Different
S Program code Name
Address
processors use
different code.
E
Phone
Possibility: Java

30
D SQL 99: OO Features
A  Abstract data type  Persistent Stored Modules
T  User defined data types.
 Equality and ordering
(Programming Language).
 Create methods.

A functions.
 Encapsulation: Public,
 SQL and extensions.
 External language.
Private, Protected.
B  Inheritance.
 User defined operators.
 Triggers for events.
 Sub-tables that inherit all
A columns from another table.
 External language support
 Call-Level Interface (CLI)

S
 Direct access to DBMS
 Embedded SQL
 SQL commands in an
E external language.

31
D Abstract Data Types
A
GeoPoint
T Procedure: DrawRegion
{ Latitude
Longitude
Find region components.
A SQL: Select …
For each component {
Altitude

B
Fetch MapLine
Set line attributes GeoLine
MapLine.Draw NumberOfPoints
A }
}
ListOfGeoPoints

S
E
32
D SQL 99 Sub-Tables
A CREATE SET TABLE Customer
( Customer
T CustomerID
Address
INTEGER,
VARCHAR,
CustomerID
Address

A )
Phone CHAR(15) Phone

B CREATE SET TABLE CommercialCustomer


(
Inherits columns
from Customer.

A Contact VARCHAR,
VolumeDiscount NUMERIC(5,2) CommercialCustomer
)
S UNDER Customer; Contact
VolumeDiscount

E
33
D SQL 99: Programming
A Database External Programs

T Data Types Tables, … Embedded SQL


Call-Level Interface
Persistent Stored Modules
A SQL
Extended SQL code
CURSOR …
SELECT …

B External language code FETCH …

A
S
E
34
D OODBMS Vendors
A GemStone Systems, Inc.
Hewlett-Packard, Inc. (OpenODB)
T IBEX Corporation, SA.
Illustra (Informix, Inc.)
A Matisse Software, Inc.
O2 Technology, Inc.
Objectivity, Inc.
B Object Design, Inc.
ONTOS, Inc.
A POET Software Corporation
UniSQL

S Unisys Corporation (OSMOS)


Versant Object Technology

E
35
D Why don’t all developers use a DBMS?
A
 Most new projects (in last 5 years) do use a DBMS
T  Need specialized personnel
 Programmers
A  Designers/Analysts

B
 Database administrators
 Need to define data for organization

A  Cost
 PC: $400 - $2000

S  Large: $100,000 +

E
36
D How do you sell a DBMS approach?
A
 Applications change a lot, but same data.
T  Need for ad hoc questions and queries.

A  Need to reduce development times.


 Need shared data.
B  Improve quality of data.
 Enable users to do more development.
A
S
E
37
D Building the Right System: Feasibility
A  Costs
 Up-front/one-time
 Benefits
 Cost Savings
 Software maintenance
T
 Software ($ millions !)
 Hardware  Fewer errors
 Communications  Less data maintenance

A  Data conversion
 Studies and Design
 Less user training
 Increased Value

B
 Training  Better access to data
 On-going costs  Better decisions
 Personnel  Better communication

A  Software upgrades
 Supplies
 More timely reports
 Faster reaction to change

S
 Support  New products & services
 Software & Hardware  Strategic Advantages
maintenance  Lock out competitors

E Easy to estimate Hard to value

38
D Economic Feasibility: NPV
A Year
0
Benefits
0
Costs
50000
Net
-50000
T 1
2
18000
18000
5000
5000
13000
13000
A 3
4
18000
18000
5000
5000
13000
13000
B 5 18000 5000 13000

A 0.05
Discount Rate
0.07 0.10

S NPV $6,283.20 $3,302.57


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

E =NPV(rate, range) + starting

39
D Exercise: Build a First Database
A Employee(EmployeeID, LastName, FirstName, Address, DateHired)
332 Ant Adam 354 Elm 5/5/1964

T 442
553
Bono
Cass
Sonny
Mama
765 Pine
886 Oak
8/8/1972
2/2/1985
673 Donovan Michael 421 Willow 3/3/1971
A 773
847
Moon
Morrison
Keith
Jim
554 Cherry
676 Sandalwood
4/4/1972
5/5/1968

B Client(ClientID, LastName, FirstName, Balance, EmployeeID)


1101 Jones Joe 113.42 442

A 2203
2256
Smith
Brown
Mary
Laura
993.55
225.44
673
332
4456 Dieter Jackie 664.90 442
S 5543
6673
Wodkoski John
Sanchez Paula
984.00
194.87
847
773

E
7353 Chen Charles 487.34 332
7775 Hagen Fritz 595.55 673
8890 Hauer Marianne 627.39 773
9662 Nguyen Suzie 433.88 553
9983 Martin Mark 983.31 847 40
D Exercise: Report
A Ant, Adam 5/5/1964
Brown, Laura 225.24

T Chen, Charles 487.34


712.58

A Bono, Sonny 8/8/1972


Dieter, Jackie 664.90
Jones, Joe 114.32
B 779.22

A
S
E
41

Vous aimerez peut-être aussi