functions multiplicities
play

Functions Multiplicities Relations can be associated with - PDF document

Functions Multiplicities Relations can be associated with multiplicities. (e.g. in UML diagrams) m..n B A The annotation ` m..n on B means that each A is associated with between m and n members of B Multiplicity annotations m..n


  1. Functions

  2. Multiplicities � Relations can be associated with multiplicities. (e.g. in UML diagrams) m..n B A � The annotation ` m..n’ on B means that each A is associated with between m and n members of B

  3. Multiplicity annotations � m..n means ` between m and n’ � * means ` any number’ � m..* means ` any number greater than or equal to m’ � m means ` exactly m’

  4. A common annotation � The annotation ` 1’ is particularly common. 1 B A � This means each A is associated with exactly one B � This kind of relation is termed a function

  5. Functions more formally

  6. CS153 CS173 CS189 CS183 CS154 Example: favourite Charlotte Emily Abigail Barney Dora

  7. Examples

  8. 0% s d n e p e D 0% o N 0% s e Y be a function? Would Depends Yes No 1. 2. 3.

  9. 0% s d n e p e D 0% o N 0% s e Y be a function? Depends Would Yes No 1. 2. 3.

  10. 0% s d n e p e D 0% o N 0% s e Y be a function? Would Depends Yes No 1. 2. 3.

  11. 0% s d n e p e D 0% o N 0% s e Y be a function? Depends Would Yes No 1. 2. 3.

  12. Partial functions � Partial functions are like functions, except that not all A’s have to relate to a B. � They have a weaker multiplicity requirement. 0..1 B A

  13. Partial functions more formally

  14. Example: on_loan_to Neil War and Peace Olivia Bleak House Madame Bovary Petra Lord of the Rings Quentin Using Z Ulysses Catch-22

  15. Examples

  16. Would be a partial function? Yes 1. No 2. Depends 3. 0% 0% 0% s o s e d N Y n e p e D

  17. Would be a partial function? Yes 1. No 2. Depends 3. 0% 0% 0% s o s e d N Y n e p e D

  18. Would be a partial function? Yes 1. No 2. Depends 3. 0% 0% 0% s o s e d N Y n e p e D

  19. Injective functions � Multiplicity requirements on the domain of the function are also useful. � If each B relates to 0 or 1 A’s then the relation is injective . � Different A’s must relate to different B’s 0..1 B A

  20. Injective functions more formally NO YES

  21. Example: exam numbers Abigail 1455673 1522368 Barney 1556398 Charlotte 1415926 Dora Emily 1529937

  22. Examples � Exam numbers: different students need different numbers � Fingerprints: different people have different fingerprints � Biometrics: different people have different biometrics

  23. Partial injective functions

  24. Example: passport numbers 31258734 Abigail 48219347 Barney 34182730 Charlotte 62399853 Dora 32452263 Emily 32452275

  25. Would be a partial injective function? Yes 1. No 2. Depends 3. 0% 0% 0% s o s e d N Y n e p e D

  26. Exercise

  27. Which symbol best matches the relation diagram? 1. 2. 3. 4. 0..1 1 B A 0% 0% 0% 0%

  28. Using relational notation Functions are (special kinds of) relations, and so the relational notation can be used:

  29. A new library Z spec: state on_loan_to declared as a partial function

  30. Event: Borrowing a book Δ Library means that the Library state changes

  31. Event: Looking up a borrower b? is an input p! is an output Ξ Library means the Library state does not change

  32. Surjective functions (in brief)

  33. Multiplicities � A surjective function from A to B involves every element of B � So every B relates to at least one A. 1..* B A

  34. Bijective functions (in brief)

  35. Examples

  36. Summary

  37. Please ensure you return your handset before leaving. The handset is useless outside of this class and non-returns will decease the likelihood of future voting system use on this course.

Recommend


More recommend