PowerPoint 프레젠테이션

Download Report

Transcript PowerPoint 프레젠테이션

Great Ideas of CS with Java








Part 1 WWW & Computer programming in the language Java
Ch 1: The World Wide Web
Ch 2: Watch out: Here comes Java
Ch 3: Numerical computation & Function
Ch 4: Subroutines & Databases
Ch 5: Graphics
Ch 6: Simulation
Ch 7: Software engineering







Part 2 Understanding what a computer is and how it works
Ch 8: Machine architecture
Ch 9: Language translation
Ch 10: Virtual Environment for Computing
Ch 11: Security, Privacy, and Wishful thinking
Ch 12: Computer Communication






Part 3 Advanced topics
Ch 13: Program Execution Time
Ch 14: Parallel Computation
Ch 15: Noncomputability
Ch 16: Artificial intelligence
1
SNU
IDB Lab.
Ch4.
Top-Down Programming, Subroutines,
and a Database Application
Copyright © 2006 SNU IDB Lab.
SNU
2
IDB Lab.
Table of contents







How to Deal with the Complexity?
Subroutines
Subroutines with array parameters
Subroutine communication examples
Storing and printing for the Database
Recursion
Summary
3
SNU
IDB Lab.
How to Deal with the Complexity?
A Big Issue in Program: How to Deal with the Complexity?

For keeping the greater complexity of large programs under control



SW Design Methodology


The method of top-down programming
The use of subroutines
Stepwise Refinement
Implementation: Top-Down programming with subroutines
4
SNU
IDB Lab.
Stepwise Refinement


Represent the problem so that it can be dealt with easily.
Decompose the problem into simpler subtasks and then
repeatedly decompose those subtasks.
Main Task
SubTask
Trivial
SubTask
Trivial
SubTask
SubTask
SubTask
SubTask
Trivial
SubTask
5
SNU
IDB Lab.
Design a Simple Database Program (1/3)


Database program is a program that stores a lot of information and
answers questions about it
Stage 1 Refinement: Database Program can be decomposed into four
subtasks




Find : Receives questions and prints all the relevant facts
Input : Reads facts
Print : Prints all the stored facts
Quit : Terminates program execution
Database Applet
Input
Print
Find
6
Quit
SNU
IDB Lab.
Design a Simple Database Program (2/3)

Find routine


Read user’s request
For each position in memory that has a fact in it,



Stage 2 Refinement


Check if that fact helps to answer the question
print it
More care needs to be exercised for the underlined part.
Find routine with question-fact comparator


Read user’s request
For each position in memory that has a fact in it,


call the question-fact comparator
If the comparator reports “answer”, then print the fact
7
SNU
IDB Lab.
Design a Simple Database Program (3/3)

Now the program structure becomes as follows
Database Applet
Input
Print
Find
Quit
Question-Fact
Comparator

Complicated database program is now effectively reduced to rather
easily handled subparts.
8
SNU
IDB Lab.
Table of contents

How to Deal with the Complexity?

Subroutines





Subroutines with array parameters
Subroutine communication examples
Storing and printing for the Database
Recursion
Summary
9
SNU
IDB Lab.

Figure 4.4
10
SNU
IDB Lab.
Subroutines (1)

A subroutine is a sequence of programming statements



Subroutine, subprogram, method, function, and procedure
A means for avoiding typing the same lines again and again
A means to isolate one task from another

A subroutine has a list of arguments for getting outside data

Global variables are not recommended in most cases


Only local variables or passing values
Data scope


Instance Variable in a class  Known within class
Local Variable of a function or method  Known within block
11
SNU
IDB Lab.
Subroutines (2)

Syntax: Defining a Function


If return-type is "void"



function-name(arg1, arg2, ...);
If function returns some values


return-type function-name(type1 param1, type2 param2, ...);
var = function-name(arg1, arg2, ...);
Rules for Formal Parameters/Arguments in Subroutine calls in Java

by position, not by name (names may or may not match)

types must match

number of parameters must match
Value Parameters vs Reference Parameters

Primitive Types: by value

Class or Arrays: by reference
12
SNU
IDB Lab.
WrittenBy.Java (144page)
import java.awt.*;
import java.awt.event.*;
public class writtenBy extends java.applet.Applet
implements ActionListener
{
TextField m0, g0, m1, m2;
Button b1;
String author;
void Byline2(String name)
{
m1.setText(“This program was written by”);
m2.setText(“ “ + name);
}
String GetName()
{
String name;
name = g0.getText();
return name;
}
public void init()
{
m0 = new TextField(80)
m0.setText(“Enter author below and press button.”);
g0 = new TextField(80);
m1 = new TextField(80);
m2 = new TextField(80);
b1 = new Button(“button”);
add(m0);
add(g0);
add(b1);
add(m1);
add(m2);
b1.addActionListener(this)
}
public void actionPerformed(ActionEvent event)
{
author = GetName();
Byline2(author);
}
}
WrittenBy.java
13
SNU
IDB Lab.
Figure 4.7
14
SNU
IDB Lab.
Figure 4.8
15
SNU
IDB Lab.
Table of contents







How to Deal with the Complexity?
Subroutines
Subroutines with array parameters
Subroutine communication examples
Storing and printing for the Database
Recursion
Summary
16
SNU
IDB Lab.
Subroutines with array parameters

Model Phone Book Capability





