cmu scs carnegie mellon univ. dept. of computer science 15-415/615 - db applications lecture #19...

35
CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

Upload: rayna-cottman

Post on 30-Mar-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Carnegie Mellon Univ.Dept. of Computer Science

15-415/615 - DB Applications

Lecture #19 (not in book)

Database Design Methodology handout

Page 2: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 2

Based on handout:

Adaptable methodology for database design

by N. Roussopoulos and R.T. Yeh, IEEE

Computer Vol. 17, no. 5, pp. 64-80. 1984

Page 3: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 3

Goal

• Given an English description of an enterprise

• build a system to automate it and

• produce the documentation

In diagram form

• tasks

• documents

Page 4: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 4

description

req. anal.

top level I.F.D.

sys. anal.

conc. mod. impl.+test.

task + doc forms.

schema.code.

task emul.

tests

user’s man.

pseudo-code

Page 5: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 5

description

req. anal.

top level I.F.D.

sys. anal.

conc. mod. impl.+test.

task + doc forms.

schema.code.

task emul.

tests

user’s man.

pseudo-code

Phase-I Phase-II

Page 6: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 6

Running example - ‘Mini-U’

• Students register

• Students enroll in courses

• Students ask for transcripts

• Administrator records grades

• Every semester: print class lists

Page 7: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 7

Requirement analysis

Turn English description in to top level information flow diagram, where

• boxes -> documents (~ db tables)

• ovals -> tasks (= db programs)

Important: system boundary

Page 8: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 8

reg. form

reg.

student rec.

input

output

Top level inf. flow diagram

Page 9: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 9

reg. form

reg.

student rec.

System boundary

• internal documents -> db tables

• tasks -> db programs

• tasks: internal only

Page 10: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 10

reg. form

reg.

More on top level diagram

enroll. form

enroll

class rec.student rec.

Page 11: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 11

reg. form

reg.

More on top level diagram

enroll. form

enroll

class rec.student rec.

transc. req.

transcr.

transcr.

Page 12: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 12

Example - Mini-U

• Students register

• Students enroll in courses

• Students ask for transcripts

• Administrator records grades

• every semester: print class rosters

Page 13: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 13

reg. form

reg.

enroll. form

enroll

class rec.student rec.

transc. req.

transcr.

transcr.

grades form

grades

Page 14: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 14

reg. form

reg.

enroll. form

enroll

class rec.student rec.

transc. req.

transcr.

transcr.

class list grades form

gradeslist

Page 15: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 15

description

req. anal.

top level I.F.D.

sys. anal.

conc. mod. impl.+test.

task + doc forms.

schema.code.

task emul.

tests

user’s man.

pseudo-code

Phase-I Phase-II

Page 16: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 16

Document + Task forms

Top level diagram: only half of the info - we also need:

• Document forms and document list

• Task forms and task list

Page 17: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 17

Document list

• D1: registration form

• D2: enrollment for

• …

• D7: student record

• D8: class record } INTERNAL

Page 18: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 18

Document forms

• D1: registration– ssn– name– address

D2: enrollmentssnnameList-of:

course idcourse name

Page 19: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 19

Document forms - cont’d

• D3: transcript request form– ssn– name

D4: transcriptssnnameList-of:

class-idclass namegrade

Page 20: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 20

Document forms - cont’d

(Internal documents - VERY IMPORTANT)

D7: student record– ssn– name– address

Page 21: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 21

Document forms - cont’d

D8: class record– class-id– class-name– syllabus– List-of

• ssn

• grade

Page 22: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 22

Document forms - cont’d

• IMPORTANT POINTS– avoid redundancy in internal documents: ie.,

grades should be stored in ONE place only– there are many, different, correct solutions

Page 23: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 23

Task List

• T1: Registration

• T2: Enrollment

• T3: Transcript

• ...

Page 24: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 24

Task forms

• As in [R+Y]

• not required for this homework

• sub-tasks: probably there won’t be any– otherwise: ~3-7 sub-tasks per task

Page 25: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 25

description

req. anal.

top level I.F.D.

sys. anal.

conc. mod. impl.+test.

task + doc forms.

schema.code.

task emul.

tests

user’s man.

pseudo-code

Phase-I Phase-II

Page 26: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 26

Database schema - E-R

• from the internal documents

• use their forms– ‘List-of’ constructs -> relationships

Eg., for ‘Mini-U’:D7: Student record (ssn, name, address)

D8: Class record (c-id, …, List-of … )

Page 27: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 27

E-R diagram for Mini-U

Student Class

ssn addr. c-id......

takes

N M

grade

Page 28: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 28

Relational schema

student( ssn, name, address)

class( c-id, c-name, syllabus)

takes(c-id, ssn, grade)

Make sure that– Primary keys are underlined;– tables are in BCNF (or 3NF at worst)

Page 29: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 29

SQL DDL statements

create table student (ssn char(9), … );

create table class (c-id char(5), … );

...

Page 30: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 30

description

req. anal.

top level I.F.D.

sys. anal.

conc. mod. impl.+test.

task + doc forms.

schema.code.

task emul.

tests

user’s man.

pseudo-code

Phase-I Phase-II

Page 31: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 31

Task emulation

T1: Registration read ssn, name and address

if ( ssn does not exist in ‘student’){

insert into student values ( :ssn, :name, :address);

} else{print “error: duplicate ssn”}

Page 32: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 32

description

req. anal.

top level I.F.D.

sys. anal.

conc. mod. impl.+test.

task + doc forms.

schema.code.

task emul.

tests

user’s man.

pseudo-code

Phase-I Phase-II

Page 33: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 33

Testing

• For T1 (registration), we check– duplicate ssn– ssn with 9 digits

• For T2 (enrollment) we check– for valid ssn (9 digits)– for registered ssn– for valid c-id– for duplicate (ssn, c-id) entry

Page 34: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 34

User’s manual

Short (~1 page or less) - eg.,:

• copy myproject.tar

• do ‘make’

• follow the menu

<anything else the user should know, like OS, space requirements, etc etc>

Page 35: CMU SCS Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications Lecture #19 (not in book) Database Design Methodology handout

CMU SCS

Faloutsos & Pavlo CMU SCS 15-415/615 35

Important points for Phase-I

• No redundancy in the fields of internal documents

• don’t forget the system boundary

• make sure the top level diagram agrees with the internal document forms

• explain if/when we deviate from BCNF