List and Tuples in OCAML Please help with a question in OCaml Suppose you are im
ID: 3889480 • Letter: L
Question
List and Tuples in OCAML
Please help with a question in OCaml
Suppose you are implementing a relational employee database, where the database is a list of tuples formed by the names, the phone numbers and the salaries of the employees. For example, a sample database may consist of the following list of tuples:
Note that I have written parentheses around the tuples to make them more readable, but the precedences of different operators in OCaml make this unnecessary.
Define a function
that takes as input a list representing the database and the name of an employee and returns his/her corresponding salary. Think also of some graceful way to deal with the situation where the database does not contain an entry for that particular name, explain it, and implement this in your code.
Define a function
that is like find_salary, except that it returns the phone number instead.
Explanation / Answer
Relational Algebra consists of several groups of operations » Unary Relational Operations • SELECT (symbol: (sigma)) • PROJECT (symbol: (pi)) • RENAME (symbol: (rho)) » Relational Algebra Operations From Set Theory • UNION ( ), INTERSECTION ( ), DIFFERENCE (or MINUS, – ) • CARTESIAN PRODUCT ( x ) » Binary Relational Operations • JOIN (several variations of JOIN exist) • DIVISION » Additional Relational Operations • OUTER JOINS, OUTER UNION • AGGREGATE FUNCTIONS (These compute summary of information: for example, SUM, COUNT, AVG, MIN, MAX)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.