relational Flashcards

(36 cards)

1
Q

What is relational algebra?

A

A procedural query language for relational databases

Relational algebra provides a formal foundation for querying and manipulating data in a relational database.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which of the following is NOT a fundamental operation in relational algebra?

A

INSERT

Fundamental operations include SELECT, PROJECT, and JOIN.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does the SELECT operation do in relational algebra?

A

Chooses specific rows

The SELECT operation filters rows based on a specified condition.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the PROJECT operation do?

A

Selects specific columns from a table

The PROJECT operation is used to retrieve specific attributes from a relation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which symbol represents the UNION operation in relational algebra?

A

The UNION operation combines the results of two relations, removing duplicates.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which type of JOIN returns all rows from both relations?

A

FULL OUTER JOIN

A FULL OUTER JOIN includes all records from both tables, matching where possible.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the purpose of the RENAME operation?

A

To change the name of a relation

The RENAME operation allows for the aliasing of relations for clarity in queries.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does the INTERSECT operation do?

A

Returns rows that are in both relations

The INTERSECT operation yields the common rows from two relations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

In relational calculus, what does the term ‘tuple’ refer to?

A

A single row in a relation

A tuple represents a single entry in a table, corresponding to a record.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does the term ‘domain’ refer to in relational calculus?

A

The set of all possible values for an attribute

The domain defines the permissible values that an attribute can take.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which of the following symbols represents the existential quantifier in relational calculus?

A

The existential quantifier indicates that there exists at least one tuple satisfying a condition.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the purpose of the universal quantifier in relational calculus?

A

To specify that a condition holds for all tuples

The universal quantifier is used to express conditions that must be true for every tuple in a relation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

In tuple relational calculus, how is a query expressed?

A

Using logical predicates

Queries in tuple relational calculus are formulated with logical conditions rather than procedural steps.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Which operation can be used to combine two relations with the same attributes?

A

UNION

The UNION operation merges two relations, eliminating duplicates.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the result of a CROSS JOIN?

A

A combination of rows from two relations without conditions

A CROSS JOIN produces a Cartesian product of the two relations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Which of the following statements about relational calculus is true?

A

It is a declarative language.

Relational calculus specifies what to retrieve rather than how to retrieve it.

17
Q

What is the main advantage of relational algebra?

A

It provides a clear procedural approach to queries

Relational algebra gives a structured way to express queries through defined operations.

18
Q

In relational algebra, what does the term ‘set difference’ refer to?

A

The result of removing common rows from two relations

Set difference yields rows that are in one relation but not in another.

19
Q

What type of queries can relational calculus express?

A

Complex queries involving multiple relations

Relational calculus supports intricate queries that may involve several relations and conditions.

20
Q

Which of the following is a valid tuple relational calculus expression?

A

{t | t ∈ Student ∧ t.Age > 20}

This expression selects tuples from the Student relation where the Age attribute is greater than 20.

21
Q

What does the term ‘result set’ refer to in the context of relational algebra?

A

The final output of a query

The result set is what is returned after the execution of a query.

22
Q

Which of the following is NOT a characteristic of relational algebra?

A

It is non-procedural.

Relational algebra is procedural, specifying the steps to retrieve data.

23
Q

What is the main purpose of using the aggregate functions in relational algebra?

A

To perform calculations on a set of values

Aggregate functions like SUM, COUNT, and AVG summarize data.

24
Q

What is the significance of the ORDER BY clause in SQL?

A

To sort the output of a query

The ORDER BY clause organizes the results based on specified columns.

25
Which of the following is an example of an aggregate function?
All of the above ## Footnote COUNT(), SUM(), and AVG() are all aggregate functions used to calculate values from a set.
26
In relational calculus, which of the following is true about the variables used?
They can represent tuples from a relation ## Footnote Variables in relational calculus can be used to denote any tuple from a specified relation.
27
What is the difference between a LEFT JOIN and a RIGHT JOIN?
LEFT JOIN returns all rows from the left table and matched rows from the right ## Footnote A RIGHT JOIN does the opposite, returning all rows from the right table.
28
Which operation is used to count the number of tuples in a relation?
COUNT ## Footnote The COUNT operation returns the total number of rows in a relation.
29
What is a primary key?
A unique identifier for a table ## Footnote A primary key ensures that each record in a table can be uniquely identified.
30
What is the main advantage of using relational algebra?
It provides a clear procedural approach to queries ## Footnote This clarity aids in understanding how data is retrieved and manipulated.
31
What is the purpose of the GROUP BY clause in SQL?
To group rows that have the same values in specified columns ## Footnote The GROUP BY clause is often used with aggregate functions to summarize data.
32
Which of the following is a property of the UNION operation?
It requires the same number of attributes in both relations ## Footnote The UNION operation can only combine relations with the same number and types of attributes.
33
What is the significance of using the DISTINCT keyword in SQL?
It removes duplicate rows from the result set ## Footnote The DISTINCT keyword ensures that each row in the output is unique.
34
In relational algebra, what does the term 'join' refer to?
Combining two relations based on a common attribute ## Footnote Joins are essential for retrieving data from multiple related tables.
35
What is a foreign key?
A primary key that references another table ## Footnote Foreign keys establish relationships between tables by linking records.
36
What does a natural join do?
Combines two relations based on a common attribute ## Footnote A natural join automatically matches columns with the same name in both tables.