1. Home
  2. Explore
  3. Computer Science
  4. Relational Algebra

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Relational Algebra

  • 95Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Foundations
  • spaceFlip card
  • KI knew it
  • DI didn't know it
  • ←Previous card
  • →Next card

What is relational algebra?

Tap to flipClick to flipspace

A procedural data-manipulation language for the relational model.

Or swipe the card

95 cards

  1. What is relational algebra?

    A procedural data-manipulation language for the relational model.

  2. Why is relational algebra called a procedural language?

    Because the user specifies the operations and steps used to retrieve the desired data.

  3. What does a relational algebra operation take as input and produce as output?

    It takes one or two relations as input and produces a new relation.

  4. What is a relational algebra expression?

    A combination of multiple relational algebra operations.

  5. What are the operands in relational algebra?

    Relations or variables that represent relations.

  6. What do relational algebra operators do?

    They map relations to relations and provide rules for combining operands and evaluating expressions.

  7. What are the four broad categories of relational algebra operations?

    Set operations, unary operations, binary operations, and extended operations.

  8. What is a set in the context of relational algebra?

    A collection of items of the same type, such as tuples or rows.

  9. What is a tuple?

    An immutable, ordered sequence of values; in a database, it corresponds to a row.

  10. What are a relation and an attribute?

    A relation is a group of tuples, equivalent to a table; an attribute is a field or column in that relation.

  11. What is a domain?

    The data type or set of permitted values for a particular attribute.

  12. What does union compatibility mean?

    Two relations have the same degree and corresponding attributes draw values from the same domains.

  13. Which operations are the four standard set operations in relational algebra?

    Union, intersection, set difference, and Cartesian product.

  14. Why are set operations called binary operations?

    Because each operates on two relations.

  15. What is the union of relations RRR and SSS?

    The relation containing all tuples found in RRR or SSS, with duplicates removed.

  16. What conditions must hold for R∪SR \cup SR∪S?

    Relations RRR and SSS must be union compatible.

  17. What is the degree of R∪SR \cup SR∪S?

    It is the same as the degree of RRR and SSS.

  18. What happens to duplicate tuples during union?

    Duplicates are eliminated.

  19. Why can the writers and clients relations be unioned in the example?

    Both relations have four attributes and corresponding attributes use the same domains.

  20. What is the intersection of relations RRR and SSS?

    The relation containing tuples that occur in both RRR and SSS.

  21. What conditions must hold for R∩SR \cap SR∩S?

    Relations RRR and SSS must be union compatible.

  22. What is the degree of R∩SR \cap SR∩S?

    It is the same as the degree of RRR and SSS.

  23. In the writers-and-clients example, what does their intersection contain?

    Only John Cena, because he is present in both relations.

  24. What is the set difference R−SR - SR−S?

    The relation containing tuples that are in RRR but not in SSS.

  25. Why does operand order matter in set difference?

    R−SR - SR−S and S−RS - RS−R generally produce different results.

  26. What conditions must hold for R−SR - SR−S?

    Relations RRR and SSS must be union compatible.

  27. In the writers-minus-clients example, why is John Cena excluded?

    John Cena appears in both writers and clients, so he is removed from the difference.

  28. What is the Cartesian product R×SR \times SR×S?

    A relation containing every possible pairing of a tuple from RRR with a tuple from SSS.

  29. What is the degree of R×SR \times SR×S?

    The sum of the degrees of RRR and SSS.

  30. How many tuples can R×SR \times SR×S contain?

    The product of the number of tuples in RRR and the number of tuples in SSS.

  31. Must relations be union compatible for a Cartesian product?

    No. Cartesian product does not require union compatibility.

  32. What is a common use of the Cartesian product?

    It can serve as a basis for join operations.

  33. What is a unary operation?

    An operation that takes one relation as input and produces one relation as output.

  34. What are the four unary operations presented?

    Select, projection, rename, and assignment.

  35. What does the select operation do?

    It returns the subset of tuples that satisfies a selection condition.

  36. Why is selection called a horizontal filter?

    Because it selects or discards rows while preserving the relation's attributes.

  37. What symbol denotes selection?

    The Greek letter sigma, σ\sigmaσ, followed by a condition and a relation.

  38. What types of conditions can be used in selection?

    Comparison operators, along with logical operators such as AND and OR and pattern matching such as LIKE.

  39. How would selection retrieve movies from 2003 with a rank greater than 7?

    Apply a selection with the combined condition year equals 2003 AND rank greater than 7 to the movies relation.

  40. What does the projection operation do?

    It returns tuples containing only a specified subset of the original attributes.

  41. Why is projection called a vertical filter?

    Because it selects or discards columns while retaining the qualifying tuples.

  42. What symbol denotes projection?

    The Greek letter pi, π\piπ, followed by a list of attributes and a relation.

  43. How can a query retrieve only actors' first names?

    Project the first-name attribute from the actors relation.

  44. How can a query retrieve the first and last names of actors named Michael?

    First select actors whose first name is Michael, then project the first-name and last-name attributes.

  45. What can the rename operation rename?

    A relation, its attributes, or both.

  46. Why is renaming useful?

    It provides new relation or attribute names that can clarify queries or resolve naming conflicts.

  47. What does assignment provide in relational algebra?

    A convenient way to express complex queries as a sequence of named intermediate results.

  48. What must receive the result of an assignment?

    A temporary relation variable.

  49. How is a multi-step query structured using assignment?

    It consists of sequential assignments followed by a final expression whose value is displayed.

  50. In the assignment example, what is stored in the male actors variable?

    The result of selecting actors whose gender is male.

  51. How can assignment help combine actors and movie genres?

    The projected actors relation can be Cartesian-producted with movie genres, assigned to a temporary variable, and then filtered for the action genre.

  52. What is a binary operation?

    An operation that combines two input relations into one output relation.

  53. Which binary operations are presented?

    Theta join, equijoin, natural join, and division.

  54. What is a theta join?

    A join of two relations based on a specified comparison condition.

  55. What is another name for a theta join?

    A conditional join.

  56. What distinguishes an equijoin from a general theta join?

    An equijoin is a theta join that uses only the equality comparison condition.

  57. What is the result of joining PC and laptop relations on equal RAM values?

    Only PC-laptop pairs with identical RAM values are returned.

  58. What conditions are required for a natural join?

    The relations must have at least one attribute with the same name and domain.

  59. How does a natural join match tuples?

    It performs equality matching on attributes common to both relations.

  60. What happens to duplicate common attributes in a natural join?

    The duplicate attribute is eliminated from the result.

  61. What is the purpose of projecting maker and model before naturally joining product and laptop?

    It ensures that the product relation supplies the attributes needed to match the laptop relation naturally.

  62. What does the division operator return?

    Tuples from the first relation that are associated with every tuple in the second relation.

  63. What happens to attributes used in division?

    They are not included in the result.

  64. What was the result of dividing the laptop relation by the relevant PC speeds?

    Laptop models 2001, 2004, 2006, and 2010.

  65. How was the laptop-by-PC-RAM division prepared in the example?

    The PC relation was first selected for RAM equal to 1024, its RAM attribute was projected, and the result was used in division with the laptop relation.

  66. What does generalized projection add to ordinary projection?

    It allows arithmetic expressions involving attributes in the projection list.

  67. What is the general form of generalized projection?

    It projects arithmetic expressions F1,F2,…,FnF_1, F_2, \ldots, F_nF1​,F2​,…,Fn​ over a relational algebra expression EEE.

  68. How can generalized projection calculate a customer's consumed credit?

    Project the customer name and calculate credit limit minus credit balance.

  69. What is an aggregate function?

    A function that takes a collection of values as input and returns one value.

  70. Which aggregate functions are presented?

    SUM, AVERAGE, COUNT, MIN, and MAX.

  71. What does the grouping attribute in an aggregation query determine?

    It determines how tuples are divided into groups before the aggregate function is applied.

  72. Can the grouping attribute be omitted from an aggregation?

    Yes, depending on the type of query being performed.

  73. How can total salary per department be calculated?

    Group employees by department and apply SUM to salary for each group.

  74. What is an outer join?

    A join that retains tuples from one or both relations and pads unmatched portions with null values.

  75. What are the three types of outer join?

    Left outer join, right outer join, and full outer join.

  76. What does a left outer join preserve?

    All tuples from the left relation; unmatched values from the right relation are padded with nulls.

  77. What does a right outer join preserve?

    All tuples from the right relation; unmatched values from the left relation are padded with nulls.

  78. What does a full outer join preserve?

    All tuples from both relations, with nulls used for unmatched values on either side.

  79. In the left outer join example, why does relation A have a null cube value for number 4?

    Number 4 exists in relation A but not in relation B.

  80. In the right outer join example, why does relation B have a null square value for number 5?

    Number 5 exists in relation B but not in relation A.

  81. What happens in a full outer join when a tuple exists in only one relation?

    The tuple is retained, and the attributes from the other relation are set to null.

  82. What did the employee-photographer left outer join demonstrate?

    All seven employees were retained, while photographer fields were null for employees without matching photographer records.

  83. What did the boat-car full outer join demonstrate?

    All tuples from both relations were included, producing six rows with nulls for nonmatching price records.

  84. What is outer union?

    A union-like operation that also handles common attributes that are not necessarily type compatible.

  85. How is outer union related to full outer join?

    Outer union is equivalent to a full outer join on the common attributes.

  86. How does outer union handle attributes that exist in only one relation?

    It includes the attribute and places null or an appropriate default value where the other relation lacks it.

  87. What does it mean to mix and match relational algebra operations?

    Operations can be composed, often using unary operations first, to produce a desired result.

  88. Why could the actors and directors relations not initially be unioned?

    They were not union compatible.

  89. How can actors be made union compatible with directors?

    Project the actors relation onto the attributes shared with directors, such as ID, first name, and last name.

  90. What query task asks for actors whose name starts with “Ch”?

    Use selection with a pattern-matching condition on the actors' name.

  91. What query task asks for actors named Stanley with renamed attributes?

    Select actors whose first name is Stanley, project first name and last name, and rename them to f_name and l_name.

  92. What is the generalized-projection exercise involving laptops?

    Calculate the total cost of each laptop model by adding 200 pesos to its cost.

  93. What is the outer-join exercise involving employees?

    Use an outer join with the department relation to retrieve the list of employees.

  94. What is the final challenge query about movie directors?

    Find the number of movies created by each director whose movie rank is at least 8 and whose movie was shown between 1960 and 2000.

  95. What operations are needed conceptually for the final director challenge?

    Filter movies by rank and year, then group by director and count the movies in each group.

Card 1 of 95
Card 1 of 95

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent