Introduction to Database Development (1) IS 240 – Database Management Lecture #3 – 2004-01-22...

Post on 26-Mar-2015

216 views 1 download

Tags:

transcript

Introduction to Database

Development (1)IS 240 – Database Management

Lecture #3 – 2004-01-22Prof. M. E. Kabay, PhD, CISSP

Norwich University

mkabay@norwich.edu

2 Copyright © 2004 M. E. Kabay. All rights reserved.

Topics: Kroenke Chapter 2

DatabaseDBMSCreating a DBApplication ComponentsDB DevelopmentHomework

3 Copyright © 2004 M. E. Kabay. All rights reserved.

Database: Types of Data

User Data: information we care aboutMetadata: information about the data Indexes: information for fast access to dataApplication Metadata: information for

showing and using data

4 Copyright © 2004 M. E. Kabay. All rights reserved.

Types: User Data

Your student information: Student_name Student_ID Student_home_address Student_residence_address Student_residence_address_term Student_grad_year Student_major Student_major_year Course_number Course_term Course_title Course_instructor Course_credits Course_grade . . . .

5 Copyright © 2004 M. E. Kabay. All rights reserved.

Types: User Data

How to group data effectively to represent course information?

1. One big record: Student_id, student_home_address, student_major, course_term, . . . .

2. A record for student-specific info +a record for residence info + a record for course-specific info +linkages (relationships)

Student_name, Student_ID, Student_home_address. . . .

Student_ID, Student_residence_address, Student_residence_address_term

Student_ID, Course_number, Course_term, Course_grade. . . .

Course_number, Course_term, Course_title, Course_instructor, Course_credits

. . . . .

6 Copyright © 2004 M. E. Kabay. All rights reserved.

User Data

Examples from instructor’s own simple databasesTODO – keeps track of things to doIYIR – keeps abstracts of security events

7 Copyright © 2004 M. E. Kabay. All rights reserved.

(User data: TODO)

8 Copyright © 2004 M. E. Kabay. All rights reserved.

(User data: IYIR)

9 Copyright © 2004 M. E. Kabay. All rights reserved.

User Data Relationships

First impressions of data requirements are usually too simple for realistic applications

Think about what can change – may need to create records to keep track of history; e.g., ____?

Think about relationships among data Relationships among data may be

1:1 (one-to-one); e.g., _____?1:n (one-to-many) ; e.g., _____?n:n (many-to-many) ; e.g., _____?

Bad designs lead to duplication, trouble in updatesNormalization (to be studied later) provides

systematic method for sorting out data into records with minimal trouble

10 Copyright © 2004 M. E. Kabay. All rights reserved.

Types

MetadataInformation about the data and their

relationshipsApplication Metadata

Forms, reportsVaries among products

11 Copyright © 2004 M. E. Kabay. All rights reserved.

(Metadata: TODO)

12 Copyright © 2004 M. E. Kabay. All rights reserved.

(Metadata: TODO)

13 Copyright © 2004 M. E. Kabay. All rights reserved.

(Metadata: IYIR)

14 Copyright © 2004 M. E. Kabay. All rights reserved.

(Metadata: IYIR)

15 Copyright © 2004 M. E. Kabay. All rights reserved.

(Metadata: IYIR)

16 Copyright © 2004 M. E. Kabay. All rights reserved.

(Metadata: IYIR)

17 Copyright © 2004 M. E. Kabay. All rights reserved.

(Metadata: IYIR)

18 Copyright © 2004 M. E. Kabay. All rights reserved.

(Forms)

19 Copyright © 2004 M. E. Kabay. All rights reserved.

(Forms)

20 Copyright © 2004 M. E. Kabay. All rights reserved.

(Forms)

21 Copyright © 2004 M. E. Kabay. All rights reserved.

(Reports)

22 Copyright © 2004 M. E. Kabay. All rights reserved.

(Reports)

23 Copyright © 2004 M. E. Kabay. All rights reserved.

(Reports)

24 Copyright © 2004 M. E. Kabay. All rights reserved.

Types: Indexes

Large databases can contain millions of records

Without index, need to search all recordsCan take seconds, minutes or hoursAll depends on speed of I/O:

25 Copyright © 2004 M. E. Kabay. All rights reserved.

DBMS

Design ToolsRun-TimeDBMS Engine

26 Copyright © 2004 M. E. Kabay. All rights reserved.

DBMS: Design Tools

27 Copyright © 2004 M. E. Kabay. All rights reserved.

DBMS: Run-Time

Infrastructure that “runs” the databaseHandles designer/user requests for

database changes, data input/outputHandles all the details of opening,

accessing, modifying informationReads structure metadata to interpret

linkagesReads form metadata to represent

information readablyProduces and prints reports automatically

28 Copyright © 2004 M. E. Kabay. All rights reserved.

DBMS: DBMS Engine

Turns instructions from DBMS run-time components into instructions to operating systemTranslates dataset names into file namesHandles file I/OHandles transactionsManages locking of resources

