Systems: Midterm study Exam And All
Correct Answers.
Which SQL keyword is used to sort the result-set in descending order using the NAME column?
a. SORT BY NAME DESC
b. ORDER BY NAME DESC
c. ORDER DESC NAME
d. ORDER NAME DESC - Answer b. ORDER BY NAME DESC
The following keyword selects records that have matching values in both tables.
a. LEFT JOIN
b. INNER JOIN
c. RIGHT JOIN
d. SELF JOIN - Answer b. INNER JOIN
With SQL, how can you delete the records from "Students" table where the "LastName" is Williams.
a. DELETE ROW Students WHERE LastName ='Williams';
b. DELETE FROM Students WHERE LastName ='Williams';
c. DELETE Students WHERE LastName ='Williams';
d. DELETE TABLE Students WHERE LastName = 'Williams'; - Answer b. DELETE FROM Students WHERE
LastName ='Williams';
,How do you change the marks of all students in Students table with marks 65 to 70 with SQL.
a. UPDATE Students SET Marks=65 WHERE Marks = 70;
b. MODIFY Students SET Marks=70 WHERE Marks = 65;
c. UPDATE Students SET Marks=70 WHERE Marks = 65; - Answer c. UPDATE Students SET Marks=70
WHERE Marks = 65;
With SQL, how do you select all the records from a table named "Students" where the "FirstName" is
Jack and "Marks" are greater than 65?
a. SELECT * FROM Students WHERE 'FirstName'='Jack' AND 'Marks'>65;
b. SELECT * FROM Students WHERE 'FirstName'='Jack', 'Marks'>65;
c. SELECT * FROM Students WHERE FirstName='Jack' AND Marks>65; - Answer c. SELECT * FROM
Students WHERE FirstName='Jack' AND Marks>65;
Which SQL keyword is used to group rows with same values.
a. JOIN
b. ORDER BY
c. COMBINE
d. GROUP BY - Answer d. GROUP BY
_____ is an attribute (or a set of attributes) in a database relation that has a unique value.
a. Foreign Key
b. Super Key
c. Secondary Key
, d. Alternate Key - Answer Super Key
_____ constraint dictates that the foreign key must contain values that match the primary key in the
related table, or must contain null.
a. Domain
b. Key
c. Referential Integrity
d. Entity Integrity - Answer Referential Integrity
Consider the following relations for a database that keeps track of business trips of salespersons in a
sales office:
SALESPERSON (SSN, Name, Start_Year, Dept_No)
TRIP (TripID, SSN, From_City, To_City, Departure_Date, Return_Date)
EXPENSE (TripID, Account#, Amount)
Identify the foreign keys for this schema:
a. TripID in EXPENSE relation references TRIP relation; SSN in TRIP relation references SALESPERSON
relation
b. TripID in EXPENSE relation references TRIP relation
c. SSN in SALESPERSON relation
d. Account# in EXPENSE relation - Answer a. TripID in EXPENSE relation references TRIP relation;
SSN in TRIP relation references SALESPERSON relation
Consider the following relations for a database that keeps track of business trips of salespersons in a
sales office: