It's UWAweek 42 (2nd semester, week 12)

help1402

This forum is provided to promote discussion amongst students enrolled in CITS1402 Relational Database Management Systems.

Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.

How do I ask a good question?
Displaying the 8 articles in this topic
Showing 8 of 612 articles.
Currently 68 other people reading this forum.


 UWA week 36 (2nd semester, mid-semester break) ↓
SVG not supported

Login to reply

👍?
helpful
5:53pm Thu 5th Sep, Kundan J.

"*Question: Find the item_ids that are either 'INK-RESIN' or 'INK-WRSOL' but not both in the po_items table. Hint you need to use UNION and INTERSECT operations.*" If you see the dataset from items table as below, IRN and IWS have one entry each for 'INK-RESIN' and 'INK-WRSOL'. Hence none of these item_ids are having both description or multiple entries in items table. item_id|descr|on_hand|price P9|9KG PAPER|300|25.25 P12|12KG PAPER|700|49.99 P18|18KG PAPER|100|100 IRN|INK-RESIN|3|500 IWS|INK-WRSOL|5|350 CBD|CARDBOARD|47|15 Now po_items table has these item_ids. As per question, we should be getting 'IRN' and 'IWS' both but only 'IWS' is expected in the output. Is my understanding correct about this question?


SVG not supported

Login to reply

👍?
helpful
7:44pm Thu 5th Sep, Mengxi L.

Based on the limited data provided, we would get the output "IWS." For this question, we need to select the item_ids that are either IRN (associated with 'INK-RESIN') or IWS (associated with 'INK-WRSOL'), and then remove(we should use another operation here) any item_id that would appear with both descriptions ('INK-RESIN' and 'INK-WRSOL') by using UNION and INTERSECT.


SVG not supported

Login to reply

👍?
helpful
8:38pm Thu 5th Sep, Quynh D.

I have the same question and you answer is a little bit confusing since based on the given data, each item id (IRN or IWS) appear with only one description for each (shown in the attached image) in the items table. Therefore, my understanding of question based on the given data suggest that the expected output in this case should be both IRN and IWS. Please correct me if there is anything wrong. Thank you!



This article has 1 attachment:

 

SVG not supported

Login to reply

👍?
helpful
8:55pm Thu 5th Sep, Mengxi L.

yeah, I know what you mean. Our expected output based on the given data should be both IRN and IWS. But when we're intersecting the results of two queries,there are no common item_ids between these two, this part of the query is returning nothing,as a result, only IWS is being returned. You can have a try in your terminal. I think this issue with only getting IWS is likely due to the logic of EXCEPT and INTERSECT filtering out more than necessary.


SVG not supported

Login to reply

👍x1
helpful
3:16pm Fri 6th Sep, Tianyu L.

I think it's the problem with the question. Even if the result returned by except is nothing, that is, it is equivalent to performing a union operation on IRN and IWS, it will also return two results. This is very simple logic.


SVG not supported

Login to reply

👍?
helpful
8:06pm Fri 6th Sep, Yufang W.

It seems like sqlite doesn't allow parenthesis for select statement when performing UNION/EXCEPT/INTERSECT operators? Without parenthesis, after UNION we get IRN and IWS, next it will perform EXCEPT and the result will be IWS, lastly it will do INTERSECT so the final results it returns is IWS.


 UWA week 37 (2nd semester, week 7) ↓
SVG not supported

Login to reply

👍?
helpful
2:02pm Wed 11th Sep, Adam W.

Yes it does appear to be an issue with the parenthesis, I tried adding them into the correct solution on the test interface and it does appear to break it, I'll investigate if this is an SQLite issue, or to do with the testing code implemented on the question itself. So for now don't use parenthesis for this one. Adam. "Yufang Wei" <24*1*1*3@s*u*e*t*u*a*e*u*a*> wrote:
> It seems like sqlite doesn't allow parenthesis for select statement when performing UNION/EXCEPT/INTERSECT operators? > > Without parenthesis, after UNION we get IRN and IWS, next it will perform EXCEPT and the result will be IWS, lastly it will do INTERSECT so the final results it returns is IWS.


SVG not supported

Login to reply

👍?
helpful
2:29pm Wed 11th Sep, Adam W.

I altered the question to give an error message referencing the unnecessary parenthesis as the reason for the error. It does appear SQLite doesn't like the use of them in SET statements and will raise an exception. Adam.

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  8:08AM Aug 25 2024
Privacy policy