home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / database / ingres / 2124 < prev    next >
Encoding:
Text File  |  1992-12-21  |  3.7 KB  |  132 lines

  1. Newsgroups: comp.databases.ingres
  2. Path: sparky!uunet!mcsun!sun4nl!rulway.LeidenUniv.nl!slc9!zweije
  3. From: zweije@slc9 (Vincent Zweije)
  4. Subject: Suspicion of bug in ingres sql
  5. Message-ID: <1992Dec18.112742.1460@rulway.LeidenUniv.nl>
  6. Keywords: bug, sql
  7. Sender: root@rulway.LeidenUniv.nl (System PRIVILEGED Account)
  8. Nntp-Posting-Host: rulwislc9.leidenuniv.nl
  9. Organization: Department Of Mathematics and Computer Science
  10. Date: Fri, 18 Dec 92 11:27:42 GMT
  11. Lines: 119
  12.  
  13. I found an SQL query that behaves strangely, I suspect a bug is the
  14. cause of it.
  15.  
  16. The idea of the query is the following: I wish to select all employees
  17. who work on all projects. Employee<->project is a total M:N relation,
  18. modeled by an extra table called works_on. I tried to make a query for
  19. this using the rephrasing "there is no project the employee does not
  20. work on". I traced the strange behaviour down to a difference between
  21. the results of two queries that should return the same results. A
  22. listing is appended below.
  23.  
  24. I'm using ingres version 6.4. The example is actually from the book
  25. "Fundamentals of Database Systems" by Elmasri/Navathe.
  26.  
  27. My question is: did I do something wrong, or is there indeed a bug in
  28. this SQL implementation? Please reply by e-mail, because I usually
  29. don't read this newsgroup.
  30.  
  31. Thanks,                                                       Vincent.
  32.  
  33. ___ Fri Dec 18 11:53:04 1992 _________________________________________
  34.  
  35.   1> select e.ssn,e.fname,e.minit,e.lname
  36.   2> from employee e
  37.  
  38. +-------------+----------+------+----------+
  39. |ssn          |fname     |minit |lname     |
  40. +-------------+----------+------+----------+
  41. |    123456789|John      |B     |Smith     |
  42. |    333445555|Franklin  |T     |Wong      |
  43. |    453453453|Joyce     |A     |English   |
  44. |    666884444|Ramesh    |K     |Narayan   |
  45. |    888665555|James     |E     |Borg      |
  46. |    987654321|Jennifer  |S     |Wallace   |
  47. |    987987987|Ahmad     |V     |Jabbar    |
  48. |    999887777|Alicia    |J     |Zelaya    |
  49. +-------------+----------+------+----------+
  50. (8 rows)
  51.  
  52.  
  53.   2> select w.essn,w.pno
  54.   3> from works_on w
  55.  
  56. +-------------+------+
  57. |essn         |pno   |
  58. +-------------+------+
  59. |    123456789|     1|
  60. |    123456789|     2|
  61. |    333445555|     2|
  62. |    333445555|     3|
  63. |    333445555|    10|
  64. |    333445555|    20|
  65. |    453453453|     1|
  66. |    453453453|     2|
  67. |    666884444|     3|
  68. |    888665555|    20|
  69. |    987654321|    20|
  70. |    987654321|    30|
  71. |    987987987|    10|
  72. |    987987987|    30|
  73. |    999887777|    10|
  74. |    999887777|    30|
  75. +-------------+------+
  76. (16 rows)
  77.  
  78.  
  79.   2> select p.pnumber
  80.   3> from project p
  81.  
  82. +------+
  83. |pnumbe|
  84. +------+
  85. |     1|
  86. |     2|
  87. |     3|
  88. |    10|
  89. |    20|
  90. |    30|
  91. +------+
  92. (6 rows)
  93.  
  94.  
  95.   2> select e.ssn,e.fname,e.minit,e.lname
  96.   3> from employee e
  97.   4> where e.ssn=123456789
  98.   5>   and not exists
  99.   6>     ( select p.pnumber
  100.   7>       from project p
  101.   8>       where p.pnumber not in
  102.   9>           ( select w.pno
  103.  10>             from works_on w
  104.  11>             where w.essn=123456789 ) )
  105.  
  106. +-------------+----------+------+----------+
  107. |ssn          |fname     |minit |lname     |
  108. +-------------+----------+------+----------+
  109. +-------------+----------+------+----------+
  110. (0 rows)
  111.  
  112.  
  113.   2> select e.ssn,e.fname,e.minit,e.lname
  114.   3> from employee e
  115.   4> where e.ssn=123456789
  116.   5>   and not exists
  117.   6>     ( select p.pnumber
  118.   7>       from project p
  119.   8>       where p.pnumber not in
  120.   9>           ( select w.pno
  121.  10>             from works_on w
  122.  11>             where w.essn=e.ssn ) )
  123.  
  124. +-------------+----------+------+----------+
  125. |ssn          |fname     |minit |lname     |
  126. +-------------+----------+------+----------+
  127. |    123456789|John      |B     |Smith     |
  128. +-------------+----------+------+----------+
  129. (1 row)
  130. End of Request
  131. ______________________________________________________________________
  132.