Assignment1 solution

833 views
738 views

Published on

2010-1 Database. assignment #1 (relation algebra)

Taemin Lee.
Dataknow Lab.
Computer Science Education Dept.
Korea University.

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
833
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Assignment1 solution

  1. 1. Database System Conceps : CH2 Exercises and solutions
  2. 2. Relation Algebra <ul><li>Six basic operators </li></ul><ul><ul><li>select:  </li></ul></ul><ul><ul><li>project:  </li></ul></ul><ul><ul><li>union:  </li></ul></ul><ul><ul><li>set difference: – </li></ul></ul><ul><ul><li>cartesian product: x </li></ul></ul><ul><ul><li>rename:  </li></ul></ul><ul><li>Additional Operations </li></ul><ul><ul><li>Natural join: </li></ul></ul><ul><ul><li>Aggregation: </li></ul></ul><ul><ul><li>Outer Join: </li></ul></ul><ul><ul><li>Division:  </li></ul></ul>
  3. 3. Problem 2.1.
  4. 4. Problem 2.1.a. σ (Street = M_street ∧ City = M_city) ( 위 relation) t1 ← employee manages t2 ← ρ manager (manager_name, m_street, m_city) (employee) Person_name Street City Manager_name M_street M_city Person_name Street City Manager_name Manager_name M_street M_city
  5. 5. Problem 2.1.a. t1 ← employee manages t2 ← ρ manager (manager_name, m_street, m_city) (employee) Π (person_name) σ (Street = M_street ∧ City = M_city) (t1 t2) Person_name Street City Manager_name M_street M_city Person_name Street City Manager_name Manager_name M_street M_city
  6. 6. Problem 2.1.a. t1 ← employee manages t2 ← ρ manager (manager_name, m_street, m_city) (employee) Π (person_name) σ (Street = M_street ∧ City = M_city) (t1 t2)
  7. 7. Problem 2.1.b.
  8. 8. Problem 2.1.b. wrong answer! Set different operation 할 때에 attribute 의 수가 동일해야 함 ! person_name company_name salary person_name
  9. 9. Problem 2.1.c.
  10. 10. Problem 2.1.c.
  11. 11. Problem 2.1.c.
  12. 12. Problem 2.3.a.
  13. 13. Problem 2.3.a. wrong answer! Update 할 때에 정보의 누수를 조심 !
  14. 14. Problem 2.3.b.
  15. 15. Problem 2.5.a.
  16. 16. Problem 2.5.b. & 2.5.c
  17. 17. Problem 2.5.d. & 2.5.e
  18. 18. Problem 2.6.
  19. 19. Problem 2.6.a.
  20. 20. Problem 2.6.a.
  21. 21. Problem 2.6.b. & 2.6.c
  22. 22. Problem 2.7.a.
  23. 23. Problem 2.7.b.
  24. 24. Problem 2.7.b.
  25. 25. Problem 2.7.c.
  26. 26. Problem 2.8.a. t1 account_number count(customer_name)
  27. 27. Problem 2.8.b. account customer 1 customer 2 customer 3
  28. 28. Problem 2.8.b. account customer 1 customer 2 customer 3 depositor 1 account 1 customer 1 depositor 2 account 2 customer 2 depositor 3 account 3 customer 3
  29. 29. Problem 2.8.b. account customer 1 customer 2 customer 3 customer 1 customer 2 customer 3 account 1 account 2 account 3 depositor 1 account 1 customer 1 depositor 2 account 2 customer 2 depositor 3 account 3 customer 3
  30. 30. Problem 2.8.b. account customer 1 customer 2 customer 3 customer 1 customer 2 customer 3 account depositor 1 account 1 customer 1 depositor 2 account 2 customer 2 depositor 3 account 3 customer 3
  31. 31. Problem 2.8.b.
  32. 32. Problem 2.9.a. t1 t2 company_name count-distinct(person_name) max(count-tistinct(person_name)
  33. 33. Problem 2.9.b.
  34. 34. Problem 2.9.b.
  35. 35. Problem 2.9.c.
  36. 36. Problem 2.11.a
  37. 37. Problem 2.11.b.
  38. 38. Problem 2.11.c. common mistake! t1 name 이 존재하지 않음 ! empno count_distinct(isbn) empno name office age isbn title authors publisher date
  39. 39. Problem 2.11.c. & 2.11.d
  40. 40. Thanks to listening! :D 질문이 있다면 ? e-mail : [email_address] twitter : http://twitter.com/tm_kor facebook : http://bit.ly/alTaCE always open!

×