Database HW2 B91902033 廖予銘 資工四 A

Database HW2 B91902033 廖予銘 資工四 A

Database HW2 B91902033 廖予銘 資工四 a. π person−name (σ company _"name= First Bank Corporation" (works )) b. π person−name, city (employee>< (σ company _"name= First Bank Corporation" (works ))) c. π person−name,, city street (employee>< (σ company _"name= First Bank Corporation" and salary>=10000 (works ))) d. π person−name (employee>< works >< company) e. π person−name (ρ (employee 1,employee >< manages) ><(manager −name =Employee2.name∧employee1.street =employee2.street ∧employee1.city=employee2.city ) (ρ (employee 2,employee))) f. π person−name (works −σ company _"name= First Bank Corporation"(works )) g. π person−name ()works −π person−name (ρ (works 1,works ) ><works1.salary≤works2.salary∧works2.company−name ="Small Bank corporation" ρ(woroks 2,works )) h. π company _ name (company /(π city (σ company _"name= Small Bank Corporation"(company)))) i. ρ(three _works (1→ name 1,2 → company1, 3→ name 2,4 → company2, 5→ name 3,6 → company3), works ×works × works) π person _ name ( σ ((name 1=name 2) ∧ (name 2 =name 3) ∧ (company 1≠company2)∧ (company 2≠company3)∧ (company 3≠company1)) (three _works )) [QUERY a] SELECT T.[Planet's Name] FROM TimeTable T WHERE T.MOVIE=3 AND T.[Character's Name]="Princess Leia" [Results of QUERY a] a Planet's Name Endor Tatooine [QUERY b] SELECT COUNT(T.[Character's Name]) FROM TimeTable AS T WHERE T.MOVIE=3 AND T.[Planet's Name]="Dagobah" [Results of QUERY b] b Expr1000 3 [QUERY c] SELECT C.[Name] FROM TimeTable AS T, Characters C WHERE T.[Character's Name]=C.[Name] AND T.[Movie]=2 AND C.[Homeworld]=T.[Planet's Name] [Results of QUERY c] c Name [QUERY d] SELECT T.[Character's Name] FROM TimeTable T,Planets P WHERE T.[Planet's Name]=P.[Name] AND P.[Affiliation]="rebels" [Results of QUERY d] d Character's Name C-3 PO d Character's Name Chewbacca Darth Vader Han Solo Luke Skywalker Princess Leia R2-D2 [QUERY e] SELECT T.[Planet's Name] FROM TimeTable T,Characters C WHERE T.[Character's Name]=C.[Name] AND C.[Race]="droid" [Results of QUERY e] e Planet's Name Bespin Hoth Tatooine Tatooine Bespin Dagobah Dagobah Endor Hoth [QUERY f] SELECT C.Name, P.Name, SUM( T.[Time of Departure] - T.[Time of Arrival] + 1 ) AS amount FROM Characters AS C, TimeTable AS T, Planets AS P WHERE T.[Character's Name]=C.Name AND T.[Planet's Name]=P.Name AND P.[Affiliation]="neutral" GROUP BY C.name,P.name [Results of QUERY f] f C.Name P.Name amount C-3 PO Bespin 5 C-3 PO Tatooine 6 Chewbacca Bespin 5 Chewbacca Endor 6 Chewbacca Tatooine 6 Darth Vader Bespin 6 Han Solo Bespin 5 Han Solo Endor 6 Han Solo Tatooine 6 Jabba the Hutt Tatooine 25 Lando Calrissian Bespin 10 Lando Calrissian Endor 2 Lando Calrissian Tatooine 3 Luke Skywalker Bespin 3 Luke Skywalker Dagobah 7 Luke Skywalker Endor 4 Luke Skywalker Tatooine 5 Obi-Wan Kanobi Tatooine 3 Owen Lars Tatooine 2 Princess Leia Bespin 5 Princess Leia Endor 6 Princess Leia Tatooine 3 R2-D2 Bespin 3 R2-D2 Dagobah 7 R2-D2 Endor 4 Rancor Tatooine 26 Yoda Dagobah 28 [QUERY g] SELECT T.[Movie],C.Name FROM Characters AS C, TimeTable AS T, Planets AS P WHERE ( ( C.Race="Human" AND C.Name=T.[Character's Name] AND P.type="desert" ) OR ( C.Race="Droid" AND P.type="swamp" ) ) AND C.Name=T.[Character's Name] AND P.Name=T.[Planet's Name] ORDER BY T.Movie, C.Name [Results of QUERY g] SimpleQuery Movie Name 1 Han Solo 1 Luke Skywalker 1 Obi-Wan Kanobi 1 Owen Lars 2 R2-D2 3 Han Solo 3 Lando Calrissian 3 Luke Skywalker 3 Princess Leia 3 R2-D2 [QUERY h] SELECT DISTINCT T1.Movie, T1.[Character's Name] FROM TimeTable AS T1 WHERE NOT EXISTS ( SELECT * FROM TimeTable AS T2 WHERE T1.Movie=T2.Movie AND ( SELECT COUNT( T3.[Planet's name] ) From TimeTable AS T3 WHERE T1.[Character's Name] = T3.[Character's Name] AND T3.Movie = T1.Movie ) < ( SELECT COUNT( T4.[Planet's name] ) From TimeTable AS T4 WHERE T2.[Character's Name] = T4.[Character's Name] AND T4.Movie = T2.Movie ) ) [Results of QUERY h] h Movie Character's Name 1 Luke Skywalker 2 Luke Skywalker 2 R2-D2 3 Luke Skywalker [QUERY i] SELECT DISTINCT T1.Movie, T1.[Planet's Name] FROM TimeTable AS T1 WHERE NOT EXISTS ( SELECT * FROM TimeTable AS T2 WHERE T1.Movie=T2.Movie AND ( SELECT COUNT( T3.[Character's name] ) From TimeTable AS T3 WHERE T1.[Planet's Name] = T3.[Planet's Name] AND T3.Movie = T1.Movie ) < ( SELECT COUNT( T4.[Character's name] ) From TimeTable AS T4 WHERE T2.[Planet's Name] = T4.[Planet's Name] AND T4.Movie = T2.Movie ) ) [Results of QUERY i] i Movie Planet's Name 1 Tatooine 2 Bespin 3 Tatooine [QUERY j] SELECT Tmp1.[Movie],Tmp1.[Race],Tmp1.[Name] FROM ( SELECT C.[Name], C.[Race],T1.[Movie], SUM( T1.[Time of Departure] - T1.[Time of Arrival] + 1 ) AS amount FROM Characters AS C, TimeTable AS T1 WHERE C.Name = T1.[Character's Name] GROUP BY C.Name, C.[Race], T1.[Movie] ) AS Tmp1 WHERE NOT EXISTS ( SELECT * FROM ( SELECT C.[Name], C.[Race],T1.[Movie], SUM( T1.[Time of Departure] - T1.[Time of Arrival] + 1 ) AS amount FROM Characters AS C, TimeTable AS T1 WHERE C.Name = T1.[Character's Name] GROUP BY C.Name, C.[Race], T1.[Movie] ) AS Tmp2 WHERE Tmp1.[Movie]=Tmp2.[Movie] AND Tmp1.[Race]=Tmp2.[Race] AND Tmp1.[Amount] < Tmp2.[Amount] ) ORDER BY Tmp1.[Movie],Tmp1.[Race] [Results of QUERY j] j Movie Race Name 1 Droid C-3 PO 1 Human Darth Vader 1 Hutt Jabba the Hutt 1 Rancor Rancor 1 Unknown Yoda 1 Wookie Chewbacca 2 Droid R2-D2 2 Human Luke Skywalker 2 Hutt Jabba the Hutt j Movie Race Name 2 Rancor Rancor 2 Unknown Yoda 2 Wookie Chewbacca 3 Droid R2-D2 3 Human Luke Skywalker 3 Hutt Jabba the Hutt 3 Rancor Rancor 3 Unknown Yoda 3 Wookie Chewbacca [QUERY k] ( SELECT P1.[Name] FROM Planets AS P1 WHERE P1.[Name] NOT IN ( SELECT T1.[Planet's Name] FROM TimeTable AS T1 WHERE T1.[Movie]=1 ) ) UNION ( SELECT P2.[Name] FROM Planets AS P2 WHERE P2.[Name] NOT IN ( SELECT T2.[Planet's Name] FROM TimeTable AS T2 WHERE T2.[Movie]=2 ) ) [Results of QUERY k] k Name Alderaan Bespin Corellia Death Star Endor Hoth Kashyyyk Star Destroyer .

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    9 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us