Question:
Database SQL Statements?
Computer
2014-04-23 18:17:37 UTC
D. Given the relational tables as follows:

SHIP(Shipname, Captain)
CREW(Crewname, Hometown, Shipname)
GROWS(Hometown, Flower)
ALLERGIES(Crewname, Flower)

Please use SQL statement to construct the following queries: (60 points)
(You are not supposed to use any aggregation functions such as count(), sum(), etc.; you are assumed that you do not know the data values of Shipname, Captain, Crewname, Hometown, Flower, etc. in the database table when you query the database table).

a. For each crew, if the crew is allergic to no flowers that grow on his/her hometown, then list the crew’s name.

b. For each crew, if the crew is allergic to all flowers that grow on his/her hometown, then list the crew’s name.

c. For each crew, if the crew is allergic only to the flowers that grow on their hometown, then list the crew’s name.

d. For each crew, if the crew is allergic to exactly the same flowers that his/her captain is allergic to, then list the crew’s name.
Three answers:
TheMadProfessor
2014-04-23 22:54:57 UTC
First off, as already said, nobody will do all your homework for you. Secondly, if and when you try on your own and get stuck, post at least a brief description of the database schema, the queries you tried and the resultset (or errors) you got.
Jeff P
2014-04-23 18:31:51 UTC
Nobody is going to do this for you. How about you attempt this, then post a specific question to a problem you're having.
Serge M
2014-04-23 21:52:51 UTC
Teach yourself at SQL Exercises.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...