Array (of strings) for Names
Array (of strings) for Phone Number
Array (of strings) for Address
Typical Access by Name
Access by other Fields (other arrays)


Global Arrays



Can access by phone number and get name/address
Implementing a "Phone List" Using Two Arrays LookUp.java
Implementing a "Phone List" in a Single Array Search.java
ArraySum program in Page 150

SumArray( int[] data, int firstempty)
17
SNU
IDB Lab.
import awb.*;
import java.awt.*;
import java.awt.event.*;
public class LookUp extends java.applet.Applet
implements ActionListener
{
TextField gName, gNum, mInstruct;
String Name[] ={"J.Able", "D.Ramm", "D.Ramm",
"R.Odom", "M.Salter", "W.Tars"};
String Num[] = {"613-1978","660-6532","732-7616",
"681-6326", "684-8111","613-1978"};
Button bByName, bByNum;
TextArea mResults;
String name, num;
int size;
public void actionPerformed(ActionEvent event)
{
Object cause = event.getSource();
int k=0;
public void init()
{
mInstruct = new TextField(60);
mInstruct.setText("Enter search info; push related button");
gName = new TextField(25);
gNum = new TextField(25);
bByName = new Button("ByName");
bByNum = new Button("ByNum");
mResults = new TextArea(10, 60);
bByName.addActionListener(this);
bByNum.addActionListener(this);
add(mInstruct);
add(gName);
add(bByName);
add(gNum);
}
add(bByNum);
}
add(mResults);
size = 6;
}
if (cause == bByName)
{
name = gName.getText();
while (k < size)
{
if (name.equals(Name[k]))
{
mResults.append("Name: "+name+" shows number: "+
Num[k]+"\n");
}
k = k + 1;
}
}
if (cause == bByNum)
{
num = gNum.getText();
while (k < size)
{
if (num.equals(Num[k]))
{
mResults.append("Number: "+num+" shows name: "+
Name[k]+"\n");
}
k = k + 1;
}
}
LookUp.java
18
SNU
IDB Lab.
import awb.*;
import java.awt.*;
import java.awt.event.*;
public void actionPerformed(ActionEvent event)
{
Object cause = event.getSource();
int k=0;
public class Search extends java.applet.Applet
implements ActionListener
{
TextField gKey, mInstruct;
String Info[] ={"J.Able, 613-1978", "D.Ramm, 660-6532",
"D.Ramm, 732-7616", "R.Odom, 681-6326",
"M.Salter, 684-8111", "W.Tars, 613-1978"};
Button bSearch;
TextArea mResults;
String key;
int size = 6;
public void init()
{
mInstruct = new TextField(60);
mInstruct.setText("Enter search info; push button");
gKey = new TextField(35);
bSearch = new Button("Search");
mResults = new TextArea(10, 60);
bSearch.addActionListener(this);
add(mInstruct);
add(gKey);
add(bSearch);
add(mResults);
}
}
}
if (cause == bSearch)
{
key = gKey.getText();
while (k < size)
{
if (Info[k].indexOf(key) >= 0)
{
mResults.append(Info[k]+"\n");
}
k = k + 1;
}
}
Search.java
Remember?
int word.indexOf(String st)
-- Returns position of start of first match of st in word
-- Returns -1 if there is no match
19
SNU
IDB Lab.
Table of contents







How to Deal with the Complexity?
Subroutines
Subroutines with array parameters
Subroutine communication examples
Storing and printing for the Database
Recursion
Summary
20
SNU
IDB Lab.
No parameter  No communication
Applet {
….
void Triple()
{ double r1, r2;
r2 = 3 * r1;
}
….
Triple();
….
}
Figure 4.9
21
SNU
IDB Lab.
Global Variables may be Harmful
It works, but no communication through subroutine parameters!
Applet {
DoubleField dR1;
TextField
mR2;
….
void Triple()
{ double r1, r2;
r1 = dR1.getDouble();
r2 = 3 * r1;
mR2.setText(“Triple the value is “ + r2);
}
….
Triple();
….
}
22
Figure 4.10
SNU
IDB Lab.
Some Global Variables, Some Parameters
Applet {
….
DoubleField dR;
TextField
mR2;
Passing information through
….
subroutine parameter
void Triple(double r1)
{ double r2;
r2 = 3 * r1;
mR2.setText(“Triple the value is “ + r2);
}
….
double r;
….
r = dR.getDouble();
Triple(r);
….
}
23
Figure 4.11
SNU
IDB Lab.
Passing information through subroutine parameter and
Getting return-value from the subroutine
Applet {
….
DoubleField dR;
TextField
mR2;
….
double Triple(double r1)
{ double r2;
r2 = 3 * r1;
return r2;
}
….
double r1, r2;
….
r1 = dR.getDouble();
r2 = Triple(r1);
mR2.setText(“Triple the value is “ + r2);
}
Figure 4.12
….
24
SNU
IDB Lab.
Table of contents







How to Deal with the Complexity?
Subroutines
Subroutines with array parameters
Subroutine communication examples
Storing and printing for the Database
Recursion
Summary
25
SNU
IDB Lab.
Storing and printing for the Database

Extend Idea to Database



Generalization of phone book problem
Can have many "parallel" arrays
Basic Data Base Functions




Load Data (File I/O would be nice)
Display Data (Complete Dump)
Query/Search (Selective Info Retrieval)
Edit/Update (Update or Correct: Edit Database)
26
SNU
IDB Lab.
Toy Database Management System

