Advertisement
Nickpips

Untitled

Oct 27th, 2015
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. Customers
  2. =========
  3. CID (pk)
  4. fname
  5. lname
  6. ---------
  7.  
  8. Addresses
  9. =========
  10. AID (pk)
  11. CID (fk)
  12. address
  13. ---------
  14.  
  15. Orders
  16. =========
  17. OID (pk)
  18. AID (fk)
  19. SID (fk)
  20. date
  21. s_cost
  22. price
  23. total
  24. ---------
  25.  
  26. S_Options
  27. =========
  28. SID (pk)
  29. name
  30. cost
  31. ---------
  32.  
  33. OrderItems
  34. =========
  35. OIID (pk)
  36. OID (fk)
  37. PID (fk)
  38. ---------
  39.  
  40. Products
  41. =========
  42. PID (pk)
  43. name
  44. price
  45. ---------
  46.  
  47. 1) SELECT CID,fname,lname FROM Customers;
  48.  
  49. 2) SELECT address FROM Addresses WHERE CID=64;
  50.  
  51. 3)
  52. a. SELECT *,fname,lname,address FROM Orders
  53. INNER JOIN Addresses ON Orders.AID=Addresses.AID
  54. INNER JOIN Customers ON Addresses.CID=Customers.CID
  55. WHERE Orders.OID=64;
  56. b. SELECT *,name,OrderItems.price FROM Orders
  57. INNER JOIN OrderItems ON Orders.OID=OrderItems.OID
  58. WHERE Orders.OID=64;
  59. c. SELECT *,name,cost FROM Orders
  60. INNER JOIN S_Options ON Orders.SID=S_Options.SID
  61. WHERE Orders.OID=64;
  62.  
  63. 4)
  64. SELECT * FROM Orders
  65. INNER JOIN Addresses ON Orders.AID=Addresses.AID
  66. INNER JOIN Customers ON Addresses.CID=Customers.CID
  67. WHERE Customers.CID=64;
  68.  
  69. 5) SELECT * FROM OrderItems WHERE OID=64;
  70.  
  71. 6) SELECT * FROM OrderItems;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement