chapter 6 Flashcards

(18 cards)

1
Q

Q: What is a query?

A

A: A query is a request to retrieve or manipulate data from a database.

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

Q: What is the difference between procedural and non-procedural query languages?

A

Procedural: Specifies how to retrieve data (e.g., Relational Algebra).
Non-Procedural: Specifies what data to retrieve (e.g., Relational Calculus, SQL).

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

Q: What is Relational Algebra?

A

A: A procedural query language that uses operations like Select, Project, Union, and Join to manipulate relations.

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

Q: Name three unary operations in Relational Algebra.

A

Selection (σ): Selects rows based on a condition.
Projection (π): Selects specific columns.
Rename (ρ): Renames a relation or its attributes.

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

Q: Name three binary operations in Relational Algebra.

A

Union (∪): Combines rows from two relations.
Intersection (∩): Finds rows common to both relations.
Set Difference (-): Finds rows in one relation but not in the other.

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

Q: What is Relational Calculus?

A

A: A non-procedural query language that describes what data to retrieve, not how to retrieve it.

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

Q: What are the two types of Relational Calculus?

A

Tuple Relational Calculus (TRC): Filters rows using tuples.
Domain Relational Calculus (DRC): Filters attributes using conditions on domains.

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

Q: What is SQL?

A

A: SQL (Structured Query Language) is a widely used language for managing relational databases, allowing data retrieval, manipulation, and definition.

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

Q: What are the three main categories of SQL commands?

A

DDL (Data Definition Language): Defines database structure (e.g., CREATE, ALTER).
DML (Data Manipulation Language): Manages data (e.g., SELECT, INSERT, DELETE).
DCL (Data Control Language): Manages permissions (e.g., GRANT, REVOKE).

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

Q: What is the purpose of TCL (Transaction Control Language)?

A

A: Manages database transactions with commands like COMMIT, ROLLBACK, and SAVEPOINT.

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

Q: What is a nested query?

A

A: A query inside another query.

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

Q: What is the LIKE operator used for in SQL?

A

A: Pattern matching in strings.
%: Matches multiple characters.
_: Matches a single character.
Example: SELECT * FROM Employee WHERE Name LIKE ‘J%’;

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

Q: What are joins in SQL?

A

A: Operations that combine rows from two or more tables based on a related column.

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

Q: Name the three types of joins in SQL.

A

Inner Join: Returns matching rows from both tables.
Outer Join: Returns all rows, filling unmatched ones with NULL (Left, Right, or Full).
Cross Join: Returns the Cartesian product of two tables.

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

Q: What is an index in a database?

A

A: A pointer that speeds up data retrieval by creating quick access to rows in a table.

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

Q: What is a trigger in SQL?

A

A: A piece of code that automatically executes in response to specific database events (e.g., AFTER INSERT).

17
Q

: What is the difference between Relational Algebra and SQL?

A

Relational Algebra: Theoretical, procedural language.
SQL: Practical, non-procedural language for working with databases.

18
Q

Q: What is query optimization?

A

A: A process to improve query performance by choosing the most efficient way to execute a query.