Storing a group of facts



Mr. mason is a chemist
The professor visited at 3PM
(noun phrase) (relationship) (noun phrase)
Figure 4.13
Figure 4.14
27
SNU
IDB Lab.
import awb.*;
import java.awt.*;
import java.awt.event.*;
public class DataBase extends java.applet.Applet
implements ActionListener
{
TextField gN1, gRe1, gN2, mInstruct;
String noun1A[], relationA[], noun2A[];
TextArea mResults;
Button bEnter, bAll;
int last;
public void init()
{
last = -1;
noun1A = new String[100];
relationA = new String[100];
noun2A = new String[100];
mInstruct = new TextField(70);
mInstruct.setText
("Enter facts in three fields below and press
Enter button.");
gN1 = new TextField(25);
gRe1 = new TextField(25);
gN2 = new TextField(25);
mResults = new TextArea(10, 60);
bEnter = new Button("Enter");
bAll = new Button("All");
bEnter.addActionListener(this);
bAll.addActionListener(this);
add(mInstruct);
add(gN1);
add(gRe1);
add(gN2);
add(bEnter);
add(bAll);
add(mResults);
}
public void actionPerformed(ActionEvent event)
{
Object cause = event.getSource();
if(cause == bEnter) {
InputFact();
}
if(cause == bAll) { // mainly used for debugging
DumpData();
}
}
void InputFact()
{
last = last + 1;
noun1A[last] = gN1.getText();
gN1.setText(" ");
relationA[last] = gRel.getText();
gRe1.setText(" ");
noun2A[last] = gN2.getText();
gN2.setText(" ");
}
void DumpData()
{
int k;
mResults.setText("Dump of data\n");
k = 0;
while(k <= last)
{
mResults.appent(k = " " + nooun1A[k] + " " + relationA[k] +
" " + noun2A[k] + "\m");
k = k +1;
}
}
}
28
SNU
IDB Lab.
Figure 4.15
29
SNU
IDB Lab.
TDBMS “Find” subroutine
Void Find()
{ String noun1, relation, noun2;
Int k;
noun1 = gN1.getText();
relation = gRel.getText();
Noun2 = gN2.getText();
mResults.setText(“The Related Facts/n”);
K=0;
While (k <= last) {
If (QFCompare(noun1, relation, noun2, k) ==1) // 1 means match
{ mResults.append(noun1A[k] + “ “ + relationA[k] + “ “ + noun2A[k] + “/n”);
}
k = k + 1;
}
}
30
SNU
IDB Lab.
TDBMS “QFCompare” subroutine
Int QFCompare(String noun1, String relation, String noun2, int k)
{
if (noun1.equals(noun1A[k]) && relation.equals(relationA[k]) &&
noun2.equals(noun2A[k])) )
{ return 1;
// 1 means query matched database
}
else
{ return 0;
// 0 means no match
}
}
31
SNU
IDB Lab.
Figure 4.16
32
SNU
IDB Lab.
TDBMS “QFCompare” subroutine for (?)(…)(…)
Int QFCompare(String noun1, String relation, String noun2, int k)
{
if ((noun1.equals(noun1A[k]) l l noun1.equals(“?”) )
relation.equals(relationA[k]) && noun2.equals(noun2A[k])) )
{ return 1; // 1 means query matched database
}
else
{ return 0; // 0 means no match
}
}
33
SNU
IDB Lab.
Figure 4.17
34
SNU
IDB Lab.
Figure 4.18
35
SNU
IDB Lab.
Another Database Example

Wild Card Bonus (WCB-3: 5page report)


UsedCars.java
Other Possible Commands


output counts rather than displaying data
logical expressions for numeric data give ranges
36
SNU
IDB Lab.
import awb.*;
import java.awt.*;
import java.awt.event.*;
bSearch.addActionListener(this);
gMake.addActionListener(this);
add(mInstruct);
add(year);
public class UsedCars extends java.applet.Applet
add(gYear);
implements ActionListener {
add(make);
TextField gMake, gStyle, gColor, gOwner, mInstruct;
add(gMake);
IntField gYear;
String Make[] ={"Mercedes","Mercedes","Ford", "Mercedes", add(style);
add(gStyle);
"Datsun","Ford"};
add(color);
String Style[]={"4 door", "4 door", "truck", "4 door",
add(gColor);
"2 door","4 door"};
String Color[]={"white", "ivory", "blue", "green", "red", "blue"}; add(owner);
String Owner[]={"M.Ramm", "D.Ramm", "M.Ramm","D.Ramm",add(gOwner);
add(bSearch);
"K.Ramm","D.Ramm"};
add(mResults);
int Year[] ={ 1987, 1987, 1972, 1971, 1978, 1978};
}
Label make, style, color, owner, year;
Button bSearch;
TextArea mResults;
int size = 6;
public void actionPerformed(ActionEvent event)
{
//Object cause = event.getSource();
int yea;
String mak, sty, col, own;
public void init()
{
year = new Label("Year");
//if (cause == bSearch)
make = new Label("Make");
{
style = new Label("Style");
yea = gYear.getInt();
color = new Label("Color");
mak = gMake.getText();
owner = new Label("Owner");
sty = gStyle.getText();
mInstruct = new TextField(60);
mInstruct.setText("Enter Selections, leave blank for Wild Card");col = gColor.getText();
own = gOwner.getText();
gYear = new IntField(10);
mResults.setText("Cars Matching Parameters Specified\n")
gMake = new TextField(10);
report(yea, mak, sty, col, own, size);
gStyle = new TextField(10);
}
gColor = new TextField(10);
}
gOwner = new TextField(20);
bSearch = new Button("Search");
mResults = new TextArea(10, 60);
37
SNU
IDB Lab.
boolean isMatch(int year, int yea, String make, String mak, String style,
String sty, String color, String col, String owner, String own)
{
if ((year == yea || yea == 0) && (make.equals(mak) ||mak.equals(""))
&& (style.equals(sty)||sty.equals(""))
&& (color.equals(col)||col.equals(""))
&& (owner.equals(own)||own.equals("")) )
return true;
return false;
}
}
void report(int yea, String mak, String sty, String col, String own, int num)
{
int k = 0;
while (k < num)
{
if (isMatch(Year[k], yea, Make[k], mak, Style[k], sty, Color[k], col,
Owner[k], own))
mResults.append("year: "+Year[k]+" make: "+Make[k]+" style: "
+Style[k]+" color: "+Color[k]+" owner: "+Owner[k]+"\n");
k = k + 1;
}
}
38
UsedCars.java
SNU
IDB Lab.
Table of contents

