In-class Exercise #2 Company Manual Queries
30 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is the purpose of aggregation functions in SQL?

  • To multiply values in a table
  • To perform operations on groups of rows and return one result per group (correct)
  • To divide values in a table
  • To filter out specific rows from a table
  • In the given text, which attribute is used for grouping tuples in the aggregation process?

  • Salary
  • Dno (correct)
  • Bdate
  • Employee Fname
  • What happens if no grouping attribute is specified in an aggregation function?

  • The aggregation function cannot be performed
  • The whole table is treated as one group (correct)
  • Rows with the same value for the grouping attribute are grouped together
  • Each row is considered a separate group
  • Which of the following statements about aggregation functions in SQL is true?

    <p>Aggregation functions can produce one tuple in the result per group</p> Signup and view all the answers

    What is the role of the 'Super_ssn' attribute in the provided text?

    <p>It identifies the supervisor of an employee</p> Signup and view all the answers

    When applying an aggregation function, which attributes survive in the result along with the grouping attributes?

    <p>'Dno' attribute and aggregated attribute only</p> Signup and view all the answers

    What is the purpose of using aliases in SQL queries?

    <p>To give a different name to a relation for convenience</p> Signup and view all the answers

    How can aliases be specified in SQL?

    <p>Using the AS keyword</p> Signup and view all the answers

    What does a missing WHERE-clause in an SQL query indicate?

    <p>It indicates a condition of 'WHERE TRUE'</p> Signup and view all the answers

    In an SQL query, what is the purpose of retrieving first names for all employees?

    <p>To list all employees' first names</p> Signup and view all the answers

    How does adding a WHERE clause change the behavior of an SQL query?

    <p>It filters the rows returned based on a specific condition</p> Signup and view all the answers

    What does using the FROM clause with multiple tables allow in SQL queries?

    <p>It combines data from different tables based on a specified condition</p> Signup and view all the answers

    How would you retrieve the names of department managers when using the assignment operator?

    <p>Rename the Employee table to E_Dept and perform a Cartesian product with the Department table.</p> Signup and view all the answers

    What does the operation 'Result ← ϬSSN = MGRSSN (Employee, Department)' in the exercise refer to?

    <p>An assignment operation assigning a subset of Employee and Department tables based on SSN and MGRSSN equality.</p> Signup and view all the answers

    How can you find all employees (SSN) who do not work on any project manually?

    <p>Use a projection operation to select only those employees whose SSNs are not present in the Project table.</p> Signup and view all the answers

    What would be the correct way to retrieve the SSN of employees who are neither supervisors nor managers?

    <p>Use the set difference operation between all employees and supervisors/managers based on their SSNs.</p> Signup and view all the answers

    In what scenario would you use the Rename operation as described in the text?

    <p>To adjust column names in a table temporarily for specific operations.</p> Signup and view all the answers

    What does the cross product operation involve when used between two tables?

    <p>It creates a new table with all possible combinations of rows from both input tables.</p> Signup and view all the answers

    What is the purpose of the SELECT statement in SQL?

    <p>To retrieve attribute values from a database</p> Signup and view all the answers

    What is the function of the WHERE clause in a SQL query?

    <p>To identify the tuples to be retrieved based on a condition</p> Signup and view all the answers

    How can SQL tables be constrained to be sets?

    <p>By using the DISTINCT option in a query</p> Signup and view all the answers

    What is the purpose of specifying PRIMARY KEY or UNIQUE attributes in SQL tables?

    <p>To prevent duplicate values in the specified attribute(s)</p> Signup and view all the answers

    In SQL, what does the DISTINCT option do in a query?

    <p>Retrieves all attribute values without duplicates</p> Signup and view all the answers

    What does the PREFIX TableName.AttributeName indicate in SQL?

    <p>It resolves naming conflicts for attributes with the same name</p> Signup and view all the answers

    What value does Sally see in the database if she executes her statements after (ins) but before the rollback?

    <p>3.50</p> Signup and view all the answers

    What happens to the effects of a transaction if it executes ROLLBACK instead of COMMIT?

    <p>Its effects can never be seen</p> Signup and view all the answers

    What does SET TRANSACTION ISOLATION LEVEL allow within a transaction?

    <p>Selection of the isolation level for the transaction</p> Signup and view all the answers

    In SERIALIZABLE isolation level, what does Sally see regarding Joe's transaction?

    <p>Database state before or after Joe's transaction, but not within</p> Signup and view all the answers

    What is the purpose of isolation levels in SQL transactions?

    <p>To control which interactions are allowed by concurrent transactions</p> Signup and view all the answers

    How does the DBMS handle isolation levels concerning the visibility of transactions?

    <p>By providing its own implementation options</p> Signup and view all the answers

    More Like This

    Database Queries Flashcards
    49 questions

    Database Queries Flashcards

    PromisingStonehenge avatar
    PromisingStonehenge
    Database Queries and Reports
    24 questions

    Database Queries and Reports

    FeasibleDulcimer8571 avatar
    FeasibleDulcimer8571
    Use Quizgecko on...
    Browser
    Browser