chapter 6 Flashcards
(18 cards)
Q: What is a query?
A: A query is a request to retrieve or manipulate data from a database.
Q: What is the difference between procedural and non-procedural query languages?
Procedural: Specifies how to retrieve data (e.g., Relational Algebra).
Non-Procedural: Specifies what data to retrieve (e.g., Relational Calculus, SQL).
Q: What is Relational Algebra?
A: A procedural query language that uses operations like Select, Project, Union, and Join to manipulate relations.
Q: Name three unary operations in Relational Algebra.
Selection (σ): Selects rows based on a condition.
Projection (π): Selects specific columns.
Rename (ρ): Renames a relation or its attributes.
Q: Name three binary operations in Relational Algebra.
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.
Q: What is Relational Calculus?
A: A non-procedural query language that describes what data to retrieve, not how to retrieve it.
Q: What are the two types of Relational Calculus?
Tuple Relational Calculus (TRC): Filters rows using tuples.
Domain Relational Calculus (DRC): Filters attributes using conditions on domains.
Q: What is SQL?
A: SQL (Structured Query Language) is a widely used language for managing relational databases, allowing data retrieval, manipulation, and definition.
Q: What are the three main categories of SQL commands?
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).
Q: What is the purpose of TCL (Transaction Control Language)?
A: Manages database transactions with commands like COMMIT, ROLLBACK, and SAVEPOINT.
Q: What is a nested query?
A: A query inside another query.
Q: What is the LIKE operator used for in SQL?
A: Pattern matching in strings.
%: Matches multiple characters.
_: Matches a single character.
Example: SELECT * FROM Employee WHERE Name LIKE ‘J%’;
Q: What are joins in SQL?
A: Operations that combine rows from two or more tables based on a related column.
Q: Name the three types of joins in SQL.
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.
Q: What is an index in a database?
A: A pointer that speeds up data retrieval by creating quick access to rows in a table.
Q: What is a trigger in SQL?
A: A piece of code that automatically executes in response to specific database events (e.g., AFTER INSERT).
: What is the difference between Relational Algebra and SQL?
Relational Algebra: Theoretical, procedural language.
SQL: Practical, non-procedural language for working with databases.
Q: What is query optimization?
A: A process to improve query performance by choosing the most efficient way to execute a query.