How to Deal with the Complexity?
Subroutines
Subroutines with array parameters
Storing and printing for the Database

Recursion

Summary



39
SNU
IDB Lab.
Recursion (1)


A special kind of function: Function invokes itself
Divide and Solve and Merge paradigm
 The divide and conquer methodology

Conceptually simple & Saving space

Factorial (N!)



decomposing problem
base case: 0! = 1
recursive case which gets closer to solution : n! = n * (n-1)!
40
SNU
IDB Lab.
Recursion (2)

Divide and Conquer Approach for Factorial
int factorial(int n) {
int D1, D2, R1, R2;
if (n == 0)
{ R1= 1;
return R1; }
else { D1 = n;
D2 = n-1;
R1 = D1;
R2 = factorial(D2);
return R1*R2;
}
}
41
SNU
IDB Lab.
Recursion (3)

{
}
public int factorial (int n)
if (n == 0)
{ return 1; }
else
{ return n * factorial (n - 1); }
Call factorial (3)  n=3 ,
call factorial (2)  n = 2,
call factorial (1)  n = 1
call factorial (0)
return 3*2

return 2*1
return 1*1
Java version of Factorial Numbers: RecFact.java
42
SNU
IDB Lab.
import awb.*;
import java.awt.*;
import java.awt.event.*;
public void actionPerformed(ActionEvent event)
{
int k;
public class RecFact extends java.applet.Applet
implements ActionListener
{
TextField mInstruct, mResults;
IntField gN;
Button bFact;
public int fact(int n)
{
if (n == 0)
{
return 1;
}
return n * fact(n - 1);
}
}
k = gN.getInt();
mResults.setText(k+" factorial = "+fact(k));
}
public void init()
{
mInstruct = new TextField(70);
mInstruct.setText("Enter N, then press button for factorial");
gN = new IntField(10);
gN.setLabel("N");
bFact = new Button("Factorial");
mResults = new TextField(70);
add(mInstruct);
add(gN);
add(bFact);
add(mResults);
bFact.addActionListener(this);
}
RecFact.java
43
SNU
IDB Lab.
Recursion (4)

Exponentiation (X ) : Manual Approaches
N

Raw multiplications
XN = X * X * X * ... * X 

Save work; clump things together
SX = X * X
XN = SX * SX * ... * SX 


Refine this latter approach
roughly N/2 times ...
A Recursive Program for exponentiation




N-1 multiplications
Base case:
X0 = 1.0
N is even case: XN = X(N/2) * X(N/2)
N is odd case: XN = X * X(N/2) * X(N/2)
Java version of Exponentiation Computation: Recurse.java
44
SNU
IDB Lab.
public void actionPerformed(ActionEvent event) {
Object cause = event.getSource();
if (cause == bFact) {
n = gN.getInt();
x = gX.getDouble();
mResults.setText(n+" factorial = "+fact(n));
}
if (cause == bExp) {
n = gN.getInt();
x = gX.getDouble();
mResults.setText(x+"to the"+n+"power="+expon(x, n));
}
}
import awb.*;
import java.awt.*;
import java.awt.event.*;
public class Recurse extends java.applet.Applet
implements ActionListener {
TextField gMake, gStyle, gColor, gOwner, mInstruct;
IntField gN;
DoubleField gX;
Label lN, lX;
Button bFact, bExp;
TextField mResults;
int k, n;
double x;
int fact(int n) {
if (n<=1) {
return 1;
}
return n * fact(n-1);
}
public void init() {
lN = new Label("N");
lX = new Label("X");
mInstruct = new TextField(60);
mInstruct.setText("Enter N and X, then press button " +
"for function");
gN = new IntField(10);
gX = new DoubleField(10);
bFact = new Button("Factorial");
bExp = new Button("Exponential");
mResults = new TextField(60);
bFact.addActionListener(this);
bExp.addActionListener(this);
}
add(mInstruct);
add(lN);
add(gN);
add(lX);
add(gX);
add(bFact);
add(bExp);
add(mResults);
double expon(double x, int n) {
double xnot;
}
}
if (n == 0) {
return 1.0;
}
xnot = expon(x, n/2);
if ( n == 2*(n/2)) {
return xnot * xnot;
}
else {
return x * xnot * xnot;
}
Recurse.java
45
SNU
IDB Lab.
Table of contents

