Podcast
Questions and Answers
What is the correct relationship between database schema and instance?
What is the correct relationship between database schema and instance?
Which attribute is most suitable to be a primary key for student data?
Which attribute is most suitable to be a primary key for student data?
Which statement correctly describes the role of a foreign key?
Which statement correctly describes the role of a foreign key?
What type of SQL statement is CREATE TABLE
?
What type of SQL statement is CREATE TABLE
?
Signup and view all the answers
Which of the following queries can be used to replace a join operation accurately?
Which of the following queries can be used to replace a join operation accurately?
Signup and view all the answers
What would the output be for the SQL query SELECT * FROM employee WHERE salary>10000 AND dept_id=101
?
What would the output be for the SQL query SELECT * FROM employee WHERE salary>10000 AND dept_id=101
?
Signup and view all the answers
Which SQL statement contains a syntax error?
Which SQL statement contains a syntax error?
Signup and view all the answers
In the SQL statement LIKE '_____ Computer Engineering'
, what character fits in the blank?
In the SQL statement LIKE '_____ Computer Engineering'
, what character fits in the blank?
Signup and view all the answers
What result does the query display after execution: (SELECT emp_id FROM employee WHERE dept = 'Toys') EXCEPT (SELECT emp_id FROM employee WHERE dept = 'Cars')?
What result does the query display after execution: (SELECT emp_id FROM employee WHERE dept = 'Toys') EXCEPT (SELECT emp_id FROM employee WHERE dept = 'Cars')?
Signup and view all the answers
What placeholder is used in an aggregate expression to eliminate duplicates in the query SELECT COUNT (____ ID)?
What placeholder is used in an aggregate expression to eliminate duplicates in the query SELECT COUNT (____ ID)?
Signup and view all the answers
What should be used to represent missing phone numbers in a relation?
What should be used to represent missing phone numbers in a relation?
Signup and view all the answers
Which statement correctly describes the requirement for a primary key attribute?
Which statement correctly describes the requirement for a primary key attribute?
Signup and view all the answers
What type of join allows for inclusion of rows that do not have matching values?
What type of join allows for inclusion of rows that do not have matching values?
Signup and view all the answers
Which command is used to delete all entries in a relation but retain its structure?
Which command is used to delete all entries in a relation but retain its structure?
Signup and view all the answers
Which statement correctly describes how to insert a tuple from another relation?
Which statement correctly describes how to insert a tuple from another relation?
Signup and view all the answers
What syntax is correct for declaring a view named 'v'?
What syntax is correct for declaring a view named 'v'?
Signup and view all the answers
Study Notes
Multiple Choice Questions
- Q1: Database instance is a snapshot of current data, while schema designs the logical structure.
- Q2: Student ID is most likely the primary key for a student data table.
- Q3: An attribute can be a foreign key if it references a primary key in another relation.
-
Q4:
CREATE TABLE student (name VARCHAR, id INTEGER)
is a Data Definition Language (DDL) statement. -
Q5:
SELECT name, course_id FROM instructor, teaches WHERE instructor_ID = teaches_ID;
can be replaced bySELECT name, course_id FROM instructor NATURAL INNER JOIN teaches;
-
Q6: All columns (id, name, salary, dept_id) are displayed if
SELECT * FROM employee WHERE salary>10000 AND dept_id=101;
is executed. -
Q7:
Select id where id = 119 and name = 'Jane';
is the only statement with possible error. -
Q8:
%Computer Engineering
should be inserted into the blank to select the department with "Computer Engineering" as the ending string. -
Q9:
SELECT name FROM instructor WHERE salary BETWEEN 90000 AND 100000;
can replace the query to select instructor's names from a salary range. - Q10: Union operation automatically eliminates duplicated tuples and adds other tuples.
-
Q11: The query
(SELECT emp_id FROM employee WHERE dept = 'Toys') EXCEPT (SELECT emp_id FROM employee WHERE dept = 'Cars')
retrieves employee IDs from the Toys department that are not present in the Cars department. - Q12: Missing phone numbers in a relation are represented as NULL values.
- Q13: A primary key is both unique and not null.
-
Q14: To eliminate duplicates when counting, use the
DISTINCT
keyword. -
Q15: The SQL expression for "greater than at least one" is
> some
. -
Q16:
DELETE FROM instructor;
deletes all rows from the instructor table, preserving the table structure. -
Q17: SQL
INSERT
statements can copy data from other tables. - Q18: Outer joins include rows even if there's no match in the other table.
-
Q19: Use
CREATE VIEW v AS "query expression";
; to create viewv
. -
Q20: Integrity constraints like
CHECK(budget >= 0)
ensure non-negative budget values. -
Q21:
CREATE TABLE course...FOREIGN KEY (dept_name) REFERENCES department...
is a relational database design, defining a foreign key constraint that ensures data consistency between thecourse
anddepartment
tables. -
Q22: The
DROP TABLE
command is used to remove a table from a database. - Q23: To enforce a column to hold a value, Not null constraint should be applied.
-
Q24:
CREATE VIEW v AS "query expression";
defines a view in SQL. -
Q25:
ON DELETE CASCADE
specifies that deletion of a tuple in the parent table automatically deletes the related tuples in the child table. - Q26: Set difference ( - ) is the correct operator that gives the distinct.
-
Q27:
π C, D (S) ∩ π A, B (R)
returns the intersection of theC
andD
columns fromS
, and theA
andB
columns fromR
. -
Q28:
π B (S) - π B (R)
finds the values in column B of table S that are not also in column B of table R. -
Q29: SQL's
SELECT
clause corresponds to the relational algebra operationσ
. (selection) -
Q30: SQL query
SELECT a,b FROM r NATURAL INNER JOIN s WHERE r.A=2
matches relational algebra expressionσr.A=2(rxs)
. -
Q31:
Πbranch_name (σ branch_city = "London"(branch))
is used to retrieve branch names located in London. -
Q32:
Π customer_name (σ amount > 500(loan x customer))
is used to retrieve names of customers who have a loan amount larger than 500. -
Q33:
P (σcustomer_city="Paris"(customer))
finds customers residing in Paris, and returns the street and count along with customer name. -
Q34:
Π customer_name( σ depositor.customer_name = borrower.customer_name(R))
retrieves customer names having both a loan and an account. -
Q35:
Πbranch_name σ max (balance)(account))
is the query used to identify the branch name where the largest balance value is located. -
Q36: To increment loan amounts by 20%
Π loan_number, branch_name, amount* 1.2(loan)
is used. -
Q37:
R - σ branch_name = "Palm Springs”(S)
is used to delete accounts from a branch named Palm Springs. - Q38: The question is about composite primary keys. Customers can have multiple accounts, an account can be shared among multiple customers, and accounts can be present in several branch locations.
- Q39: Foreign key definitions involve referencing another table's primary key to maintain data integrity.
-
Q40:
SELECT staff_no, salary FROM Staff WHERE salary BETWEEN 100 AND 200 ORDER BY salary DESC
retrieves staff numbers and salaries within the 100-200 range in descending order. (inclusive). -
Q41:
SELECT count(distinct car_no) FROM rented WHERE rentDate BETWEEN '1-Jan-2021' AND '31-Jan-2021'
counts distinct cars rented in Jan 2021. -
Q42:
SELECT compNo, count(staff_no), SUM(salary) FROM Staff GROUP BY compNo HAVING count(staff_no) > 15;
finds companies with more than 15 staff and their total salary. -
Q43:
SELECT custNo, fName, IName FROM customer LEFT OUTER JOIN rented ON customer.custNo = rented.custNo
finds all customers with associated rental information or displays customers without any rentals. -
Q44:
SELECT playername FROM player WHERE playerid NOT IN (SELECT playerid FROM player_record)
is used to find all players who haven't played in any match. -
Q45:
SELECT refname, ref_age FROM referee WHERE league = 'Premier League' ORDER BY ref_age
finds the youngest referees in the Premier League. -
Q46:
UPDATE stock SET quantity = quantity - 100 WHERE code = 'A1'
decrements the quantity of items with code 'A1' by 100 units in the stock table. -
Q47:
DELETE FROM stock WHERE code = 'A1'
removes all rows with code 'A1' from the stock table.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
Test your knowledge on database management concepts with this multiple-choice quiz. Topics include database instances, primary and foreign keys, and SQL statements. Perfect for students studying Database Systems.