Top Banner
Database Design (3) IS 240 – Database Management Lecture #12 – 2004-03-30 Prof. M. E. Kabay, PhD, CISSP Norwich University [email protected]
17

Database Design (3) IS 240 – Database Management Lecture #12 – 2004-03-30 Prof. M. E. Kabay, PhD, CISSP Norwich University [email protected].

Mar 26, 2015

Download

Documents

Jesse Thornton
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: Database Design (3) IS 240 – Database Management Lecture #12 – 2004-03-30 Prof. M. E. Kabay, PhD, CISSP Norwich University mkabay@norwich.edu.

Database Design (3)

IS 240 – Database ManagementLecture #12 – 2004-03-30

Prof. M. E. Kabay, PhD, CISSP

Norwich University

[email protected]

Page 2: Database Design (3) IS 240 – Database Management Lecture #12 – 2004-03-30 Prof. M. E. Kabay, PhD, CISSP Norwich University mkabay@norwich.edu.

2

Topics

SubtypesTreesNetworksBill of MaterialsSurrogate KeysNull Values

Page 3: Database Design (3) IS 240 – Database Management Lecture #12 – 2004-03-30 Prof. M. E. Kabay, PhD, CISSP Norwich University mkabay@norwich.edu.

3

Subtypes (1)

Consider a currency-trading operationThere’s a counter for walk-in anonymous clients

Need only date, time, currency_in, rate, currency_out, fee; customer_ID is set to 0.

People who use the service often can become regular customers and receive a monthly statement of all transactionsIn addition to info above, need name,

customer_ID, address etc.Corporate customers have a corporate_ID and a

list of authorized usersTheir monthly report includes a total_fees field

that gives the aggregated total for all users

Page 4: Database Design (3) IS 240 – Database Management Lecture #12 – 2004-03-30 Prof. M. E. Kabay, PhD, CISSP Norwich University mkabay@norwich.edu.

4

Subtypes (2)

Show diagrams for the relations above as subtypes of customer

Why not lump all the customers into a single relation?

Page 5: Database Design (3) IS 240 – Database Management Lecture #12 – 2004-03-30 Prof. M. E. Kabay, PhD, CISSP Norwich University mkabay@norwich.edu.

6

Subtypes (3)

Show the tables you could create to represent the situation described above

Page 6: Database Design (3) IS 240 – Database Management Lecture #12 – 2004-03-30 Prof. M. E. Kabay, PhD, CISSP Norwich University mkabay@norwich.edu.

8

Trees

Many systems involve hierarchical 1:N relationsAdministrative hierarchies

Department, directorate, division, unit…Polychotomous classifications of various

kindsKingdom, phylum, class, order, family…

Every element in tree is a nodeTop level of classification: rootParent nodes have child nodes in a branchA child node can have one and only one

parent

Page 7: Database Design (3) IS 240 – Database Management Lecture #12 – 2004-03-30 Prof. M. E. Kabay, PhD, CISSP Norwich University mkabay@norwich.edu.

9

Trees (cont’d)How can you represent the relationships in a

tree? Consider a system for tracking students in college dormitories:

College

Dormitory

Floor

Room

Student

Page 8: Database Design (3) IS 240 – Database Management Lecture #12 – 2004-03-30 Prof. M. E. Kabay, PhD, CISSP Norwich University mkabay@norwich.edu.

10

Networks

In simple networks an entity may have more than one parent

The parent entities have M:N relations to the child entities

Give an example of a network using doctors, nurses and patients in a health-care system

Page 9: Database Design (3) IS 240 – Database Management Lecture #12 – 2004-03-30 Prof. M. E. Kabay, PhD, CISSP Norwich University mkabay@norwich.edu.

11

Network: Doctors, Nurses, Patients

Draw the health-care example you have developed

Page 10: Database Design (3) IS 240 – Database Management Lecture #12 – 2004-03-30 Prof. M. E. Kabay, PhD, CISSP Norwich University mkabay@norwich.edu.

13

Bill of Materials

In manufacturing systems, many components may contain many partsTrying to model these relations caused

headaches in the early years of DBMS design

Why?Solution: treat the relation as recursive

Every element is described in its own tableEvery relationship is described by the

container and the contained elementsStructure thus very simple – now draw it!

Page 11: Database Design (3) IS 240 – Database Management Lecture #12 – 2004-03-30 Prof. M. E. Kabay, PhD, CISSP Norwich University mkabay@norwich.edu.

14

Bill of Materials Design

Page 12: Database Design (3) IS 240 – Database Management Lecture #12 – 2004-03-30 Prof. M. E. Kabay, PhD, CISSP Norwich University mkabay@norwich.edu.

16

Surrogate Keys

To link two relations in a relationship table, we need unique IDs

What if the key we use when designing a relation is not in fact unique?What happens to our tables?

What if the keys we use are very long?What about efficiency?

Page 13: Database Design (3) IS 240 – Database Management Lecture #12 – 2004-03-30 Prof. M. E. Kabay, PhD, CISSP Norwich University mkabay@norwich.edu.

17

Surrogate Keys (cont’d)

DBMS can supply a system-assigned unique identifierTypically a simple numberTakes little roomEasy to use in indexingPrevents duplication of keys

How do we use these unique identifiers in our relationship table?Show an example with doctor/patient

What is the main disadvantage of this surrogate key technique?

Page 14: Database Design (3) IS 240 – Database Management Lecture #12 – 2004-03-30 Prof. M. E. Kabay, PhD, CISSP Norwich University mkabay@norwich.edu.

18

Null Values

What are the possible meanings of a field that has not been filled in by a user (a null or empty field)?

For inappropriate values (e.g., gender-specific attributes), should you always use subtypes?

Can also assign a blank value ab initioChange blank to N/A or UNKNOWN if

necessaryMust handle these values in code (why?)

Page 15: Database Design (3) IS 240 – Database Management Lecture #12 – 2004-03-30 Prof. M. E. Kabay, PhD, CISSP Norwich University mkabay@norwich.edu.

19

HOMEWORKReview Chapter 6 of Kroenke

Prepare for next class by applying SQ3R to chapter 8 of Kroenke.

REQUIRED: By Tuesday 6 April, complete and hand in answers to review questions 6.25 through 6.36 for 24 points.

OPTIONAL: Also by Tuesday 6 April, for an extra 2 points each, complete any or all of Projects 6A, 6B or 6C.

(More homework possibilities for extra credit on next page)

Page 16: Database Design (3) IS 240 – Database Management Lecture #12 – 2004-03-30 Prof. M. E. Kabay, PhD, CISSP Norwich University mkabay@norwich.edu.

20

HOMEWORK (cont’d)

For a 2 extra points each, complete any or all of the FiredUp projects A through D on pp 180-181. To submit B you must first do ATo submit D you must first do C

Page 17: Database Design (3) IS 240 – Database Management Lecture #12 – 2004-03-30 Prof. M. E. Kabay, PhD, CISSP Norwich University mkabay@norwich.edu.

21

DISCUSSION