home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / database / 8045 < prev    next >
Encoding:
Internet Message Format  |  1992-11-23  |  7.1 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!natinst.com!hrd769.brooks.af.mil!hrd769.brooks.af.mil!not-for-mail
  2. From: burgess@hrd769.brooks.af.mil (Dave Burgess)
  3. Newsgroups: comp.databases
  4. Subject: Re: Normalizing 2NF -> 3NF
  5. Date: 23 Nov 1992 11:21:39 -0600
  6. Organization: Armstrong Lab MIS, Brooks AFB TX
  7. Lines: 128
  8. Distribution: world
  9. Message-ID: <1er3v3INNqfc@hrd769.brooks.af.mil>
  10. References: <69674@cup.portal.com> <1ejt9qINN340@hrd769.brooks.af.mil> <70064@cup.portal.com>
  11. NNTP-Posting-Host: hrd769.brooks.af.mil
  12.  
  13. In article <70064@cup.portal.com> DVaz@cup.portal.com (David D Vazquez) writes:
  14. >Dave Burges writes:
  15. >>
  16. >>  Where is the redundancy?  In the foreign key element?  That is where your
  17. >>cardinality will help determine the actual implementation, but we are talking
  18. >>Form Normalization, not implementation.  In normalization, the concepts of 
  19. >>query speed and disk space have no place.  Save them for the physical
  20. >>implementation phase.
  21. >>
  22. >
  23. >I agree, but physically implemented tables generally tend to look alot like 
  24. >their abstractly designed  relatives.   You can also save alot of time and
  25. >headaches if you implement your tables just like they've been designed.  Just
  26. >think, you've spent 7 hours designing a database only to have your programmer/
  27. >implementor spend another 7 hours trying to figure out the better implementa-
  28. >tion (and for something silly like R1(A*,B)/R2(A*,C) vs. R1(A*,B)/R2(B*,C).
  29. >The database implementor shouldn't have to make these kinds of decisions!  
  30.  
  31.   I agree 100%.  That is why they should implement according to the design,
  32. not try to second guess what was intended.  I have a 'REAL LIFE' example of this
  33. that I am not willing to share on the net, but E-Mail me and I will be glad to
  34. discuss it.  It shows what happens when the implementation team codes up what
  35. they understood the situation to be, rather then implementing what the designer
  36. had documented.  The nightmare continues.
  37.  
  38. >Supertype/subtype and recursive relationship implementation should be the extent
  39. >of implementation issues.
  40. >
  41.  
  42.   That is what makes the Database methodology so inviting.  It allows us the
  43. ability to document these types of relationships in (relatively) easy to do
  44. pieces that illuminate (versus obfuscate) the issue.
  45.  
  46.   Before I continue, I need to make sure everyone understands what I meant by
  47. 'Dorm'.  In the military, every building at a training site has a 'name', 
  48. whether it is a squadron name DORM or a historical figure HALL or a simple
  49. building number.  In addition, each building on the 'campus' has a street 
  50. address.  If the term 'dorm' was taken as a room number, then we are debating 
  51. different issues.  For example, the student lives in 'Kilday Hall', but the
  52. street address is '123 34th Street West'.  No one uses the address, except to
  53. get mail into the mail room.  All other correspondence refers to the 'dorm 
  54. name'. 
  55.   If the term 'dorm' were to be taken as a 'room number' then the
  56. relation R1(A*,B,C) could only be further normalized through the use of a
  57. compound key relationship where B and C are used in R2(C+B*) since this is the
  58. only way to develop a candidate key from the R2 relation.  If this were the 
  59. case and no other data about (dorm+room) were kept, we would still need to
  60. have it separated out to avoid an anomoly where the rooms disappear when no 
  61. one lives in them unless we implement a kludge like 'VACANT' moves in whenever
  62. the rooms are emptied.
  63.  
  64. >'Redundancy?', you ask.  Given R(Student, Dorm, Dorm Address); if you implement
  65. >as R1(Student, Dorm) and R2(Student, Dorm Address), you are repeating values
  66. >of Dorm Address for each student as well as not enforcing Dorm -> Dorm Address
  67. >(or vice versa); you'd have to do some extra coding..  Also, you'd need two
  68. >copies of Student's names (one to find the dorm and one to find the dorm's 
  69. >address); this is a waste.
  70.  
  71.   The dorm address is not dependent on the student; it is dependent on the 
  72. dormitory.  In fact, if the students all move out of the dormitory in your
  73. example, it ceases to exist.  I don't think THAT was your intent (although 
  74. it would make urban renewal a lot easier, and I have known students where, when
  75. they moved out, it was as much work as building a new dorm to fix it back 
  76. up :-))  Therefore, the relationship in the example could never be 
  77. R1(A*,B)  R2(A*,C).  The dorm address is transitively dependent on the 
  78. student, but functionally dependent on the dormitory.  Therefore, the only 
  79. possible 3NF relations from the relationship are:
  80.  
  81.    R1(A*,B)/R2(B*,C)
  82.   or
  83.    R1(A*,C)/R2(C*,B)
  84.  
  85.   Since either the Dorm address or the dormitory name could be a candidate
  86. key to their relation, the selected foreign key into R2 is moot.
  87.  
  88.   Another way to look at it to further understanding might be to recognize the
  89. one-to-many relationships at work.
  90.  
  91.   Student (1)       to (1) Dormitory
  92.   Student (1)       to (1) Dorm address
  93.   Dormitory (1)     to (1) Dorm Address 
  94.   Dormitory (1)     to (m) Student
  95.   Dorm Address (1)  to (1)  Dormitory
  96.   Dorm Address (1)  to (m)  Student
  97.  
  98.   I don't want to draw pictures, but the 1-M relationship between (Dorm Name
  99. Student) implies that the relation should be split to AVOID redundant data
  100. being entered in the 2NF relation.  In other words, the dorm information would
  101. be entered once (address/dorm name) and all of the students would reference
  102. that combination through a foreign key (address or name).
  103.  
  104. >
  105. >The problem I see is that you never have one correct answer when it comes to
  106. >getting a database into 3NF.  Should there be one, maybe?
  107. >
  108. >  -Dave. "dvaz@cup.portal.com and dvazquez@sdiserv.cs.uno.edu"
  109.  
  110.   I have seen dozens of database designs for the sample problem in the class 
  111. I teach.  None were ever the same.  On the other hand, there are certain 
  112. features which every class has implemented the same way:
  113.  
  114.   -  All the successful designs relied on the analysis of the anomolies that
  115. their design would and wouldn't address.
  116.   -  The successful ones were reality based, in that the relationships between
  117. the relations correlated very closely to the discovered real life situations.
  118.   -  The unsuccessful ones were over-simplified in order to make postpone
  119. decision making to the implementation phase.
  120.   -  The confusing ones may or may not have worked.  They were unmappable
  121. to a physical implementation method, or relied on a single database product
  122. (e.g. Oracle) to limit their design.  This made implementing them using a 
  123. different database model (Flat File access model/Network Model/
  124. Hierarchical Model).  
  125.   -  None have every successfully overdesigned.  The ones where a lot of work
  126. was done on in the design stages were very easy to implement.  They were not
  127. always optimally executable, but the were easy to implement.  The optimization
  128. of the database is a separate issue, and relies on the access patterns, rather
  129. than any relationships of the data.
  130.  
  131.  
  132.   I understand that I have painted many of these statements with a pretty wide
  133. brush, but please understand that I get a little religious about implementation
  134. being where the work is done.  I have been bowled down too many times by 
  135. poorly designed but very excellently implemented database systems.  
  136.  
  137. TSgt Dave Burgess
  138. NCOIC AL/MIS
  139. Brooks AFB, TX
  140.  
  141.