Subroutines
How to Deal with the Complexity?
Subroutines with array parameters
Storing and printing for the Database
Recursion

Summary




46
SNU
IDB Lab.
Summary

Two issues in managing complex problems


Representation of the problem
Systematically decomposing the problem

Solution: The notion of top-down design with subroutine

Java lets you solve many kinds of algorithms.


Maybe you are a little bit doubtful about Java……..
Church-Markov-Turing Thesis
Any nontrivial computer language that one can invent is apparently capable of
computing no more and no fewer functions that all the other nontrivial
programming languages.
( The programming language A has the same programming power of any
proven programming language if A has basic features.)
Of course! Java has basic features, So Java is enough for you!
47
SNU
IDB Lab.


Ch4: Top-down Programming, Database
Text Review Time
48
SNU
IDB Lab.
참고자료
Data Base Management System
Overview
DBMS 개관 와 정의
DBMS 역사
DBMS 시장 동향
The current DBMS trend
http://www.oopsla.snu.ac.kr
49
SNU
IDB Lab.
SNU OOPSLA Lab.
DBMS 란?
방대한 양의 데이터를 편리하고
효율적으로 저장, 검색할 수 있
는 환경을 제공해 주는 System
Software
http://www.oopsla.snu.ac.kr
50
SNU
IDB Lab.
SNU OOPSLA Lab.
What is a Database?


A large collection of data
Data + Programs
Database
STORE
http://www.oopsla.snu.ac.kr
51
Data
Data
Data
Data
Data
Data
Data
Data
Data
Data
Data
Data
Data
Data
Data
Data
Data
Data
Data
Data
Data
Data
Data
Data
SNU
IDB Lab.
SNU OOPSLA Lab.
What is a Database? (1)

서울대 40,000명 학생의 학적/수강 정보




1명당 10K record : 45개 과목, 성적, 학기, 재수강, …
10K Byte * 40,000 명 = 400M Byte
Others: 도서관, 보건소, S-card, …
수능시험 관리 정보



2002학년도: 73만 명; 2001학년도:87만 명
1명당 8K record: 인적사항, 문항답, 영역점수/석차, …
8K Byte * 73 만명 = 6G Byte (109)
http://www.oopsla.snu.ac.kr
52
SNU
IDB Lab.
SNU OOPSLA Lab.
What is a Database? (2)

이동전화 통화 정보





3000만 가입자 (2002년)
60 Byte rcord: 통화시간, 통화번호, 기지국, …
3천만명 * 60 Byte * 5calls/day * 365 일 = 3T Byte (1012)
(중국: 136M 가입자 & increasing)
주민등록부 정보



4천 7백만 명
10K Byte record: 본적, 주소, 주민번호, …
10K Byte * 470 M = 5T Byte
http://www.oopsla.snu.ac.kr
53
SNU
IDB Lab.
SNU OOPSLA Lab.
What is a Database? (3)




Google database

15억 Websites, 20억개의 인덱싱 용어관리

Usenet archive = 700 Million messages * 20KB/message = 14 TB
Hubble Space Telescope Data

2000년 3월까지 생성한 data : 7.3 TB 이상

매일 3~5 GB의 데이타를 생성하여 전세계에 전송
Hartwell Bioinformatics Center

Protein Sequencing, Protein Interaction Analysis 등

12 GB 메모리, 1.8 TB 저장공간의 시스템

Human Genome Project: 26,000 ~ 40,000 Genes
한국인 의 유전자 맵

서울대 의대 벤쳐 마크로젠

초기버전: 900G Byte
완성본:
http://www.oopsla.snu.ac.kr
15T Byte
54
SNU
IDB Lab.
SNU OOPSLA Lab.
What do we do with Database ?
(1)

Record Search

주민번호 “840101-1212121” 학생의 수학영역 성적





74만명 * 5개 records = 3.7 M records
12ms to fetch a record and check content
3.7M * 12ms = 44.4Kseconds = over 12 hours
If we use DBMS, it will be less than 0.1sec!
Summarize and Mine for more information



Statistical processing for population census
Search for the correlation between gene and disease
Search for the purchase pattern on customer groups
http://www.oopsla.snu.ac.kr
55
SNU
IDB Lab.
SNU OOPSLA Lab.
What do we do with Database?
(2)

Most (all?) computing applications use some type of a database
CRM
ERP
Data Warehouse
MIS, ERP
OLTP
EDPS
Database
Database
Database
Database
http://www.oopsla.snu.ac.kr
56
SNU
IDB Lab.
SNU OOPSLA Lab.
Database Management System (DBMS)
(1)
창고
http://www.oopsla.snu.ac.kr
57
SNU
IDB Lab.
SNU OOPSLA Lab.
Database Management System (DBMS)
(2)
창고
창고지기
http://www.oopsla.snu.ac.kr
58
SNU
IDB Lab.
SNU OOPSLA Lab.
Database Management System (DBMS)
(3)
데이타베이스
상품
신상
주문 배송 관리
고객
사용자
급여 관리
DBMS
재고
경영자 정보
관리
판매
응용 프로그램
http://www.oopsla.snu.ac.kr
59
SNU
IDB Lab.
SNU OOPSLA Lab.
DBMS Architecture
naive
users
application
programmers
casual
users
database
administrator
application
programs
system
calls
query
database
scheme
data manipulation
language
pre-compiler
application
programs
object
query
processor
database
manager
data definition
language
compiler
DBMS
file
manager
Disk storage
http://www.oopsla.snu.ac.kr
60
SNU
IDB Lab.
SNU OOPSLA Lab.
A Sample Relational Database
http://www.oopsla.snu.ac.kr
61
SNU
IDB Lab.
SNU OOPSLA Lab.
SQL
SQL: widely used commercial query language


