Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Database Design (3) IS 240 – Database Management Lecture #12 – 2004-03-30 Prof. M. E. Kabay, PhD, CISSP Norwich University"— Presentation transcript:

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

2 2 Topics Subtypes Trees Networks Bill of Materials Surrogate Keys Null Values

3 3 Subtypes (1) Consider a currency-trading operation Theres 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 transactions In addition to info above, need name, customer_ID, address etc. Corporate customers have a corporate_ID and a list of authorized users Their monthly report includes a total_fees field that gives the aggregated total for all users

4 4 Subtypes (2) Show diagrams for the relations above as subtypes of customer Why not lump all the customers into a single relation?

5 5 Subtypes (2*) Show diagrams for the relations above as subtypes of customer Why not lump all the customers into a single relation? Customers Walk-inRegular IndividualCorporate

6 6 Subtypes (3) Show the tables you could create to represent the situation described above

7 7 Subtypes (3*) Show the tables you would create to represent the situation described above Cust_IDCust_info 0Walk-in 1name1 Individual Customers Cust_IDDate_etc 0… 1… Individual Transactions Corp_IDCorp_info 100corp1 200corp2 Corporate Customers Corp_IDEmpno 100emp1 200emp2 Corporate Employees Corp_IDEmpnoDate_etc 100emp1… 200emp2… Corporate Transactions

8 8 Trees Many systems involve hierarchical 1:N relations Administrative hierarchies Department, directorate, division, unit… Polychotomous classifications of various kinds Kingdom, phylum, class, order, family… Every element in tree is a node Top level of classification: root Parent nodes have child nodes in a branch A child node can have one and only one parent

9 9 Trees (contd) How can you represent the relationships in a tree? Consider a system for tracking students in college dormitories: College Dormitory Floor Room Student

10 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

11 11 Network: Doctors, Nurses, Patients Draw the health-care example you have developed

12 12 Network: Doctors, Nurses, Patients* Draw the health-care example you have developed DoctorNursePatient Doctor-PatientNurse-Patient

13 13 Bill of Materials In manufacturing systems, many components may contain many parts Trying 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 table Every relationship is described by the container and the contained elements Structure thus very simple – now draw it!

14 14 Bill of Materials Design

15 15 Bill of Materials Design* Kroenke p. 173

16 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?

17 17 Surrogate Keys (contd) DBMS can supply a system-assigned unique identifier Typically a simple number Takes little room Easy to use in indexing Prevents 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?

18 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 initio Change blank to N/A or UNKNOWN if necessary Must handle these values in code (why?)

19 19 HOMEWORK Review 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)

20 20 HOMEWORK (contd) 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 A To submit D you must first do C

21 21 DISCUSSION


Download ppt "Database Design (3) IS 240 – Database Management Lecture #12 – 2004-03-30 Prof. M. E. Kabay, PhD, CISSP Norwich University"

Similar presentations


Ads by Google