Communicates with other OS subsystemsInput devices – keyboards, mouseDisplay units – screensSpooler – sends print output to printer

29 Copyright © 2004 M. E. Kabay. All rights reserved.

Creating a DB

SchemaTablesRelationships

30 Copyright © 2004 M. E. Kabay. All rights reserved.

Creating a DB: Schema

Define all aspects of the needed dataSpecify names of

Fields (columns)Records (table rows)

Decide on domains for every fieldPhysical format (length, types)Allowable valuesEmpty(null) allowed?Unique?

Define relations (links) among tables

31 Copyright © 2004 M. E. Kabay. All rights reserved.

Creating a DB: Tables

Turn specifications into real tablesDBMS automatically handles details

32 Copyright © 2004 M. E. Kabay. All rights reserved.

Creating a DB: Relationships

Specify how to link tablesRequires common fieldsSpecify type of relationship

1:11:nm:n

33 Copyright © 2004 M. E. Kabay. All rights reserved.

Application Components

Will study details laterFormsQueriesReportsMenusPrograms

34 Copyright © 2004 M. E. Kabay. All rights reserved.

Forms

Show data in different ways for different functionsLookupData entryData management (modification)

Many different forms can exist in a single DBCan define fields that have different

characteristicsRead-onlySpecific input-values only

Generate specific error messages or confirmations

35 Copyright © 2004 M. E. Kabay. All rights reserved.

QueriesAsk questions about data

Planned – stored queriesAd hoc – defined on the spot

Various methodsSQL – Structured Query Language

Sometimes pronounced “sequel”Often pronounced “S – Q – L”

Visual methods – drag and dropQuery-by-example (QBE) – specify

requirements, then store queryQuery-by-form – designer supplies form,

user inputs specific data

36 Copyright © 2004 M. E. Kabay. All rights reserved.

Reports

Formatted output for printersTypical banded structure

Report headerPage headerDetailPage footerReport footer

Many different report structures can be named and stored for a single DB

37 Copyright © 2004 M. E. Kabay. All rights reserved.

Menus

Windows / Mac visual interface has made drop-down menus familiar

Can create application-specific menusProvide shortcut-keys if desiredMenus can change from stage to stage of

user’s progress through application program

38 Copyright © 2004 M. E. Kabay. All rights reserved.

Programs

DBMS usually include facilities for special controls (programs)Can define actions for anything that can be

specified in syntax of programming language for DBMS

Often highly portable across platforms as long as same DBMS used

Can also write standalone programs that access database files in various languagesNeed application program interface (API)May not be easily portable from platform to

platform

39 Copyright © 2004 M. E. Kabay. All rights reserved.

DB Development

PrototypesTop-down design/developmentBottom-up design/developmentData modeling

40 Copyright © 2004 M. E. Kabay. All rights reserved.

Development: Prototypes

SDLC (System Development Life Cycle)AnalysisSpecificationsDesignCodingTestingDocumentationImplementation

Sometimes takes too longCode is out of date by time it’s

implemented

41 Copyright © 2004 M. E. Kabay. All rights reserved.

Development: Prototypes

Rapid Application Development (RAD)Joint Application Development (JAD)

Show user mockup of applicationHelps to improve communications among

users, analysts, programmers, trainersModern DBMS ideal for prototyping

Easy forms & reports for I/OCan include constraints easily and write

good error messages quicklyWrite one to throw away: learn from mistakes

42 Copyright © 2004 M. E. Kabay. All rights reserved.

Development: Top-down Design/Development

Thorough analysis of requirementsPlan carefully, looking at strategic issues

firstDevelop data models of ever-more detail

AdvantagesReduce wasted effort, rewriting of codeExpandable to new requirements because

of systematic understandingDisadvantages

Slow to reach production codeMay be inflexible in rapidly-changing area

43 Copyright © 2004 M. E. Kabay. All rights reserved.

Development: Bottom-up Design/DevelopmentStart with specific project

Often small-scaleConsistent with RAD/JADBuild up from existing project by adding

others as requiredAdvantages

Can be rapid to meet needsConsistent with Pareto Principle: meet 80% of

needs with first 20% of developmentDisadvantages

Can lead to false starts, reworking, difficult integration of different systems

44 Copyright © 2004 M. E. Kabay. All rights reserved.

Development: Data Modeling

Complex, sophisticated processObserve what people do as well as what they

say about their information needsUsers do not know how to represent data

in data structuresHave to see what they need to construct

modelsBut what they do now may not be the best

for them – limited by current toolsGood communications skills essential

45 Copyright © 2004 M. E. Kabay. All rights reserved.

Homework

Reread Chapter Two of Kroenke using Read-Recite-Review

For Thu the 29th of January 2004Answer questions 2.1 through 2.21 in

writingFor Tue the 27th

Prepare for lab work on by running MS-ACCESS on a lab computer (or your own)

Finish Ferrett et al Projects #1 & #2Look ahead to Ferrett Projects #3 & #4

46 Copyright © 2004 M. E. Kabay. All rights reserved.

DISCUSSION