E.g. find the name of the customer with customer-id 192-83-7465
select customer.customer-name
from customer
where customer.customer-id = ‘192-83-7465’

E.g. find the balances of all accounts held by the customer with
customer-id 192-83-7465
select account.balance
from depositor, account
where depositor.customer-id = ‘192-83-7465’ and
depositor.account-number = account.account-number
http://www.oopsla.snu.ac.kr
62
SNU
IDB Lab.
SNU OOPSLA Lab.
Major Commercial DBMS in
2004 (1)
Market Leader
안정성
10g
대용량 처리 능력
Famous CEO
http://www.oopsla.snu.ac.kr
63
SNU
IDB Lab.
SNU OOPSLA Lab.
Major Commercial DBMS in
2004 (2)
Window NT/XP과의 통합
PC based (Windows NT)
Microsoft!!!
http://www.oopsla.snu.ac.kr
64
SNU
IDB Lab.
SNU OOPSLA Lab.
Major Commercial DBMS in
2004 (3)
안정성
Mainframe
Informix 매입
IBM
http://www.oopsla.snu.ac.kr
65
SNU
IDB Lab.
SNU OOPSLA Lab.
Database Companies in
the World
http://www.oopsla.snu.ac.kr
66
SNU
IDB Lab.
SNU OOPSLA Lab.
8
Table of Contents
DBMS 개관 과 정의
DBMS 역사
DBMS 시장 동향
The current DBMS trend
http://www.oopsla.snu.ac.kr
67
SNU
IDB Lab.
SNU OOPSLA Lab.
계층형 및 네트워크 DBMS
1970년대 초기 이후
IMS (IBM), System/2000(MRA)
DMS 1100 (Sperry), Total (Cincom)
장점 : Link 를 통한 빠른 데이터 접근
단점 : Physical Database 에 독립적인 응용을 작성할 수 없음
http://www.oopsla.snu.ac.kr
68
SNU
IDB Lab.
SNU OOPSLA Lab.
Network DB Example
Root Record
Customer
records
Lowery
Maple
Queens
Hodges
Shiver
Amount
records
900
North
556
SideHill Brooklyn
Bronx
647
647
801
Query
Bronx에 사는 Mr. Shiver 의 계좌 잔고의 합은?
http://www.oopsla.snu.ac.kr
69
SNU
IDB Lab.
SNU OOPSLA Lab.
Network DB query example
sum:=0
get first customer
where customer.name=“Shiver”
and customer.city =“Bronx”;
while DB_status = 0 do
begin
sum:=sum+customer.amount;
get next customer
where
customer.name = “Shiver”
and customer.city =“Bronx”;
end
print(sum);
http://www.oopsla.snu.ac.kr
70
SNU
IDB Lab.
SNU OOPSLA Lab.
관계형 DBMS (RDBMS)
1970년대 후반에서 80년대 초반
E.F.Codd, 1970 CACM Paper, “The Relational Data Mode
Relational Algebra & Calculus
The Spartan Simplicity!
SQL: Structured Query Language
System/R - 1976, 최초의 상업용 RDBMS
Ingres
- 1976, 최초의 연구용 RDBMS
http://www.oopsla.snu.ac.kr
71
SNU
IDB Lab.
SNU OOPSLA Lab.
관계형 DBMS의 예
name
street
city
amount
Lowerly
Maple
Queens
900
Shiver
North
Bronx
556
Shiver
North
Bronx
647
Hodges
SideHill
Brooklyn
801
Hodges
SideHill
Brooklyn
647
Select sum(amount)
from customer
where customer.name = “Shiver”
and customer.city=“Bronx”;
http://www.oopsla.snu.ac.kr
72
SNU
IDB Lab.
SNU OOPSLA Lab.
80년 초 새로운 DB응용의 출현
CAD/CASE/CAM 분야 대용량 design data
인공 지능 분야 : Expert systems
Multimedia 분야 : IMAGE, TEXT, AUDIO, VIDEO등의 데이터 처
Telecommunication
Rich data model & DBMS function 이 요구
http://www.oopsla.snu.ac.kr
73
SNU
IDB Lab.
SNU OOPSLA Lab.
17
객체지향 (OO) DBMS 의 등장
1985년 ~ 1995년
Research prototype
ORION, POSTGRES, ENCORE/ObServer 등
Commercial Products:
O2, ObjectStore, Objectivity, Versant 등
ODMG-93 OODB standard
http://www.oopsla.snu.ac.kr
74
SNU
IDB Lab.
SNU OOPSLA Lab.
OODBMS의 특징
Object-Oriented Paradigm 지원
객체(object), 객체 식별자(object identity),
포인터
traversal Network DB로의 회귀?
클래스 계층구조, 계승(inheritance)
Semantic Data Model extension
Version & Composite object
Persistent programming language
Long-duration transaction
Large object
http://www.oopsla.snu.ac.kr
75
SNU
IDB Lab.
SNU OOPSLA Lab.
Object-Oriented Database 의 예
name
street
city
amount
Lowerly
Maple
Queens
900
Shiver
North
Bronx
556
Shiver
North
Bronx
647
Hodges
SideHill
Brooklyn
801
Hodges
SideHill
Brooklyn
647
Is-part-of relationship
76
ISA relationship
SNU
IDB Lab.
20
OO DBMS의 OQL query
select sum(customer.deposit.balance)
from Customer customer
where customer.name = “Shiver”
and customer.deposit.branch.city = “Bronx”;
http://www.oopsla.snu.ac.kr
77
SNU
IDB Lab.
SNU OOPSLA Lab.
객체 관계형 (OR) DBMS
1980 – 1985: ORDBMS Research Prototype
PostGres by UC Berkeley
System/R Engineering Extension by IBM
객체기능을 갖춘 관계형 DBMS
Extension within SQL & Tables!
1990년 초반: OODBMS (Illustra, UniSQL, Mattise) 몰락
1997년, Big3 ORDBMS 일제히 등장
http://www.oopsla.snu.ac.kr
78
SNU
IDB Lab.
SNU OOPSLA Lab.
OR Database 의 예
name
street
city
amount
Lowerly
Maple
Queens
900
Shiver
North
Bronx
556
Shiver
North
Bronx
647
Hodges
SideHill
Brooklyn
801
Hodges
SideHill
Brooklyn
647
http://www.oopsla.snu.ac.kr
79
SNU
IDB Lab.
SNU OOPSLA Lab.
ORDBMS의 주요기능
LOB (large object) 지원
Abstract Data Type 지원(객체 지원)
Type Inheritance 지원
User defined type & Stored procedure 지원
Application domain specific extension 지원
SQL 프로시저 확장
룰(rule)/트리거(trigger) 시스템 지원
http://www.oopsla.snu.ac.kr
80
SNU
IDB Lab.
SNU OOPSLA Lab.
ORDBMS의 제품들
ORACLE-8 Universal Server
Informix Universal Server
IBM DB2 Universal Database
Sybase Adaptive Server
Microsoft Access
http://www.oopsla.snu.ac.kr
81
SNU
IDB Lab.
SNU OOPSLA Lab.
27
Table of Contents
DBMS 개관 과 정의
DBMS 역사
DBMS 시장 동향
The current DBMS trend
http://www.oopsla.snu.ac.kr
82
SNU
IDB Lab.
SNU OOPSLA Lab.
DBMS Market Share
83
SNU
IDB Lab.
DBMS Market Share
84
SNU
IDB Lab.
국내 데이타베이스 인지도
조사
출처: 2004 국내 데이타베이스 산업현황 및 전망 보고서
85
SNU
IDB Lab.
국내DBMS시장성장 추이
(단위:억원)
2500
2,207
2000
1,581
1,767
1,722
2001
2002
1500
1,053
1000
679
500
0
1998
1999
2000
2003
출처: 시사컴퓨터 2004. 2월호
86
SNU
IDB Lab.
국내 DBMS 업체별 매출 성장 추이
(단위:억원)
1000
900
800
700
600
500
400
300
200
100
0
1999년
2000
2001
2002
2003
한국MS
한국사이베이스
한국IBM
한국엔씨알
한국오라클
출처: 시사컴퓨터 2004. 2월호
87
한국이포믹스
한국컴퓨터통신
SNU
IDB Lab.
Table of Contents
DBMS 개관 과 정의
DBMS 역사
DBMS 시장 동향
The current DBMS trend
http://www.oopsla.snu.ac.kr
88
SNU
IDB Lab.
SNU OOPSLA Lab.
Current Database Issues
DB R&D Trend
The grand challenges
XML: 비정형 데이터 처리
Knowledge Discovery
Data Warehousing
Data Mining
http://www.oopsla.snu.ac.kr
89
SNU
IDB Lab.
SNU OOPSLA Lab.
DBMS R&D trend
기존 DB 연구 방향을 변화시키는 세가지 조류
Web과 Internet의 발달
프로그램과 데이터의 통합 필요
H/W의 급속한 발달
연구방향
컴포턴트 방식의 DBMS기능 추가
인터넷상의 수백만개의 Dabase의 연결
http://www.oopsla.snu.ac.kr
정형화된 데이터와 비정형화된 데이터의 통합
90
SNU
IDB Lab.
SNU OOPSLA Lab.
The Grand Challenges !!!
Web과 Internet의 급속한 보급
수천만 의 사용자가 Web에 연결
방대한 양의 데이터
인간 유전자 지도: 900 Gbyte
영화 데이터: (600M/1hour) ×100year=…
H/W의 급속한 발전
10년 안에 수백terabyte 의 database & 1 terabyte의
main memory 가능
http://www.oopsla.snu.ac.kr
91
SNU
IDB Lab.
SNU OOPSLA Lab.
Bio Technology Data
인체 설계도를 낱낱이 규명
방대한 데이터
인체: 60-100조 개의 세포
1개의 세포: 2개의 게놈
(46개의 염색체)
1개의 염색체: 수 천개의 유전자
유전자: ACGT
http://www.oopsla.snu.ac.kr
92
SNU
IDB Lab.
SNU OOPSLA Lab.
XML
XML의 필요성
텍스트와 다른 미디어가 인터넷 상을 이동하는데 통일된
framework가 필요
What is XML?
‘eXtensible Markup Language’
Developed by the W3C
A data format for storing structured and semistructured text for dissemination and ultimate
publication, perhaps on a variety of media
Self-describing
http://www.oopsla.snu.ac.kr
93
SNU
IDB Lab.
SNU OOPSLA Lab.
HTML & XML
<tr>
<td>
<font color=“red”> 이름
</font>
</td>
<td> 고소영 </td>
</tr>
<person>
<name>고소영
</name>
HTML: 화면 출력 모
<tr>
양을 지정하기 위한 태
<td>
그
<b> 주소 </b>
</td>
http://www.oopsla.snu.ac.kr
94
<city>서울
XML: 문서의 의미
</city>
를 지정하기 위한
태그
</person>
SNU
IDB Lab.
SNU OOPSLA Lab.
Basic Representation
Bib
<Bib>
1
<paper id=“o2” references=“o3”>
<author>Abiteboul </author>
paper
book
</paper>
reference
<book id=“o3”>
2
3
<author> Hull </author>
author
publisher
<title> Foundations of Data
author
title
Bases </title>
6
5
7
4
<publisher> Addison Wesley
</publisher>
Abiteboul
Hull Foundations Addison
</book>
Of DataBases Wesley
</Bib>
OEM Model
XML data
http://www.oopsla.snu.ac.kr
95
SNU
IDB Lab.
SNU OOPSLA Lab.
Why XML?
■ System , application들 사이의 문서교환 증가
■ text 이외의 정보 - image , video , sound 등 기타 media가 같이 존
재하는 복합문서가 일반화
■ 문서의 독립성 (문서가 system, 언어, 주변기기, 네트워크 등에 종속
적이지 않을 것) 에 대한 요구 증가
■ 문서의 효율적인 저장과 검색이 중요한 issue로 대두
문서의 구조화 촉구
http://www.oopsla.snu.ac.kr
96
SNU
IDB Lab.
SNU OOPSLA Lab.
What are XML for ?
Business to Business
기업간 비즈니스 어플리케이션의 통합
XML
Electronic Data Interchange
XML
시스템 간 데이터 교환
Advanced Information Management System
모든 유형의 데이터 통합 관리
HTML검색
Co-Work
XML검색
지식관리시스템
Advanced Search System
1. 일등감자 포카칩
키워드, 구조, 태그
2. 초코칩이 더 좋아
3. 인텔에서 만든 칩
4. 칩샷을 성공해
상품 카탈로그 검색
인텔에서 제공하는 메모리
칩은 크기가 0.3mm이고 무게
가 0.007g이며, 도매가는
55,000 원이다.
5. 칩이 우승을 차지
검색 : 인텔에서 만드는 메모리 칩의 도매가는 얼마인가?
http://www.oopsla.snu.ac.kr
97
SNU
IDB Lab.
SNU OOPSLA Lab.
Knowledge Discovery
Database Data
Warehouse
useful,
interesting
hidden
information
Knowledge Discovery
Processing: Data mining
응용
의사결정
http://www.oopsla.snu.ac.kr
98
SNU
IDB Lab.
SNU OOPSLA Lab.
Data Warehouse (1)
Data warehouse
시간 데이터 저장
시간에 따른 경향 분석
요약 데이터 요구
다양한 관점에 의한 데이터 관찰
Non-volatile
질의 위주
새로운 데이터 모델의 필요성
: 차원 모델(Dimensional model)
http://www.oopsla.snu.ac.kr
99
SNU
IDB Lab.
SNU OOPSLA Lab.
Data Warehouse (2)
Sales Volumes
Jan
time
Product
Feb
Mar
Wong
Dewitt
Stonebreaker
A
B
C
Sales person
http://www.oopsla.snu.ac.kr
100
SNU
IDB Lab.
SNU OOPSLA Lab.
Data Mining (1)
Data Mining 이란?
넒은 의미
대상이 되는 데이터를 추출하는 단계에서부터 발견된 패턴을
정제, 해석한 후 사람이 이해할 수 있는 언어(텍스트, 그림,
그래픽)로 표현하는 단계까지를 포함
좁은 의미
대용량 데이터에서 흥미 있고 사람이 이해할 수 있는 패턴과
규칙성을 추출하는 여러 가지 알고리즘(data mining algorithm)
또는 소프트웨어의 사용
http://www.oopsla.snu.ac.kr
101
SNU
IDB Lab.
SNU OOPSLA Lab.
Data Mining (2)
패턴발견
빵과 과자를 사는 사람의 80%는 우유를 같이 산다
분유와 기저귀를 사는 사람의 74%는 맥주를 같이 산다
의사결정
맥주 소비는 분유와 기저귀 소비에 영향을 미침
빵과 과자 가격 인상은 우유 소비에 영향을 미침
업무적용
상품 진열대에 (빵, 과자, 우유), (분유, 기저귀, 맥주)를 같이 진열
우유 소비를 조절하기 위해 빵,과자 가격을 조정
http://www.oopsla.snu.ac.kr
102
SNU
IDB Lab.
SNU OOPSLA Lab.