home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / database / ingres / 2344 < prev    next >
Encoding:
Internet Message Format  |  1993-01-22  |  3.7 KB

  1. Path: sparky!uunet!spool.mu.edu!agate!iat.holonet.net!news.cerf.net!network.ucsd.edu!sdcc12!jeeves!jude
  2. From: jude@jeeves.ucsd.edu (Jude Poole)
  3. Newsgroups: comp.databases.ingres
  4. Subject: possible ingres bug in retrieve unique on views
  5. Keywords: retrieve unique views
  6. Message-ID: <43822@sdcc12.ucsd.edu>
  7. Date: 21 Jan 93 17:43:32 GMT
  8. Sender: news@sdcc12.ucsd.edu
  9. Lines: 100
  10. Nntp-Posting-Host: jeeves.ucsd.edu
  11.  
  12.  
  13. Here is an apparent error in the way ingres is answering retrieve statements
  14. for a large 3 table view we have.  The three tables in the view monster
  15. have the relationship one -> many -> many.  It exists for the convenience of
  16. fairly inexperienced users.  The people's names exist only once in the base 
  17. table named people, but occur multiple times in the view monster because of 
  18. multiple historical job titles and funding.  The theory was that retrieve
  19. unique (or sorting) would eliminate duplicates from query results but it
  20. doesn't seem to work that way when the view is joined to other tables (which it
  21. frequently is to print out long definitions of various codes).  Does anyone
  22. know why ingres behaves as demonstrated in the short script below?
  23. (comments come after each query below) We are running 6.4/01 (su4.u42/01)
  24. on OS/MP 4.1A.1 (same as Sun/OS)
  25.  
  26.   1> range of m is monster
  27.  
  28.  
  29.   1> retrieve (m.lname, m.fname) where m.lname="POOLE"
  30.  
  31. +--------------------+---------------+
  32. |lname               |fname          |
  33. +--------------------+---------------+
  34. |POOLE               |JUDE D         |
  35. |POOLE               |JUDE D         |
  36. +--------------------+---------------+
  37. (2 rows)
  38.  
  39. /* As expected -- I have two entries in the second table */
  40.  
  41.   1> retrieve unique (m.lname, m.fname) where m.lname="POOLE"
  42.  
  43.  
  44. +--------------------+---------------+
  45. |lname               |fname          |
  46. +--------------------+---------------+
  47. |POOLE               |JUDE D         |
  48. +--------------------+---------------+
  49. (1 row)
  50.  
  51. /* again as expected, keyword unique causes "duplicated rows [to be] removed
  52.    from the result table " -- Quel Ref manual, page 2-46
  53. */
  54.  
  55.   1> retrieve (zyx.all)
  56.  
  57. +--------------------+
  58. |only                |
  59. +--------------------+
  60. |jjjjj               |
  61. +--------------------+
  62. (1 row)
  63.  
  64. /* a single row junk table */
  65.  
  66.   1> retrieve unique (m.lname, m.fname, zyx.only) where m.lname="POOLE"
  67.  
  68. +--------------------+---------------+--------------------+
  69. |lname               |fname          |only                |
  70. +--------------------+---------------+--------------------+
  71. |POOLE               |JUDE D         |jjjjj               |
  72. |POOLE               |JUDE D         |jjjjj               |
  73. +--------------------+---------------+--------------------+
  74. (2 rows)
  75.  
  76. /* here's the problem!! -- the retrieved rows are in fact not unique */
  77. /* of course we join monster on a code field to the lookup tables in */
  78. /* real queries, but the principle is the same */
  79.  
  80.   1> range of p is people
  81.  
  82. /* people is a 'real' table, not a view */
  83.  
  84.   1> retrieve (p.lname, p.fname) where p.lname="POOLE"
  85.  
  86. +--------------------+---------------+
  87. |lname               |fname          |
  88. +--------------------+---------------+
  89. |POOLE               |DANIEL S       |
  90. |POOLE               |JUDE D         |
  91. +--------------------+---------------+
  92. (2 rows)
  93.  
  94. /* only one row for me, but there is someone else named POOLE too */
  95.  
  96.   1> retrieve unique (p.lname, zyx.only) where p.lname="POOLE"
  97.  
  98. +--------------------+--------------------+
  99. |lname               |only                |
  100. +--------------------+--------------------+
  101. |POOLE               |jjjjj               |
  102. +--------------------+--------------------+
  103. (1 row)
  104.  
  105. /* with the base table the unique keyword seems to work correctly */
  106.  
  107. Any thoughts would be appreciated.
  108.  
  109. Jude Poole
  110. jpoole@ucsd.edu
  111.  
  112.